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

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

相关推荐
wj3055853781 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
abigriver2 小时前
打造 Linux 离线大模型级语音输入法:Whisper.cpp + 3090 显卡加速与 Rime 中英混输终极调优指南
linux·运维·whisper
wangqiaowq2 小时前
windows下nginx的安装
linux·服务器·前端
YYRAN_ZZU3 小时前
Petalinux新建自动脚本启动
linux
charlie1145141913 小时前
嵌入式Linux驱动开发pinctrl篇(1)——从寄存器到子系统:驱动演进之路
linux·运维·驱动开发
Agent手记3 小时前
异常考勤智能预警与处理与流程优化方案 | 基于企业级Agent的超自动化实战教程
运维·人工智能·ai·自动化
于小猿Sup3 小时前
VMware在Ubuntu22.04驱动Livox Mid360s
linux·c++·嵌入式硬件·自动驾驶
cen__y3 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git
不仙5205 小时前
VMware Workstation 26.0.0 在 Ubuntu 24.04 (内核 6.17.0) 上的安装与内核模块编译问题
linux·ubuntu·elasticsearch
189228048616 小时前
NY352固态MT29F32T08GWLBHD6-24QJ:B
大数据·服务器·人工智能·科技·缓存