[Kernel/Drive] 请问是否可以手动删除/boot中的内核
Tofloor
poster avatar
lin_lcs
deepin
2025-01-14 15:27
Author

最近更新系统的时候发现/boot分区满了,删除旧的内核的时候发现有一个内核版本删不掉

执行 sudo update-grub,结果如下

 maba@maba-PC:~$ sudo update-grub
Generating grub configuration file ...
Found theme: /boot/grub/themes/deepin-fallback/theme.txt
Found background image: /boot/grub/themes/deepin-fallback/background.jpg
Found linux image: /boot/vmlinuz-6.12.1-amd64-desktop-rolling
Found initrd image: /boot/initrd.img-6.12.1-amd64-desktop-rolling
Found linux image: /boot/vmlinuz-5.15.77-amd64-desktop
Found initrd image: /boot/initrd.img-5.15.77-amd64-desktop
Found initrd image: /boot/deepin-ab-recovery/initrd.img-5.15.77-amd64-desktop
sh: 0: cannot open /usr/libexec/deepin-ab-recovery/deepin_ab_recovery_get_backup_grub_args.sh: No such file
11_deepin_ab_recovery back grub args: 
Warning: version_find_latest() is deprecated. Use version_sort() instead.
Warning: version_test_gt() is deprecated. Use version_sort() instead.
Warning: version_test_gt() is deprecated. Use version_sort() instead.
Warning: version_test_numeric() is deprecated. Use version_sort() instead.
Found  image: /boot/vmlinuz-6.12.1-amd64-desktop-rolling
Found initrd image: /boot/initrd.img-6.12.1-amd64-desktop-rolling
Skipped Deepin 20.9 (20.9) on /dev/sda4 by user request.
done

这时候一个5.15版本的内核,但是执行 dpkg --get-selections |grep linux-image,没有该版本,结果如下


maba@maba-PC:~$ dpkg --get-selections |grep linux-image
linux-image-6.12.1-amd64-desktop-rolling        install
linux-image-deepin-amd64                        install

查看 /boot目录

 oot@maba-PC:/boot# ls -l
总计 370936
-rw-r--r-- 1 root root    260127 2023年 6月15日 config-5.15.77-amd64-desktop
-rw-r--r-- 1 root root    305642 12月 4日 18:26 config-6.12.1-amd64-desktop-rolling
drwxr-xr-x 2 root root      4096 2009年 5月17日 deepin-ab-recovery
drwxr-xr-x 3 root root      4096 1970年 1月 1日 efi
drwxr-xr-x 2 root root      4096 2009年 5月17日 fonts
drwxr-xr-x 6 root root      4096  1月14日 14:57 grub
-rw-r--r-- 1 root root  52120732  1月14日 14:48 initrd.img-5.15.77-amd64-desktop
-rw-r--r-- 3 root root  97817930 2023年 8月15日 initrd.img-5.15.77-amd64-desktop.old-dkms
-rw-r--r-- 1 root root 189465230  1月14日 14:49 initrd.img-6.12.1-amd64-desktop-rolling
drwx------ 2 root root      4096 2009年 5月17日 lost+found
drwx------ 4 root root      4096  1月14日 14:57 snapshot
-rw-r--r-- 1 root root   5964162 2023年 6月15日 System.map-5.15.77-amd64-desktop
-rw-r--r-- 1 root root   8901911 12月 4日 18:26 System.map-6.12.1-amd64-desktop-rolling
-rw-r--r-- 3 root root  10823592 2023年 6月15日 vmlinuz-5.15.77-amd64-desktop
-rw-r--r-- 1 root root  14126408 12月 4日 18:26 vmlinuz-6.12.1-amd64-desktop-rolling
root@maba-PC:/boot# ls -l /de
deepin-fix-init-bdsGSL  deepin-fix-init-hhMZGI  dev/                
deepin-fix-init-Ck2KlP  deepin-fix-init-hn04vL  
root@maba-PC:/boot# ls -l ./deepin-ab-recovery/
总计 107644
-rw-r--r-- 1 root root 99400259  8月20日 09:47 initrd.img-5.15.77-amd64-desktop
-rw-r--r-- 1 root root 10823592  8月20日 09:47 vmlinuz-5.15.77-amd64-desktop

