0

I am trying to recover from attempt to remove a specific kernel ... I can login to Ubuntu using previous kernel release shown on login GRUB menu ( avoiding the newest top most kernel which I am trying to delete )

while logged in under 5.4.0-16-generic which is my good kernel I want to delete bad 5.4.0-17-generic ... I have already removed bad using

sudo apt-get remove linux-image-5.4.0-17-generic

and ran grub update

sudo update-grub

and did a reboot however bad 5.4.0-17 is still my default boot up kernel ... here is my /boot dir

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

Is it OK to manually remove from above dir everything for the bad kernel ? file, symlink to bad 5.4.0-17 and then make new symlinks pointing to good 5.4.0-16 ? or is there a better way ?

ubuntu 20.04

1 Answer 1

0

Evidently the answer is yes ... I just manually removed bad kernel files and symlinks then recreated symlinks to good kernel ... and with a reboot all is well ... as per

at first I see

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

then I issue

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 

finally I then see

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 $ 

about to update grub and reboot

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .