Skip to content

Instantly share code, notes, and snippets.

@askdaddy
Last active March 16, 2020 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save askdaddy/acbbcb09747db81bcc5990e7c98becbb to your computer and use it in GitHub Desktop.
Save askdaddy/acbbcb09747db81bcc5990e7c98becbb to your computer and use it in GitHub Desktop.
清理/boot目录

参考1: How do I free up more space in /boot? 参考2: What is the safest way to clean up /boot partition?

# as root
# 先看看当前用的内核版本
uname -r

# STEP 1
# 手动删掉目录里一些旧的数据 initrd.img- 开头的,释放点空间,别删当前版本号的
# 禁止initramfs更新.在apt运行时这个工具会在boot目录生 initrd.img 
# 把 update_initramfs=yes 改为 no
# 在所有操作结束后再改回来
vim /etc/initramfs-tools/update-initramfs.conf # update_initramfs=no


# STEP 2
# 强制apt 把安装进度跑完
# 这一步就需要上一步的准备,因为卡一半的安装进度就是在安装新版本的内核。这步不走完apt根本不会做别的动作
apt -f install


# STEP 3
# 重启会让系统用上一步装的新版本内核引导系统
reboot

# STEP 4
# 清理,此命令会自己卸载老版本内核
apt autoremove

# STEP 5
vim /etc/initramfs-tools/update-initramfs.conf # update_initramfs=yes



# 看一下当前装了哪些版本
dpkg --list 'linux-image*' | grep ^ii

# uninstall
apt-get remove linux-image-VERSION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment