我正在尝试从删除特定内核的尝试中恢复...我可以使用登录 GRUB 菜单上显示的先前内核版本登录 Ubuntu(避免我试图删除的最新最顶层内核)
登录时,在 5.4.0-16-generic
我的好内核下,我想删除坏的 5.4.0-17-generic
...我已经使用删除了坏的
sudo apt-get remove linux-image-5.4.0-17-generic
并运行 grub update
sudo update-grub
并重新启动,但糟糕的是 5.4.0-17 仍然是我的默认启动内核...这是我的/boot
目录
pie@peach /boot $ ls -la
total 271188
drwxr-xr-x 5 root root 4096 Mar 7 14:05 .
drwxr-xr-x 28 root root 4096 Feb 10 09:40 ..
-rw-r--r-- 1 root root 237656 Feb 6 17:30 config-5.4.0-14-generic
-rw-r--r-- 1 root root 237694 Feb 26 13:22 config-5.4.0-16-generic
-rw-r--r-- 1 root root 237694 Feb 27 08:29 config-5.4.0-17-generic
drwx------ 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 4096 Mar 7 14:18 grub
lrwxrwxrwx 1 root root 27 Mar 7 14:04 initrd.img -> initrd.img-5.4.0-17-generic
-rw-r--r-- 1 root root 99646073 Feb 21 07:12 initrd.img-5.4.0-14-generic
-rw-r--r-- 1 root root 99685332 Feb 27 13:52 initrd.img-5.4.0-16-generic
-rw-r--r-- 1 root root 27953789 Mar 7 14:05 initrd.img-5.4.0-17-generic
lrwxrwxrwx 1 root root 27 Mar 7 14:04 initrd.img.old -> initrd.img-5.4.0-16-generic
drwx------ 2 root root 16384 Jun 1 2019 lost+found
-rw-r--r-- 1 root root 182704 Feb 13 18:09 memtest86+.bin
-rw-r--r-- 1 root root 184380 Feb 13 18:09 memtest86+.elf
-rw-r--r-- 1 root root 184884 Feb 13 18:09 memtest86+_multiboot.bin
-rw------- 1 root root 4714929 Feb 6 17:30 System.map-5.4.0-14-generic
-rw------- 1 root root 4730982 Feb 26 13:22 System.map-5.4.0-16-generic
-rw------- 1 root root 4730982 Feb 27 08:29 System.map-5.4.0-17-generic
lrwxrwxrwx 1 root root 24 Mar 7 14:04 vmlinuz -> vmlinuz-5.4.0-17-generic
-rw------- 1 root root 11596536 Feb 6 17:31 vmlinuz-5.4.0-14-generic
-rw------- 1 root root 11645688 Feb 26 12:48 vmlinuz-5.4.0-16-generic
-rw------- 1 root root 11643776 Feb 27 08:29 vmlinuz-5.4.0-17-generic
lrwxrwxrwx 1 root root 24 Mar 7 14:04 vmlinuz.old -> vmlinuz-5.4.0-16-generic
可以从上面的目录中手动删除坏内核的所有内容吗?文件,符号链接为坏5.4.0-17
,然后创建新的符号链接指向好 5.4.0-16
?或者,还有更好的方法 ?
ubuntu 20.04
答案1
显然答案是肯定的...我只是手动删除了坏内核文件和符号链接,然后重新创建了指向好内核的符号链接...并且重新启动后一切都很好...按照
起初我看到
pie@peach /boot $ s
total 259816
drwxr-xr-x 5 root root 4096 Mar 7 14:59 .
drwxr-xr-x 28 root root 4096 Feb 10 09:40 ..
-rw-r--r-- 1 root root 237656 Feb 6 17:30 config-5.4.0-14-generic
-rw-r--r-- 1 root root 237694 Feb 26 13:22 config-5.4.0-16-generic
-rw-r--r-- 1 root root 237694 Feb 27 08:29 config-5.4.0-17-generic
drwx------ 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 4096 Mar 7 14:58 grub
lrwxrwxrwx 1 root root 27 Mar 7 14:04 initrd.img -> initrd.img-5.4.0-17-generic
-rw-r--r-- 1 root root 99646073 Feb 21 07:12 initrd.img-5.4.0-14-generic
-rw-r--r-- 1 root root 99685332 Feb 27 13:52 initrd.img-5.4.0-16-generic
-rw-r--r-- 1 root root 27953789 Mar 7 14:05 initrd.img-5.4.0-17-generic
lrwxrwxrwx 1 root root 27 Mar 7 14:04 initrd.img.old -> initrd.img-5.4.0-16-generic
drwx------ 2 root root 16384 Jun 1 2019 lost+found
-rw-r--r-- 1 root root 182704 Feb 13 18:09 memtest86+.bin
-rw-r--r-- 1 root root 184380 Feb 13 18:09 memtest86+.elf
-rw-r--r-- 1 root root 184884 Feb 13 18:09 memtest86+_multiboot.bin
-rw------- 1 root root 4714929 Feb 6 17:30 System.map-5.4.0-14-generic
-rw------- 1 root root 4730982 Feb 26 13:22 System.map-5.4.0-16-generic
-rw------- 1 root root 4730982 Feb 27 08:29 System.map-5.4.0-17-generic
lrwxrwxrwx 1 root root 24 Mar 7 14:04 vmlinuz -> vmlinuz-5.4.0-17-generic
-rw------- 1 root root 11596536 Feb 6 17:31 vmlinuz-5.4.0-14-generic
-rw------- 1 root root 11645688 Feb 26 12:48 vmlinuz-5.4.0-16-generic
lrwxrwxrwx 1 root root 24 Mar 7 14:04 vmlinuz.old -> vmlinuz-5.4.0-16-generic
然后我发出
pie@peach /boot $
pie@peach /boot $ sudo rm -rf config-5.4.0-17-generic initrd.img-5.4.0-17-generic System.map-5.4.0-17-generic
pie@peach /boot $ sudo rm initrd.img
pie@peach /boot $ sudo ln -s initrd.img-5.4.0-16-generic initrd.img
pie@peach /boot $ s initrd.img.old
lrwxrwxrwx 1 root root 27 Mar 7 14:04 initrd.img.old -> initrd.img-5.4.0-16-generic
pie@peach /boot $ sudo rm initrd.img.old
pie@peach /boot $ sudo ln -s initrd.img-5.4.0-14-generic initrd.img.old
pie@peach /boot $ sudo rm vmlinuz
pie@peach /boot $ sudo ln -s vmlinuz-5.4.0-16-generic vmlinuz
pie@peach /boot $ sudo rm vmlinuz.old
pie@peach /boot $ sudo ln -s vmlinuz-5.4.0-14-generic vmlinuz.old
最后我看到
pie@peach /boot $ s
total 227656
drwxr-xr-x 5 root root 4096 Mar 7 15:00 .
drwxr-xr-x 28 root root 4096 Feb 10 09:40 ..
-rw-r--r-- 1 root root 237656 Feb 6 17:30 config-5.4.0-14-generic
-rw-r--r-- 1 root root 237694 Feb 26 13:22 config-5.4.0-16-generic
drwx------ 3 root root 4096 Dec 31 1969 efi
drwxr-xr-x 5 root root 4096 Mar 7 14:58 grub
lrwxrwxrwx 1 root root 27 Mar 7 14:59 initrd.img -> initrd.img-5.4.0-16-generic
-rw-r--r-- 1 root root 99646073 Feb 21 07:12 initrd.img-5.4.0-14-generic
-rw-r--r-- 1 root root 99685332 Feb 27 13:52 initrd.img-5.4.0-16-generic
lrwxrwxrwx 1 root root 27 Mar 7 15:00 initrd.img.old -> initrd.img-5.4.0-14-generic
drwx------ 2 root root 16384 Jun 1 2019 lost+found
-rw-r--r-- 1 root root 182704 Feb 13 18:09 memtest86+.bin
-rw-r--r-- 1 root root 184380 Feb 13 18:09 memtest86+.elf
-rw-r--r-- 1 root root 184884 Feb 13 18:09 memtest86+_multiboot.bin
-rw------- 1 root root 4714929 Feb 6 17:30 System.map-5.4.0-14-generic
-rw------- 1 root root 4730982 Feb 26 13:22 System.map-5.4.0-16-generic
lrwxrwxrwx 1 root root 24 Mar 7 15:00 vmlinuz -> vmlinuz-5.4.0-16-generic
-rw------- 1 root root 11596536 Feb 6 17:31 vmlinuz-5.4.0-14-generic
-rw------- 1 root root 11645688 Feb 26 12:48 vmlinuz-5.4.0-16-generic
lrwxrwxrwx 1 root root 24 Mar 7 15:00 vmlinuz.old -> vmlinuz-5.4.0-14-generic
pie@peach /boot $
即将更新 grub 并重新启动
pie@peach /boot $ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-16-generic
Found initrd image: /boot/initrd.img-5.4.0-16-generic
Found linux image: /boot/vmlinuz-5.4.0-14-generic
Found initrd image: /boot/initrd.img-5.4.0-14-generic
Adding boot menu entry for UEFI Firmware Settings
done