Fixing initrd via chroot

2017/01/08

One of my first upgrades via slackpkg ended with a kernel panic.

   Kernal panic - not syncing: VFS: Unable to mount root FS unknown-(block8.1)

The upgrade moved from my box from kernel 4.4.32-x86_64-1 to 4.4.38-x86_64-1

The kernel upgrade somehow changed from the huge kernel to the generic one. I was missing the initrd ram disk needed for the generic kernel to boot.

I was able to boot the slackware install DVD and from there can see the virtual harddisk "/dev/sda1". I was able to mount it. In the /boot directory new kernel was vlinuz-generic-4.4.38 and the old kernel vmlinuz-huge-4.4.32. vmlinuz was sym-linked to the generic 4.4.38

Thru linuxquestions and a bit of help from Mr Google, I was able to find the process to create a initrd.

  1. load the slackware install DVD into the drive and boot

  2. login as root

  3. mount the drive, create suitable environment, and chroot into it Code:

    $ mount /dev/sda1 /mnt $ mount --bind /dev /mnt/dev $ mount --bind /proc /mnt/proc $ mount --bind /sys /mnt/sys $ chroot /mnt

  4. run script to get mkinitrd command suggestion, and then run the command Code:

    $ cd /usr/share/mkinitrd $ ./mkinitrd_command_generator.sh -k 4.4.38

    $ mkinitrd -c -k 4.4.38 -f ext4 -r /dev/sda1 -m jbd2:mbcache:ext4 -u -o /boot/initrd.gz

  5. edit /etc/lilo.conf to include reference to the new initrd file Code:

    image = /boot/vmlinuz initrd = /boot/initrd.gz # add this line so that lilo sees initrd.gz root = /dev/sda1 label = Linux read-only

  6. update the boot loader Code:

    $ lilo

  7. un-mount things and exit from chroot environment Code:

    $ exit $ umount /dev $ umount /proc $ umount /sys $ umount /mnt

  8. reboot .... and smile when the login prompt appears.

. .

I heard aftewards that it is better up upgrade the kernel with installpkg instead of slackpkg.


Guestbook and Comments

Back