User Tools

Site Tools


howtos:recover_from_broken_update-initramfs

Situation

If you end up in a (initramfs) shell after a kernel update, chances are that the update-initramfs didn't finish properly.

Rescue preps

Get hold of a live USB with the latest Ubuntu release. With this we can gain access to the broken machine.

The Rescue

Bootup on the USB key. Then mount the harddrive of broken machine, this is done easies via Nautilus. Open Nautilus and find the harddrive in the left colon and click on it to mount it.

Open a terminal and venture into the /media directory. Inside /media you should now only find one directory with the UID name of the just mounted harddrive. To get update-initramfs working we need some basic environment setup done before we chroot. Execute the following commands to do that (86b25c37-24d7-44cd-b09d-31669338ea73 is the name of my harddrive where my broken Ubuntu resides):

root@ubuntu:/# cd /media/86b25c37-24d7-44cd-b09d-31669338ea73
root@ubuntu:/media/86b25c37-24d7-44cd-b09d-31669338ea73# mount --bind /dev ./dev
root@ubuntu:/media/86b25c37-24d7-44cd-b09d-31669338ea73# mount --bind /proc ./proc
root@ubuntu:/media/86b25c37-24d7-44cd-b09d-31669338ea73# mount --bind /sys ./sys
root@ubuntu:/media/86b25c37-24d7-44cd-b09d-31669338ea73# chroot .

Now we can finish up the mess the update process left behind:

root@ubuntu:/# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]? 
Can not write log, openpty() failed (/dev/pts not mounted?)
Setting up linux-image-2.6.35-22-generic (2.6.35-22.35) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.35-22-generic
Not updating initrd symbolic links since we are being updated/reinstalled 
(2.6.35-22.34 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled 
(2.6.35-22.34 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
 * dkms: running auto installation service for kernel 2.6.35-22-generic         
 *       vboxhost (3.2.10)...                                            [ OK ] 
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postinst.d/nvidia-common 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found memtest86+ image: /boot/memtest86+.bin
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
ls: cannot access /casper-rw-backing: No such file or directory
Found Windows 7 (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda2
done
Setting up udev (162-2.1) ...
udev start/running, process 19138
update-initramfs: deferring update (trigger activated)
Setting up gconf2 (2.31.91-0ubuntu3.1) ...
Setting up gnome-settings-daemon (2.32.0-0ubuntu3) ...
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-2.6.35-22-generic
root@ubuntu:/# 

Now things should be all dandy again and you can reboot out of the live USB environment and into you normal desktop.

Troubleshooting

If you see something like this:

update-initramfs: Generating /boot/initrd.img-2.6.35-22-generic
/usr/sbin/mkinitramfs: 142: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
/usr/sbin/mkinitramfs: 233: cannot create /dev/null: Permission denied
...
...
...
...
...

then you forgot to mount /proc, /dev and /sys before you chroot'ed.

howtos/recover_from_broken_update-initramfs.txt · Last modified: d/m/Y H:i (external edit)