Tuesday, January 06, 2009

How to recover from an accidental deletion of linux boot partition (Part 2 of 3)

Continuing from the previous post. Everything would have been up and running again if I had did exactly as said in the previous post. However, I did an extra step. As suggested in forums, to create a partition, I would first fdisk and then mkfs.ext3. So I went to type this instead. sda7 is the newly created partition. #fdisk /dev/sda n p 1 <enter> <enter> w #mkfs.ext3 /dev/sda7 #reboot Again the grub screen, with the kernel totally gone.

Recovery Process

Boot into Vista, install VirtualBox (VirtualPC didn't work. No USB support). All the steps below are done in VirtualBox. Create new virtual machine. Install Fedora 10. (Default installation) Boot into Fedora. swapoff -a, delete the swap partition and edit fstab. (this is to create a configuration that matches my Fedora installation on my hard disk before I deleted my boot partition) Insert thumb drive and capture it. Open Terminal. Switch to root (su). Copy everything in /boot into my thumb drive, which is mounted on /mnt/TOSHIBA Shut down Fedora. Exit out of VirtualBox. Shut down Vista. Boot into Fedora DVD. Go into Rescue Installed System. Select English, US keyboard, no network. To find which device is the thumb drive, type #blkid My system showed /dev/sdb1: LABEL="TOSHIBA" UUID=... Also, note down the UUID of the root partition, we will need it later. /dev/dm-0: UUID="<note down this long string>" TYPE="ext3" Mount the thumb drive as follows #mkdir /mnt/thumb #mount /dev/sdb1 /mnt/thumb Mount the boot partition #mkdir /mnt/boot #mount /dev/sda7 /mnt/boot Copy everything from the thumb drive to the boot partition. Next is to edit grub.conf #nano /mnt/boot/grub/grub.conf Change the timeout=0 to timeout=5 After hiddenmenu add the following to create the Windows Vista boot option.
title Windows Vista
    rootnoverify (hd0,1)
    chainloader +1
For the line beginning with kernel /vmlinuz, replace the UUID in the root=UUID=<replace this what you note down just now> To save, Ctrl+O To exit, Ctrl+X #reboot Fedora recovered!

No comments: