Wolfgang wrote on 22 Sep 08: >Hi Randhir, > that is correct that you cannot boot if the MBR is gone or corrupt. But >in this case you need only a bootable medium e.g. LFS live CD/DVD and >then you can repair the MBR with dd command. >Another alternative is if you have a discete drive to write the MBR to a >discete with dd. >Wolfgang
Hi Wolfgang, That is very good. I have checked and seen that your first command does, in fact, copy the MBR on to the file: /boot/mbr_$TS. However, I am not very clear whether, it will copy the file back to MBR from within the 'Live LFS CD/DVD', without first chrooting into your linux installed on /dev/hda. I shall try it next time when I have a similar mishap. Have not understood "Another alternative is if you have a discete drive to write the MBR to a discete with dd." Do you mean a disket? Anyway thanks a lot for the responses. It is a pleasure to converse with you! Regards, Randhir >>>Introduction: >>>-------------- >>>In a multi-OS boot system, booting is done from MBR with Grub or such >>>boot-loader. In case the MBR is corrupted or over-written>>>because of any >>>reason, such as re-installing Windows, the booting through Grub can be >>>restored from MBR, without need to>>>re-install Linux. >>> >>>Steps: >>>------ >>>1. Download an LFS live DVD image from www.linuxfromscratch.org, and burn >>>the iso image onto a DVD. (This is a very handy tool>>>and, hence, should >>>always be available). If it is not with you presently, use your windows or >>>other installation to download and>>>burn. Boot from the live LFS DVD. >>>2. Type the command 'net-setup' and setup your internet and download or read >>>online the LFS Book. Open with lynx for reference,>>>if >>>needed. >>>3. Give the following commands in succession: (These commands are from the >>>LFS book - only selected here for the limited job>>>to be done) >>> export LFS=/mnt/lfs >>> mount -v -t ext3 /dev/ $LFS (where is the >>> partition on which your linux exists that you wish to>>>boot.) >>> /sbin/swapon -v /dev/ (where is >>> the swap partition on your hard disk.) >>> mount -v --bind /dev $LFS/dev (mounting >>> and populating /dev) >>> mount -vt devpts devpts $LFS/dev/pts (mounting >>> virtual kernel File System) >>> mount -vt tmpfs shm $LFS/dev/shm >>> mount -vt proc proc $LFS/proc >>> mount -vt sysfs sysfs $LFS/sys >>> chroot "$LFS" $LFS >>> (entering the chroot environment - this command will show root prompt >>> on>>>the >>> >>> partition that was mounted above. Check and ensure that it is >>> the>>>right one.) >>> /bin/bash --login +h >>> (shall bring the same prompt as above but with its environment) >>> >>>4. Installing Grub on to MBR: Give following commands: >>> >>> grub >>> (Note that grub does not recognize scaci drives etc. For it everything >>> is>>>'hd'. So >>> >>> if you have drive such as 'sda', for grub it shall remain as 'hd' >>> only) >>> root (hdx,z) >>> (Where 'x' is the number of the drive starting at zero and 'z' is >>> the>>>number of >>> >>> linux partition on that drive) >>> setup hdx >>> (If you had a working system before the mishap and you already had>>>the >>> >>> 'stage1' and 'stage2' in place, grub will show success.) >>>5. Unmount the various virtual kernel file systems mounted at Step 3 above >>>as also the $LFS partition and reboot the system. >>>6. The system should boot normally unless something else had also gone >>>wrong. The things can go wrong in that the splash>>>screen may not be the >>>same what you had earlier. For example, I boot from openSUSE and its splash >>>screen is different but what>>>I got after rebooting above was different and >>>after booting with that grub menu I got kernel panic at some stage of >>>booting. But>>>the grub shall be available and you could give it the >>>commands by pressing 'c' on your keyboard. Like earlier, give it the >>>following>>>commands, in succession: >>> >>> root (hdx,z) >>> kernel (hdx,z)/boot/vmlinuz (or whatever is the kernel name in your >>> boot partition) >>> initrd (hdx,z)/boot/initrd (or the specific name of your initrd >>> file in boot partition) >>> boot >>> >>>The system should boot. After booting the system you could carryout whatever >>>further correction you wish to do. For example in>>>my case, the X refused >>>to start. So I had to setup grub again here through 'YAST'. After that the >>>normal booting came up with its>>>normal splash etc. >>> >>>Conclusion: >>>------------- >>>If any such mishap ocurs, there is no need to panick. The good old LFS is >>>there for your rescue. Needless to say that there are a>>>number of other >>>means available for rescue. Personally, however, I find this simple. I have >>>used these steps a number of times,>>>mainly because of the need to >>>re-install windows Vista, which goes off pretty often, in my case. >>> >>>------------------------------------------------------------------------------------------------------------------------------------------------------------ >>> >>Date: Sat, 20 Sep 2008 18:00:30 +0200 >>From: Wolfgang Messingschlager >>Subject: Restoring grub on MBR >>To: LFS Support List >>Hi Randir, >> >> >>very interesting info. But if you install often or sometimes Windows I >>prefer to create the partitions on Linux and then save the MBR in a file >>with the dd command e.g. >> >>TS=`date +%Y%m%d` >>dd if=/dev/hda of=/boot/mbr_$TS bs=512 count=1 >> >>This can be done on a regular basis e.g. as a cron job. >> >>Then you can easily restore your MBR with dd as well e.g. >> >>dd if=/boot/mbr_... of=/dev/hda bs=512 count=1 >> >> >>Wolfgang >> >>------------------------------------------------------------------------------------------------------------------------------------------------------ >>Randhir Phagura wrote >>Hi Wolfgang, >>That is a smart one. It can, probably, be done from within a linux system >>after it boots. But once the MBR is gone, booting into linux>>is not possible. >>Regards, >>Randhir Phagura _________________________________________________________________ Searching for weekend getaways? Try Live.com http://www.live.com/?scope=video&form=MICOAL -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
