Ubuntu – How to reinstall kernels after accidental deletion with a separate boot partition and an encrypted LVM volume

data-recoverykernellukslvm

My installation is a Ubuntu 12.04 64 bits (Classic "legacy" MBR – No EFI/UEFI here) with two partition :

  1. A separate boot partition
  2. An encrypted LUKS volume that contains the system Logical Volumes

I seems I accidentaly deleted all the current kernel files with:

sudo apt-get purge 'linux-image-3.8*' 

I applied the updates with Ubuntu Software Update, rebooted and then:
Ubuntu can't boot.

I tried to boot on a live DVD with a 14.04.1 Ubuntu and can still see my partitions (described later):

/dev/sda1 (boot)
/dev/sda2 (Encrypted volume)
/dev/sda5 (Logical Volume container)

What are the steps to recover/reinstall the kernel files and dependencies in order to cleanly reboot my installed system?

Thanks in advance

Best Answer

Test this:

Start the computer with a live-dvd / usb.

Open a terminal.

Run it:

sudo -i
apt-get update
apt-get install lvm2 cryptsetup
modprobe dm-crypt
cryptsetup luksOpen /dev/sda2 crypt1
*##Write the passphrase##*
vgscan --mknodes
*##Save the volume name##*
mount /dev/<volume-name>/root /mnt
mount /dev/sda1 /mnt/boot
mount --bind /dev /mnt/dev 
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
cp /etc/resolv.conf /mnt/etc/resolv.conf
chroot /mnt
apt-get update
apt-get install --reinstall 'linux-image-3.8*'
update-grub 
apt-get clean
umount /mnt
reboot