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

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

相关推荐
少妇的美梦13 小时前
logstash教程
运维
chen94513 小时前
k8s集群部署vector日志采集器
运维
chen94513 小时前
aws ec2部署harbor,使用s3存储
运维
轻松Ai享生活17 小时前
5 节课深入学习Linux Cgroups
linux
christine-rr18 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
三坛海会大神55518 小时前
LVS与Keepalived详解(二)LVS负载均衡实现实操
linux·负载均衡·lvs
東雪蓮☆18 小时前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
qq_2642208918 小时前
LVS负载均衡群集和LVS+Keepalived群集
运维·负载均衡·lvs
乌萨奇也要立志学C++19 小时前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
雨落Liy19 小时前
Nginx 从入门到进阶:反向代理、负载均衡与高性能实战指南
运维·nginx·负载均衡