122

Upon trying to upgrade from 10.10 to 11.04 all seemed to go well until the restart. This error message is what comes up:

Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

How do we fix that?

  • 1
    Your troubles might having nothing to do with your main system, but rather with your install media (USB stick)... ➪ see here: askubuntu.com/a/632636/479118 – Frank Nocke Dec 4 '15 at 18:00
  • I can't post an answer since I don't have enough rep, but when I got this problem I solved it by booting to a live USB stick, mounting the main and EFI partitions, enabling networking, and running sudo apt-get install linux-image-generic to upgrade to the latest kernel. – Owen Apr 23 '19 at 4:04
111

You are missing the initramfs for that kernel. Choose another kernel from the GRUB menu under Advanced options for Ubuntu and run sudo update-initramfs -u -k version to generate the initrd for version (replace version with the kernel version string such as 4.15.0-36-generic) then sudo update-grub.

| improve this answer | |
  • 5
    what if the kernel panic is being shown when selecting the unique kernel option that exists for that OS (in a multi-boot scenario), how does one go to launch update-initramfs? – knocte Jan 29 '14 at 9:04
  • 4
    @knocte, See Tomeu Roig's answer. – psusi Jan 29 '14 at 14:07
  • 3
    I cannot enter Ubuntu System or Recovery Mode, how can I execute that command to test whether it works? – Casper Jul 16 '16 at 9:54
  • 1
    @sherrellbc, it does have to do with the rootfs. The kernel can't mount the rootfs because it isn't configured correctly to do so. Instead it is assumed that the kernel will use an initramfs to mount the rootfs. In the days before initramfs, you had to configure the kernel to know a hard coded block number for the rootfs to mount, and this is the behavior it falls back to when it has no initramfs. – psusi Feb 11 '18 at 2:43
  • 1
    In my case, the cause was running out of storage space. So I chose a previous kernel, booted, deleted stuff from the hard drive, and rebooted back to the original kernel. – Ibu Jun 11 '18 at 21:51
65

Start with a livecd, open a a terminal

sudo fdisk -l
sudo mount /dev/sdax /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt 

and now you can make update-initramfs and update-grub without errors.

update-initramfs -u -k 2.6.38-8-generic (or your version)

If you don't know your version. Use:

dpkg --list | grep linux-image

And just update Grub.

update-grub2

Reboot your system.

| improve this answer | |
  • 2
    I have added sudo mount --bind /dev/pts /mnt/dev/pts and sudo mount --bind /sys /mnt/sys in my edit; without this, update-grub2 complained. – Hbf Nov 8 '12 at 15:51
  • 6
    how can I found out the exact version? – knocte Jan 29 '14 at 9:05
  • 1
    None of the mount points exist beyond the first one /dev/sdax if you're using EFI. – Paul Gregoire Jul 28 '14 at 14:36
  • 1
    Very nice - this worked for me in eliminating the 'kernel panic' error. I still had to follow it up by selecting the 'repair' start-up option in grub and selecting 'fix broken packages'. That took care of my remaining issues. – Gatmando Mar 22 '16 at 23:27
  • 1
    mount: mount point {path} does not exist. All the mount points does not exist. How can I solve the problem? – Casper Jul 16 '16 at 10:07
33

In case this happened after an aborted kernel update (e.g. system crash while aptitude safe-upgrade),

  1. boot with an older kernel and
  2. run dpkg --configure -a.

This will complete the upgrade, including configuring the boot settings as psusi explains.

| improve this answer | |
23

In my situation the problem was that /boot was at 100% capacity, so the last 2 kernel updates had not completed successfully, hence on reboot when GRUB2 selected the latest Kernel, it failed.

I resolved the issue by booting into the oldest kernel installed, and removing some unused kernels using aptitude. By using aptitude, after the uninstall had happened, dpkg automatically tried to configure the broken packages, and this time succeeded.