所以,我想问这个内核能不能手动删除,主要是 /boot分区有点满了,2GB占了88%,而且执行 update-grub非常慢

可能是因为从V20.9通过官方升级工具升级导致的(现在启动还有选项回滚回V20)

现在系统是V23,内核版本为6.12.1-amd64-desktop-rolling,而且我也不想重装了,重装软件很麻烦,升级后还没有什么其他大的问题。

Reply Favorite View the author
All Replies
expskywalker
deepin
2025-01-14 15:43
#1

不想回退就可以删除。

Reply View the author
132******48
deepin
2025-01-14 16:41
#2

sudo apt purge 5.15的

Reply View the author
lin_lcs
deepin
2025-01-14 18:24
#3
It has been deleted!
lin_lcs
deepin
2025-01-14 18:43
#4
132******48

sudo apt purge 5.15的

但是dpkg找不到有关5.15的包,应该用不了apt了

Reply View the author
LiuYongzhang
deepin
2025-01-14 20:15
#5

直接进入boot用管理员模式 删除相关版本号的所有文件即可。然后sudo update-grub更新一下即可

Reply View the author
lin_lcs
deepin
2025-01-14 21:58
#6
LiuYongzhang

直接进入boot用管理员模式 删除相关版本号的所有文件即可。然后sudo update-grub更新一下即可

好的,明天我试试

Reply View the author
lin_lcs
deepin
2025-01-15 09:43
#7
LiuYongzhang

直接进入boot用管理员模式 删除相关版本号的所有文件即可。然后sudo update-grub更新一下即可

我删了后,执行 sudo updagte-grub还是会去找5.15内核

maba@maba-PC:~$ sudo update-grub
请输入密码:
验证成功
Generating grub configuration file ...
Found theme: /boot/grub/themes/deepin-fallback/theme.txt
Found background image: /boot/grub/themes/deepin-fallback/background.jpg
Found linux image: /boot/vmlinuz-6.12.1-amd64-desktop-rolling
Found initrd image: /boot/initrd.img-6.12.1-amd64-desktop-rolling
Found initrd image: /boot/deepin-ab-recovery/initrd.img-5.15.77-amd64-desktop
/usr/bin/grub-mkrelpath: 错误: 获取 "/boot/deepin-ab-recovery" 的规范路径失败.
sh: 0: cannot open /usr/libexec/deepin-ab-recovery/deepin_ab_recovery_get_backup_grub_args.sh: No such file
11_deepin_ab_recovery back grub args: 
Warning: version_find_latest() is deprecated. Use version_sort() instead.
Warning: version_test_gt() is deprecated. Use version_sort() instead.
Found  image: /boot/vmlinuz-6.12.1-amd64-desktop-rolling
Found initrd image: /boot/initrd.img-6.12.1-amd64-desktop-rolling
Skipped Deepin 20.9 (20.9) on /dev/sda4 by user request.
done

打算重装了,切换音频框架结果没声了,切换的设置也变灰了sob

Reply View the author
观察者
deepin
2025-01-16 10:06
#8

删除不掉的原因可能你正在使用那个内核

initrd.img 过大

清理旧的内核和 initrd.img
如果系统中存在多个旧的内核和 initrd.img 文件,可以清理它们以释放空间:

  • 列出所有内核和 initrd.img

    dpkg --list | grep linux-image
    
  • 删除旧的内核和 initrd.img

    sudo apt purge linux-image-<旧内核版本>
    
  • 更新 GRUB
    删除旧内核后,更新 GRUB 配置:

    sudo update-grub
    
Reply View the author