[kwlug-disc] SOLVED: Re: mbr / grub2 hosed - easiest fix? (Was Re: Adding (setting up) 2nd disk.)

unsolicited unsolicited at swiz.ca
Wed Jan 27 03:02:49 EST 2010


THANK YOU COLIN, YOU LEAD ME TO THE SOLUTION. Below.

For: Re: [kwlug-disc] Adding (setting up) 2nd disk.
Colin Mackay wrote, On 01/26/2010 3:28 PM:
 > Tue, you mount filesystems, my apologies.  But apparently, you can
 > mount a folder into another folder as well with "mount --bind /dir1
 > /dir2"
 >
 > Found another link to explain it better:
 > http://aplawrence.com/Linux/mount_bind.html
.
.
.

Has a first comment of:
<<<<<
I use mount to bind directories when using a Knoppix cdrom to recover 
from mucked up linux bootloaders or resetting root passwords and whatnot.

Assuming that /dev/hda1 is your OS's on your harddrive's main partition...

Boot up with knoppix.
mount /mnt/hda1
(should set that up automaticly, could be in /media though)
cd /mnt/hda1
mount -t proc proc ./proc
mount -t sysfs sys ./sys
mount -o bind /KNOPPIX/dev ./dev
(or is that /mnt/KNOPPIX/dev? I forget, been a while)
chroot ./ su -

Or something similar to that. Should end up having full access to the 
hardware from inside the chroot environment for setting up grub or 
whatnot.

I also use that in conjunction with debootstrap for installing Debian 
on machines for for whatever reason have issues with the installer 
cdrom (such as only have knoppix disk handy, or normal installer cdrom 
doesn't have drivers for the network or ide controller.
 >>>>>

Which led me to google search terms of: "mount -t proc proc ./proc" 
"mount -o bind" grub2, and a hit to: 
http://blog.purecodes.org/index.php/2009/07/11/fixing-your-grub-if-your-system-is-not-bootable/, 
where you get:
<<<<<
You can fix the grub installation again using any kind of live CD. I 
used the Knoppix CD.

     * Boot the live CD
     * Mount your boot partition, for example to /mnt. In my case

       mount -t auto /dev/sda1 /mnt

     * Bind your /dev directory to the mounted partition:

       mount -o bind /dev/ /mnt/dev

     * Chroot into your boot partition

       chroot /mnt

     * Mount your proc directory

       mount -t proc proc /proc

     * Mount your sys file system (/sys)

       mount -t sysfs sysfs /sys

     * Ready, now you can use your system almost as if you booted in 
it. You can reinstall grub, kernel images, create initrd images, fix 
the menu.lst or grub.cfg or whatever you want.
 >>>>>

For a final solution of:

mount -t auto /dev/sda3 /mnt

# crucial missed step in prior try.

mount -o bind /dev/ /mnt/dev

# because now the bind has kept the real hardware as accessible, post 
chroot, for grub to examine and discover.

chroot /mnt
mount -t proc proc /proc	# as John alluded to earlier.
mount -t sysfs sysfs /sys
grub-install /dev/sda

# might have used update-grub, I forget.


Reboot, and voila. Prior grub menu, with customizations from 
/etc/default/grub in place.


Now on to fixing the cause of this mess, corrupted partition table 
from http://www.ext2fsd.com/.

I've had rather good success with http://www.fs-driver.org/, but this 
fails in Vista/Win 7 - the service won't start due to user account 
controls. I did have to give up on it when beating on it quite hard 
during backups, but most of the time it has been great. Under XP, 
anyways. Large files under Windows, without ntfs, and Linux accessible.

Found ext2fsd in discovering the above. Service works under UAC. It 
has a nifty user control interface that includes the ability to change 
partition table entries. Shrinking the windows partition, adding 
others in prep. for kubuntu, and all sorts of nonsense with the EFI 
boot booster partition and hidden fat32 recovery partition being moved 
into an extended volume lead to ...

Amazing aggravation.

Thank you all, and especially to Colin.




More information about the kwlug-disc mailing list