| improve this answer | |
  • 4
    This was the closest to my solution; just running dpkg --configure -a was enough to trigger the update-initramfs hook, and fix the broken kernel. – Symmetric May 11 '13 at 19:44
  • You mean you had a separate /boot partition is that it? – Ciro Santilli 冠状病毒审查六四事件法轮功 Oct 1 '15 at 7:00
  • 1
    It was a server set up prior to my arrival, and it was configured with /boot on it's own partition and unattended-upgrades – sheepeatingtaz Oct 1 '15 at 14:24
  • 3
    You can use sudo apt-get autoremove to remove old kernels in case your running out of space on /boot. – Florian Brucker Jul 21 '16 at 5:42
  • I booted into an older kernel, did a sudo apt-get autoremove, rebooted again (older kernel), then did a sudo apt-get dist-upgrade, and this worked. This was on a small test machine I have. Same issue though, 100% /boot – jmlumpkin May 23 '18 at 2:51
2

The kernel boot messages tell you which disks you can use

For example, if in my test Linux 4.17 virtual machine setup I replace the correct root=/dev/vda with root=/dev/vdb the last message is:

---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)-

However, a few lines above, it shows messages of type:

VFS: Cannot open root device "vdb" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
fe00          524288 vda
 driver: virtio_blk

which basically tells me straight out that vdb was not found, but that there is a /dev/vda which can be read due to the virtio_blk driver (CONFIG_VIRTIO_BLK=y).

| improve this answer | |
1

I faced this problem, as linux headers were getting updated, and electricity was gone. I recovered as below,

Go to grub menu and select advanced options > select a previous kernel and boot,

Once you get terminal, run below command,

sudo dpkg --configure -a

here from man page of dpkg,

--configure package...|-a|--pending
              Configure a package which has been unpacked but not yet configured.  If -a or --pending is given instead of package, all unpacked but unconfigured packages are configured.

              To reconfigure a package which has already been configured, try the dpkg-reconfigure(8) command instead.

              Configuring consists of the following steps:

              1. Unpack the conffiles, and at the same time back up the old conffiles, so that they can be restored if something goes wrong.

              2. Run postinst script, if provided by the package.

logs as below,

Setting up linux-image-4.15.0-76-generic (4.15.0-76.86) ...
Processing triggers for initramfs-tools (0.130ubuntu3.9) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-74-generic
Processing triggers for linux-image-4.15.0-76-generic (4.15.0-76.86) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 4.15.0-76-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-76-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-76-generic
Found initrd image: /boot/initrd.img-4.15.0-76-generic
Found linux image: /boot/vmlinuz-4.15.0-74-generic
Found initrd image: /boot/initrd.img-4.15.0-74-generic
Found linux image: /boot/vmlinuz-4.15.0-72-generic
Found initrd image: /boot/initrd.img-4.15.0-72-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 on /dev/sda1
done

and voila, newer package that was downloaded but not configured is working.

| improve this answer | |
0

In addition to Tomeu's instructions, before chroot I needed to:

sudo mount --bind /dev /mnt/dev

Additionally, after the chroot:

cp -r /usr/lib/i386-linux-gnu/pango /usr/lib/

(Got this from here.)

| improve this answer | |
  • 1
    Tomeu already mentioned mounting /dev on /mnt/dev. – Lekensteyn Oct 16 '11 at 8:59
0

You can also boot the server in rescue mode, and reinstall only the grub

http://info.w3calculator.com/free-code/linux/recover-from-corrupted-boot-image/

| improve this answer | |
  • link was dead.. – John Joe Apr 24 '18 at 16:24
0

I got this problem due to my /boot partition was full so my kernel updates had failed. I managed to fix this by booting from an old kernel in the GRUB menu.

When managed to boot I began purging old kernels, but I had manage to get some dependency issues so first I had to uninstall linux-server package

apt-get remove linux-server
apt-get update
apt-get -f install
apt-get upgrade

Then I rebooted and everything was working fine!

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.