randhir phagura wrote: > Howto: Re-establishing boot > process from MBR > > ================================== > > Introduction: > -------------- > In a multi-OS boot system, booting is done from MBR with Grub or such a > 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 'hd0' 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, also starting with zero.) > 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. > > Thought this may be of some use to the community. > > Regards > > Randhir Phagura > _________________________________________________________________ > Search for videos of Bollywood, Hollywood, Mollywood and every other wood, > only on Live.com > http://www.live.com/?scope=video&form=MICOAL
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 -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
