Ubuntu – How to restore boot folder

10.04bootrmsudo

No laughing!

I just did sudo rm -vr /boot/*. Is there a way to restore the content?

Just to clarify why I would do this: I have a SD-card with a boot-partition mounted at /media/boot that I wanted to replace.

The computer is still running. What are my options?

Update (my solution): This might be a little unsatisfactory for future reference, but I simply backed up all my files and then reinstalled Ubuntu.

Important note if you have the same problem: Don't turn off your computer until you have everything backuped

Best Answer

You can restore /boot from a live CD using a chroot.

http://ubuntuforums.org/showpost.php?p=11893615&postcount=2

Assuming ubuntu is installed in /dev/sda1 ...

sudo mount /dev/sda1 /mnt
sudo cp /etc/resolv.conf /mnt/etc/

Depending on your configuration, you may also need to copy the hosts file

sudo cp /etc/hosts /mnt/etc/

mount /mnt/dev and chroot, configure the chroot

sudo mount --bind /dev/ /mnt/dev
sudo chroot /mnt /bin/bash
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

To avoid locale issues and in order to import GPG keys

export HOME=/root
export LC_ALL=C

Restore grub

grub-install /dev/sda

If that does not restore the grub files in /boot, reinstall grub first apt-get install --reinstall grub2 grub-install /dev/sda

Reinstall the kernel

apt-get install --reinstall linux-gnereic
Related Question