Missing vmlinuz from /boot

I am running a laptop with Windows 7 and Ubuntu 12.04. I had grub issues following a partition resize which were eventually found to be problems due to missing kernel files. (These problems did not begin until a week after the resize, during which the computer continued to work perfectly).

By chrooting into my hard drive install from a 12.04 LTS LiveCD I was eventually able to restore /boot/initrd-3.2.0.24-generic.img. By copying vmlinuz from the LiveCD's /casper/ folder to /boot/vmlinuz-3.2.0.24-generic I found that update-grub would finally recognize and add my Ubuntu install to the grub menu, which was my initial problem.

However, my new problem is that when booting into this install I am met with all kinds of failed modules and error messages, often far too fast for me to even read or remember; finally I am given the option of starting Ubuntu in Low Graphics Mode, Troubleshooting, Command Prompt, Networking etc... Selecting Low Graphics Mode just dumps me out at the terminal prompting me to login, but my user name and password do not work.

Perhaps simply copying the vmlinuz from LiveCD has caused these errors? My problem is that an appropriate vmlinuz was not installed by the same kernel install process that restored my 'initrd-....'.img

I would really prefer not to have to reinstall the entire Ubuntu partition again as I had a lot of customized settings for various programming environments I use for my research work and I am currently abroad, limiting my bandwidth which is quite necessary to restore much of this software.

I do however have a complete image and a complete clone of the non-booting partition (both via CloneZilla); I just don't know if these actually acquired my private 'Home' folder, which claims to be unreadable when I mount the clone.


Solution 1:

Have you tried using apt-get to (re-)install the kernel?


Try booting the Live CD or USB which matches your Ubuntu install, then chroot, and then the command below.

apt-get -V install linux-generic linux-image-generic linux-headers-generic
  • Note: If the above does not work, you could also try either --reinstall or doing a remove of the above packages and then trying to install again.

If none of the above works, please update your question with details about how it failed.

The suggestion above is based on what apt-get did to upgrade the kernel of a clean install of Ubuntu 12.04 LTS 64-bit in a virtual machine. The packages which apt-get decided to install to update the kernel were linux-generic, linux-image-generic, and linux-headers-generic.

I have included below the output I got from running the apt-get command above in case it is of any possible use.

It appears to me that both vmlinuz-3.2.0-25-generic and initrd.img-3.2.0-25-generic were generated by running the update-initramfs script during installation post-processing. So I doubt that just copying the files from one installation to another would work unless the installations were identical (enough).

irrational@VB64Too:~$ sudo apt-get -V install linux-generic linux-image-generic linux-headers-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
   linux-headers-3.2.0-25 (3.2.0-25.40)
   linux-headers-3.2.0-25-generic (3.2.0-25.40)
   linux-image-3.2.0-25-generic (3.2.0-25.40)
Suggested packages:
   fdutils (5.5-20060227-5)
   linux-doc-3.2.0 ()
   linux-source-3.2.0 (3.2.0-25.40)
   linux-tools (3.2.0.25.27)
The following NEW packages will be installed:
   linux-headers-3.2.0-25 (3.2.0-25.40)
   linux-headers-3.2.0-25-generic (3.2.0-25.40)
   linux-image-3.2.0-25-generic (3.2.0-25.40)
The following packages will be upgraded:
   linux-generic (3.2.0.23.25 => 3.2.0.25.27)
   linux-headers-generic (3.2.0.23.25 => 3.2.0.25.27)
   linux-image-generic (3.2.0.23.25 => 3.2.0.25.27)
3 upgraded, 3 newly installed, 0 to remove and 247 not upgraded.
Need to get 50.6 MB of archives.
After this operation, 216 MB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-image-3.2.0-25-generic amd64 3.2.0-25.40 [38.2 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-generic amd64 3.2.0.25.27 [1,710 B]                          
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-image-generic amd64 3.2.0.25.27 [2,648 B]                    
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-headers-3.2.0-25 all 3.2.0-25.40 [11.4 MB]                   
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-headers-3.2.0-25-generic amd64 3.2.0-25.40 [958 kB]          
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-headers-generic amd64 3.2.0.25.27 [2,644 B]                  
Fetched 50.6 MB in 36s (1,398 kB/s)                                                                                                
Selecting previously unselected package linux-image-3.2.0-25-generic.
(Reading database ... 141202 files and directories currently installed.)
Unpacking linux-image-3.2.0-25-generic (from .../linux-image-3.2.0-25-generic_3.2.0-25.40_amd64.deb) ...
Done.
Preparing to replace linux-generic 3.2.0.23.25 (using .../linux-generic_3.2.0.25.27_amd64.deb) ...
Unpacking replacement linux-generic ...
Preparing to replace linux-image-generic 3.2.0.23.25 (using .../linux-image-generic_3.2.0.25.27_amd64.deb) ...
Unpacking replacement linux-image-generic ...
Selecting previously unselected package linux-headers-3.2.0-25.
Unpacking linux-headers-3.2.0-25 (from .../linux-headers-3.2.0-25_3.2.0-25.40_all.deb) ...
Selecting previously unselected package linux-headers-3.2.0-25-generic.
Unpacking linux-headers-3.2.0-25-generic (from .../linux-headers-3.2.0-25-generic_3.2.0-25.40_amd64.deb) ...
Preparing to replace linux-headers-generic 3.2.0.23.25 (using .../linux-headers-generic_3.2.0.25.27_amd64.deb) ...
Unpacking replacement linux-headers-generic ...
Setting up linux-image-3.2.0-25-generic (3.2.0-25.40) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-25-generic /boot/vmlinuz-3.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-25-generic /boot/vmlinuz-3.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-25-generic /boot/vmlinuz-3.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-25-generic /boot/vmlinuz-3.2.0-25-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-25-generic
Found initrd image: /boot/initrd.img-3.2.0-25-generic
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done
Setting up linux-image-generic (3.2.0.25.27) ...
Setting up linux-generic (3.2.0.25.27) ...
Setting up linux-headers-3.2.0-25 (3.2.0-25.40) ...
Setting up linux-headers-3.2.0-25-generic (3.2.0-25.40) ...
Setting up linux-headers-generic (3.2.0.25.27) ...
irrational@VB64Too:~$

Solution 2:

By chrooting into my hard drive install from a 12.04 LTS LiveCD I was eventually able to restore /boot/initrd-3.2.0.24-generic.img. By copying vmlinuz from the LiveCD's /casper/ folder to /boot/vmlinuz-3.2.0.24-generic I found that update-grub would finally recognize and add my Ubuntu install to the grub menu, which was my initial problem.

However, my new problem is that when booting into this install I am met with all kinds of failed modules and error messages…

I would have initially suggested to same thing but had to find a better answer than copying files from live media or just installing linux-image-generic in chroot.

My suggestion is to look into /lib/modules/ of your installation and pick the latest kernel version number you can find, then install the corresponding kernel image in chroot. To generate initrd if it wasn't created automatically you have to run mkinitramfs which would otherwise have been called by update-initramfs, but may refuse to work from live media.

I posted complete instructions here: How to restore deleted files in /boot? (vmlinuz missing, system does not boot)