怎样清理boot引导区

2024年8月31日 | 分类: 【技术】

问题:怎样迁移boot引导区

参考:https://blog.csdn.net/wangganggelian/article/details/49848305

查看当前内核版本:

uname -r

查看boot的使用情况即可

df -lh

将boot移除,然后重新添加新的boot目录:

由于安装系统时没有仔细看,/boot目录默认设置只有100M,这样编译几个版本的内核/boot空间就不够用了。mount一下,看到/boot目录被挂在到/dev/sda1上,空间只有100M,解决办法:

1. umount /boot
2. mkdir /boot_old
3. mount /dev/sda1 /boot_old
4. 到/boot_old目录下: cp -rp * /boot
5. 删除/etc/fstab表中含有 /boot项

该方法是取消将/boot挂在到sda1上,而是直接使用/boot目录,但是需要将原来在/dev/sda1上的文件拷贝到/boot下。

问题:怎样清理boot引导区

当从终端登录 Ubuntu ,发现提示:

New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

执行:

do-release-upgrade

如果提示 /boot 空间不足:

Not enough free disk space
The upgrade has aborted. The upgrade needs a total of 251 M free
space on disk '/boot'. Please free at least an additional 24.1 M of
disk space on '/boot'. You can remove old kernels using 'sudo apt
autoremove' and you could also set COMPRESS=xz in
/etc/initramfs-tools/initramfs.conf to reduce the size of your
initramfs.

您将删除未使用的内核以释放 /boot 分区中的空间。 您所要做的就是输入:

sudo apt autoremove

这不仅会删除未使用的内核,还会消除您不需要或任何安装的工具都不需要的依赖项。

如果依然不足:

查看当前内核:

uname -r

输出:

5.15.0-119-generic

使用 rm 命令使用以下命令从启动分区中删除特定无用内核(每个命令一个命令):

sudo rm /boot/initrd.img-5.15.0-94-generic
sudo rm /boot/vmlinuz-5.15.0-94-generic

参考:https://cn.linux-console.net/?p=18276