LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2007, 01:43 AM   #1
styles24
LQ Newbie
 
Registered: Feb 2007
Location: Michigan
Distribution: Fedora 6
Posts: 5

Rep: Reputation: 0
How can i backup and install GRUB


I am fairly new to Linux. Im currently taking classes for Linux and have searched for this and cant find it.

I have XP installed on /dev/hdc1 and Fedora 6 on /dev/sda1. I installed grub to the XP partition, but my XP is acting up so i want to reinstall it. Problem is that grub is installed on this drive and i know that reinstalling windows would override the bootloader to get into Linux. I want to know step by step how to backup and reinstall grub to /dev/hdc1 after i have reinstalled XP. The instructions and answers im looking for are prolly right under my nose, but my nose cant see anything at the moment. Im sorry if this has been answered somewhere else, but i cant find it. Any help would be appreciated.

Jesse
 
Old 03-27-2007, 02:00 AM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
To save the MBR, which is what I think you want, you do the following:
Code:
dd if=/dev/hdc of=MBR.image bs=446 count=1
To restore it, boot a liveCD and run:
Code:
dd if=MBR.image of=/dev/hdc bs=446 count=1
The MBR is the master boot record that searches for the grub components on your disk at boot time.
 
Old 03-27-2007, 02:16 AM   #3
styles24
LQ Newbie
 
Registered: Feb 2007
Location: Michigan
Distribution: Fedora 6
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you for your quick reply. Will this also work if XP and Fedora are installed on the same drive on my laptop and i want to do the same, just insert the correct partitions?

And can i just use a regular fc6 install disk or do i need to download a fc6 live cd? Thank you again.
 
Old 03-27-2007, 07:42 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by styles24
Thank you for your quick reply. Will this also work if XP and Fedora are installed on the same drive on my laptop and i want to do the same, just insert the correct partitions?

And can i just use a regular fc6 install disk or do i need to download a fc6 live cd? Thank you again.
Copying and restoring the mbr is independent of what is on the drive. By definition, the mbr is on the 1st sector of the drive which the BIOS sees as #1.

Don't understand the question about the Fedora disk...You can do the dd thing from any Linux--eg what is already installed, live CD, etc.

Final nit: When you are talking about the mbr, there are no partitions involved.
 
Old 03-27-2007, 10:13 PM   #5
styles24
LQ Newbie
 
Registered: Feb 2007
Location: Michigan
Distribution: Fedora 6
Posts: 5

Original Poster
Rep: Reputation: 0
Quakeboy02 and pixellany, thank you very much for your help.
 
Old 03-27-2007, 11:53 PM   #6
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
If you want to put it in a specific place, like your home directory, the command should include that directory:

dd if=/dev/hdc of=/home/<user>/MBR.img bs=512 count=1

Last edited by Junior Hacker; 03-27-2007 at 11:58 PM.
 
Old 03-28-2007, 12:06 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might want to read the Wikipedia article on the MBR:
http://en.wikipedia.org/wiki/Master_boot_record

Notice that Quakeboy02 used the first 446 bytes. Some howto's use 512 bytes. The first 446 bytes contain just the bootstrap loader code. So you would be backing up part of the MBR and not the entire MBR.

If XP uses the NTFS filesystem and you don't have NTFS write support in Linux, then you may want to copy the MBR backup image to a usb device instead and copy it to C:/ (/dev/hdc) when using XP before reinstalling.
 
Old 03-28-2007, 12:31 AM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
jschiwal,

I'm glad you made me look that up. I had though that the first 446 bytes contained only the boot code. But, apparently, it's even more complicated than that. But, if you backup the whole sector (512 bytes) be aware that that MBR is not transferable to any other disk, as it contains the partition table.

For more info: http://en.wikipedia.org/wiki/Partition_table
 
Old 03-28-2007, 01:00 AM   #9
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
The thread starter did not mention using another disc, only backup the MBR to put it back after re-building Windows.
 
Old 03-28-2007, 01:11 AM   #10
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
I do welcome any "constructive criticism" here, but if I remember correctly, there are some "reserved" bytes in the MBR, which is probably why Awesome uses 446 excluding the reserved bytes, which contain nothing.
 
Old 03-28-2007, 02:57 AM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The partition table starts above 466. The entire MBR is 512 bytes long. The Wikipedia article has a table showing this.

If you really want to feel nerdy:
dd if=/dev/hdc of=MBR.image bs=446 count=1
objdump -D -b binary -mi386 -Maddr16,data16 MBR.image
 
Old 03-28-2007, 03:09 AM   #12
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
A quick look at that spells "fat 16 floppy"
 
Old 03-28-2007, 12:40 PM   #13
wpn146
Member
 
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
Windows XP "assumes" it is the only operating system in existence in the Galaxy and can wipe your dual boot mbr.

I have found "Smart Boot Manager" to be useful to have around (Google for it). If Windows XP wipes your mbr on /dev/hdc1 the "Smart Boot Manager" should let you boot to Fedora 6 on /dev/sda1. Once booted, you should be able to reinstall grub as a dual boot system with:
Code:
grub-install /dev/sda
On the other hand, if you wish Windows XP to "fix" what Windows XP considers a corrupt mbr:
Code:
1.  Boot from the Windows XP cdrom.  
2.  Run the "fixmbr" command.
 
Old 03-28-2007, 11:17 PM   #14
styles24
LQ Newbie
 
Registered: Feb 2007
Location: Michigan
Distribution: Fedora 6
Posts: 5

Original Poster
Rep: Reputation: 0
Ok, just so im understanding right. If i reinstall windows on /dev/hdc, i can install "smart boot manager" and then boot to Fedora 6 on /dev/sda1. From there i install grub to /dev/sda, and if i wanted, instead install grub to /dev/hdc since i want it to boot from the first hard drive. I dont mean to be a PITA, i just got alot of conflicting info and want to get it right.
 
Old 03-29-2007, 09:21 AM   #15
wpn146
Member
 
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
Quote:
Originally Posted by styles24
Ok, just so im understanding right. If i reinstall windows on /dev/hdc, i can install "smart boot manager" and then boot to Fedora 6 on /dev/sda1. From there i install grub to /dev/sda, and if i wanted, instead install grub to /dev/hdc since i want it to boot from the first hard drive. I dont mean to be a PITA, i just got alot of conflicting info and want to get it right.
"Smart Boot Manager" fits on a 3.5" floppy and is operating system independent. I find it useful just to have around. It allows you to boot from devices that otherwise not be bootable. If you have an internal 3.5" drive that can be selected as the boot device in the BIOS, you boot from the floppy and it allows you to boot from its menu, effectively bypassing a bad or unbootable mbr.

Last edited by wpn146; 03-29-2007 at 09:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
Backup Grub to USB Stick Jongi Linux - General 6 08-25-2006 08:17 AM
Load dd backup of MBR via GRUB Computer Guru Linux - Software 1 06-16-2006 05:37 AM
grub floppy backup and restoration chocloman Linux - Software 3 02-02-2006 03:06 PM
How to Backup Grub mayagenesis Linux - Software 1 08-30-2003 12:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration