While following the instruction from the nVidia .run script to delete drm-kmp-default I accidentally (and carelessly and stupidly) deleted all the kernel files under /boot. So now I am unable to boot into 42.3. I only backup up my data so there is no system backup. Is there a simple method to recover those kernels and regenerate my grub menu?
If you need to access the installed system from the rescue system, you need to do this in a change root environment. For example, to modify the boot loader configuration, or to execute a hardware configuration utility.
To set up a change root environment based on the installed system, proceed as follows:
Run lsblk to check which node corresponds to the root partition. It is /dev/sda2 in our example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149,1G 0 disk
├─sda1 8:1 0 2G 0 part [SWAP]
├─sda2 8:2 0 20G 0 part /
└─sda3 8:3 0 127G 0 part
└─cr_home 254:0 0 127G 0 crypt /home
Mount the root partition from the installed system:
mount /dev/sda2 /mnt
Mount /proc, /dev, and /sys partitions:
mount -t proc none /mnt/proc
mount --rbind /dev /mnt/dev
mount --rbind /sys /mnt/sys
Now you can “change root” into the new environment, keeping the bash shell:
chroot /mnt /bin/bash
Finally, mount the remaining partitions from the installed system:
Now you have access to the installed system. Before rebooting the system, unmount the partitions with umount -a and leave the “change root” environment with exit.
Although you have full access to the files and applications of the installed system, there are some limitations. The kernel that is running is the one that was booted with the rescue system, not with the change root environment. It only supports essential hardware and it is not possible to add kernel modules from the installed system unless the kernel versions are identical. Always check the version of the currently running (rescue) kernel with uname -r and then find out if a matching subdirectory exists in the /lib/modules directory in the change root environment. If yes, you can use the installed modules, otherwise you need to supply their correct versions on other media, such as a flash disk. Most often the rescue kernel version differs from the installed one — then you cannot simply access a sound card, for example. It is also not possible to start a graphical user interface.
Also note that you leave the “change root” environment when you switch the console with Alt–F1 to Alt–F6.
Assuming that, a Leap 42.3 installation DVD is available (haven’t tried the Network Installation CD-ROM), boot the DVD and attempt the system repair tools on the DVD.
Failing that, a re-install without reformatting any (neither system nor user) partitions is needed.
The tools on the DVD should allow the inspection of ‘/etc/’ – hopefully ‘passwd’ and ‘group’ are still intact – if not, inspection of the ‘/home/’ partition(s) may help to recover at least the system’s users UIDs and GIDs.
Are your main filesystems using Btrfs? If so, you likely have a snapshot
at some point before this happened, particularly if you used ‘zypper’ to
do your accidental-kernel-deletion, and that means you should be able to
use Grub to boot from a prior snapshot and there you go. That is how it
works on SLES anyway.
If you changed the defaults away from Btrfs, well now you know why you
should NOT do that.
If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.
If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.
Thanks for the advice. I managed to boot into the damaged installation. There were a number of other problems that I won’t bother you with but as you can see I am online again, and I WILL be backing up my /boot directory as of today.
Thanks to everyone for helping. It’s wonderful to have such solid support.