I had three primary partitions on my hard-drive:

  1. Win7 NTFS (300G)
  2. linux /  (600G)
  3. linux swap (30G)

As I needed more space on Win7 I deleted the second partition inside windows and grow the NTFS to incorporate the free space. Worked fine until the next reboot. This what I saw then:

grub rescue

grub rescue

The partition layout was changed, so that the former swap partition was reused as linux partition:

  1. Win7 NTFS (900G)
  2. linux / (30G)

My disk are organized in a raid 1 mirroring set, so it is not really /dev/sdaX, (see next picture). The linux on this dual boot machine is only for emergency rescue stuff, so I easily can reinstall it, without loosing content. When installing the Ubuntu 10.04 LTS I also node down the name of the raid set names, which play a vital part in the restoration of the grub boot loader.

Raidset overview

Raidset overview

Finished the ubuntu linux install.

Ubuntu 10.04 reinstall

Ubuntu 10.04 reinstall

Starting the grub rescue. If you ever see this

error: no such device: gksdfksdklhsdkhjsdkkdh
grub rescue>

DON’T PANIC! – grub is confused about the latest changes to you partitioning and his knowledge about the system setup, but it usually does know still some things. And here is how to proceed.

grub rescue set

grub rescue set

Enter the following to see the what grub still knows.

grub rescue> set
prefix=(hd0,2)/boot/grub
root=hd0,2
grub rescue>

It knows that there should be a linux on the second partition of the first hard-drive. But the disk UUID has changed and therefore it bailed out. So now we need to load the normal grub mode:

grub rescue insmod normal

grub rescue insmod normal

grub rescue> insmod normal
grub rescue> set
color_highlight=
color_normal=
pager=
prefix=(hd0,2)/boot/grub
root=hd0,2
grub rescue>

Worked! We have more commands to our grub now. Let’s see what we have in /boot and we proceed in loading linux kernel

grub rescue insmod linux + linux kernel load

grub rescue insmod linux + linux kernel load

grub rescue> ls /boot
./ ../ grub/ System.map-2.6.32-21-generic abi-2.6.32-21-generic config-2.6.32-21-generic memtest86+.bin vmcoreinfo-2.6.32-21-generic vmlinuz-2.6.32-21-generic initrd.img-2.6.32-21-generic
grub rescue> insmod linux
grub rescue> linux /boot/vmlinuz-2.6.32-21-generic root=/dev/mapper/isw_baafeifjp_Klawiklack2
grub rescue>

So we have told grub which kernel to boot, and where the root fs is located. We need to tell grub about the initrd.

grub rescue initrd settings

grub rescue initrd settings

grub rescue> initrd /boot/initrd.img-2.6.32-21-generic
grub rescue> boot

And now the linux does boot! Inside the linux we need to run the following command to correct the grub settings.

linux booting

linux booting

root@klawiklack# dpkg-reconfigure grub-pc

And finally we see the grub boot loader screen again

grub normal again

grub normal again

Don’t forget that Windows does a lengthy fsck too.

Windows repaired fs

Windows repaired fs

Have fun.