Appearance
系统盘清理指南
当实例系统盘空间不足1GB时,可能导致实例无法正常关机、重启。本文档将指导您快速定位并清理占用系统盘的冗余文件,恢复实例的正常使用。
一、查看磁盘使用情况
在清理之前,建议先确认当前磁盘占用状态:
bash
# 查看根目录下各一级目录的占用大小(已排除数据盘挂载目录)
du -h -d 1 --exclude=home --exclude=datasets --exclude=proc /二、建议清理的缓存目录
以下目录为常见的缓存或临时文件存储位置,清理后不影响正常使用:
| 路径 | 说明 |
|---|---|
/tmp/*、/var/tmp/* | 系统临时文件 |
~/.cache/pip | pip 安装包缓存 |
/root/comfyui/ComfyUI/temp/* | ComfyUI 运行时临时文件 |
~/.cache/huggingface | HuggingFace 模型缓存 |
~/.cache/torch | PyTorch 缓存 |
~/.triton、~/.cache/torchinductor | Triton / TorchInductor 编译缓存 |
~/.vscode-server | VS Code Server 缓存 |
~/.jupyter/lab/workspaces/* | Jupyter Lab 工作区缓存 |
/var/log/*.log 等 | 系统日志文件 |
core / core.* | 程序崩溃生成的 core dump 文件 |
**/__pycache__、*.pyc | Python 字节码缓存 |
三、一键清理脚本
为方便操作,我们提供了一键清理脚本,您可以直接下载并执行。
下载脚本
bash
cp /datasets/clear_mirror_new.sh /root/
cd /root/
chmod +x clear_mirror_new.sh执行脚本
bash
bash clear_mirror_new.sh脚本清理范围
脚本将依次执行以下清理操作:
| 步骤 | 清理内容 |
|---|---|
| 1 | conda 缓存(conda clean -a) |
| 2 | pip 缓存(pip cache purge + ~/.cache/pip) |
| 3 | Python 字节码缓存(__pycache__、*.pyc) |
| 4 | ComfyUI 临时文件(ComfyUI/temp/) |
| 5 | HuggingFace / PyTorch 缓存 |
| 6 | apt 包缓存(apt-get clean) |
| 7 | 系统临时文件(/tmp/、/var/tmp/) |
| 8 | VS Code Server 缓存(~/.vscode-server) |
| 9 | core dump 文件 |
| 10 | 系统日志(保留最近 3 天) |
| 11 | Jupyter 缓存与 .ipynb_checkpoints |
| 12 | Triton / TorchInductor 编译缓存 |
四、手动清理(按需执行)
如只需清理特定内容,可参考以下命令单独执行:
bash
# conda 缓存
conda clean -a -y
# pip 缓存
pip cache purge
rm -rf ~/.cache/pip
# Python 字节码缓存
find /root /opt /usr -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
find /root /opt /usr -type f -name "*.pyc" -delete 2>/dev/null
# ComfyUI 临时文件
rm -rf /root/comfyui/ComfyUI/temp/*
# HuggingFace / PyTorch 缓存
rm -rf ~/.cache/huggingface
rm -rf ~/.cache/torch
# apt 缓存
apt-get clean
rm -rf /var/lib/apt/lists/*
# 系统临时文件
rm -rf /tmp/* /var/tmp/*
# VS Code Server 缓存
rm -rf ~/.vscode-server
# core dump 文件
find / -maxdepth 3 -name "core" -type f -delete 2>/dev/null
find / -maxdepth 3 -name "core.*" -type f -delete 2>/dev/null
# 系统日志
journalctl --vacuum-time=3d 2>/dev/null
find /var/log -type f -name "*.log" -exec truncate -s 0 {} \; 2>/dev/null
# Jupyter 缓存
rm -rf ~/.jupyter/lab/workspaces/*
find /root -type d -name ".ipynb_checkpoints" -exec rm -rf {} + 2>/dev/null
# Triton / TorchInductor 缓存
rm -rf ~/.triton ~/.cache/torchinductor /tmp/torchinductor_*清理完成后,可在实例管理——系统盘,确认磁盘空间已释放。
五、注意事项
- 执行清理前,请确保没有正在运行的训练或推理任务,以免误删运行中依赖的临时文件。
- HuggingFace / PyTorch 缓存(
~/.cache/huggingface、~/.cache/torch)清理后,下次运行时需重新下载对应模型,请确认网络畅通或模型已有其他备份。 - VS Code Server(
~/.vscode-server)清理后,重新连接时会自动重新安装,不影响使用,但需等待片刻。 core/core.*为程序崩溃生成的 core dump 文件,如需排查崩溃原因,请在删除前先完成分析。- 系统日志默认保留最近 3 天,如需保留更长时间的日志,请勿执行日志清理步骤。
- 如果清理后磁盘空间仍然不足,建议进一步排查用户数据目录(如模型权重、输出图片等),考虑迁移至数据盘/home/waas存储。
- 如问题持续存在,请联系平台技术支持。
如有疑问,请联系客服。