Xen Server服务器释放磁盘空间

disk.sh

shell 复制代码
#!/bin/bash

cd /run/sr-mount/e54f0646-ae11-0457-b64f-eba4673b824c
# 全部虚拟机物理磁盘文件存储
a=$(ls -l | awk '{print $NF}' | cut -d'.' -f1)
# 使用中的虚拟机物理磁盘文件
b=$(xe vm-disk-list --multiple | grep uuid | awk '{print $NF}')

printf "%s\n" "${a[@]}" | sort > /tmp/a_sorted.txt
printf "%s\n" "${b[@]}" | sort > /tmp/b_sorted.txt

#comm -23 /tmp/b_sorted.txt /tmp/a_sorted.txt
#comm -13 /tmp/b_sorted.txt /tmp/a_sorted.txt

# 获取未使用的垃圾磁盘文件,删除,释放空间
array=($(comm -13 /tmp/b_sorted.txt /tmp/a_sorted.txt))

#echo ${#array[@]}
for i in "${array[@]}"; do
        file="$i.vhd"
        if [[ -f $file ]]; then
                du -sh $file
        fi
done

bash disk.sh | sort -rh | cat -n

以上结果可删除释放磁盘空间

相关推荐
yc_122425 分钟前
用 Visual Studio 远程调试 Linux:从零到流畅的完整指南
linux·ide·visual studio
思茂信息26 分钟前
CST软件如何进行参数化扫描?
运维·开发语言·javascript·windows·ecmascript·软件工程·软件需求
计算机安禾1 小时前
【Linux从入门到精通】第31篇:防火墙漫谈——iptables与firewalld防护指南
linux·运维·php
下一页盛夏花开1 小时前
ubuntu 20中安装QT以后出现红色空心断点
linux·运维·ubuntu
金色光环1 小时前
FreeModbus释放底层的 TCP 监听端口
服务器·网络·tcp/ip
sanshanjianke2 小时前
Thunderobot 911ME 笔记本 Linux 风扇控制研究
linux
sxgzzn4 小时前
光伏数智化综合平台:让光伏电站运维更智能、更高效
运维
fengyehongWorld4 小时前
TeraTerm ttl脚本登录wsl
linux·teraterm
乌托邦的逃亡者5 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip