Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

时间:2024-03-18 18:46:09

转自:https://thomasmodeneis.wordpress.com/2017/05/12/how-to-restore-ubuntu-16-04-kernel-panic-not-syncing-vfs-unable-to-mount-root-fs-on-unknown-block00/

How to restore Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

Today one of the guys on my development team ran into an old problem on Linux, the good and old Kernel panic …  This time it was after updating Ubuntu 16.04 internals.

After doing the reboot, there it was, the old good linux scaring n00bies away:

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

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

This is an old problem and usually, depending on the tooling you have around it, it can be quite time-consuming to figure a way out if you are not experienced on Linux.

The problem originated because he installed updates on Ubuntu, one after another during many months of usage, until a day … nothing special, he updated once again and boom!!! The updates caused the /boot partition to be left with no space, and this caused the grub to be blocked when trying to mount the root fs. The solution is simple: just to remove the old kernel images and run a quick cleanup.

I believe if a piece of software or program is not clear enough for an average person to understand and solve, than its broken and it should be properly fixed or at least documented until it can be fixed permanently.

 

[SOLVED] kernel panic-not syncing:

Start your Ubuntu with shift pressed until you see the recover screen, choose recovery mode:

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

Cleaning up Boot partition on Ubuntu 16.04

When on Rescue Mode, select the option clean followed by dpkg, grub and fsck.

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

This will make sure that the space on your boot partition is free, will repair any broken packages, check all file systems and that they are correct and update your grub bootloader.

After this, you are very likely to get a stable Ubuntu 16.04 back.

 

 

The command line way to clean up /boot partition:

 

It can be that you open your computer, and it will boot normally, but Ubuntu will complain that the boot partition is almost full, in this case you can execute the auto-remove:

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

 

$ sudo apt-get autoremove --purge
[sudo] password for ninja: 
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages will be REMOVED:
 linux-headers-4.4.0-79 linux-headers-4.4.0-79-generic linux-headers-4.4.0-81
 linux-headers-4.4.0-81-generic linux-headers-4.8.0-49
 linux-headers-4.8.0-49-generic linux-headers-4.8.0-51
 linux-headers-4.8.0-51-generic linux-headers-4.8.0-52
 linux-headers-4.8.0-52-generic linux-headers-4.8.0-54
 linux-headers-4.8.0-54-generic linux-image-4.4.0-79-generic
 linux-image-4.4.0-81-generic linux-image-4.8.0-49-generic
 linux-image-4.8.0-51-generic linux-image-4.8.0-52-generic
 linux-image-4.8.0-54-generic linux-image-extra-4.4.0-79-generic
 linux-image-extra-4.4.0-81-generic linux-image-extra-4.8.0-49-generic
 linux-image-extra-4.8.0-51-generic linux-image-extra-4.8.0-52-generic
 linux-image-extra-4.8.0-54-generic
0 upgraded, 0 newly installed, 24 to remove and 93 not upgraded.
9 not fully installed or removed.
After this operation, 1854 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 497711 files and directories currently installed.)
Removing linux-headers-4.4.0-79-generic (4.4.0-79.100) ...
Removing linux-headers-4.4.0-79 (4.4.0-79.100) ...
Removing linux-headers-4.4.0-81-generic (4.4.0-81.104) ...
Removing linux-headers-4.4.0-81 (4.4.0-81.104) ...
Removing linux-headers-4.8.0-49-generic (4.8.0-49.52~16.04.1) ...
Removing linux-headers-4.8.0-49 (4.8.0-49.52~16.04.1) ...
Removing linux-headers-4.8.0-51-generic (4.8.0-51.54~16.04.1) ...
Removing linux-headers-4.8.0-51 (4.8.0-51.54~16.04.1) ...
Removing linux-headers-4.8.0-52-generic (4.8.0-52.55~16.04.1) ...
Removing linux-headers-4.8.0-52 (4.8.0-52.55~16.04.1) ...
Removing linux-headers-4.8.0-54-generic (4.8.0-54.57~16.04.1) ...
Removing linux-headers-4.8.0-54 (4.8.0-54.57~16.04.1) ...
Removing linux-image-extra-4.4.0-79-generic (4.4.0-79.100) ...
(...)
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.8.0-58-generic
Found initrd image: /boot/initrd.img-4.8.0-58-generic
Found linux image: /boot/vmlinuz-4.8.0-56-generic
Found initrd image: /boot/initrd.img-4.8.0-56-generic
Found linux image: /boot/vmlinuz-4.4.0-83-generic
Found initrd image: /boot/initrd.img-4.4.0-83-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done
Setting up linux-image-generic-hwe-16.04 (4.8.0.58.29) ...
Setting up linux-generic-hwe-16.04 (4.8.0.58.29) ...
Setting up linux-image-extra-virtual (4.4.0.83.89) ...
[email protected]:~$ sudo apt-get autoremove --purge
Reading package lists... Done
Building dependency tree 
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 93 not upgraded.

 

Then finally you can update GRUB kernel list:

$ sudo update-grub
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.8.0-58-generic
Found initrd image: /boot/initrd.img-4.8.0-58-generic
Found linux image: /boot/vmlinuz-4.8.0-56-generic
Found initrd image: /boot/initrd.img-4.8.0-56-generic
Found linux image: /boot/vmlinuz-4.4.0-83-generic
Found initrd image: /boot/initrd.img-4.4.0-83-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done

 

 

Check the partition sizes with ncdu:

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

If you dont have it, then install with:

$ sudo apt-get install ncdu

Alternatively you can:

check the partition sizes with lsblk:

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 88,1M 1 loop /snap/conjure-up/518
loop4 7:4 0 79,5M 1 loop /snap/core/2312
loop2 7:2 0 88,1M 1 loop /snap/conjure-up/527
loop0 7:0 0 79,5M 0 loop /snap/core/1689
nvme0n1 259:0 0 477G 0 disk 
├─nvme0n1p5 259:3 0 476,5G 0 part 
│ └─nvme0n1p5_crypt 253:0 0 476,5G 0 crypt 
│ ├─ubuntu--vg-root 253:1 0 460,9G 0 lvm /
│ └─ubuntu--vg-swap_1 253:2 0 15,6G 0 lvm 
│ └─cryptswap1 253:3 0 15,6G 0 crypt [SWAP]
├─nvme0n1p1 259:1 0 487M 0 part /boot
└─nvme0n1p2 259:2 0 1K 0 part 
loop5 7:5 0 78,4M 0 loop /snap/core/1577
loop3 7:3 0 88,2M 1 loop /snap/conjure-up/510

 

Or you can also:

Check the partition sizes with baobab:

$ sudo baobab

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

 

Now just restart the Ubuntu and it should be as good as before! 

 

Ubuntu 16.04 “Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)”

Happy Open Source coding to everyone.

Advertisements