LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Backup Grub to USB Stick (https://www.linuxquestions.org/questions/linux-general-1/backup-grub-to-usb-stick-477009/)

Jongi 08-24-2006 01:15 PM

Backup Grub to USB Stick
 
I once backed up my grub/bootup to floppy. Is it possible to do the same but to a USB stick?

J_K9 08-24-2006 05:54 PM

Of course.

How did you install GRUB? If you installed it to your / partition or a separate /boot partition (ie. there's only one OS on the PC, and that is Linux), then all you need to do is copy the entire /boot directory to your USB stick.

If you installed GRUB to the MBR, simply run the following command in a terminal window to back it up to your USB stick (let's assume that it's mounted at /media/usbstick, and that the hard drive it's installed on is hda):
Code:

dd if=/dev/hda of=/media/usbstick/mbr-bkp bs=512 count=1
And then, if you want to restore it:
Code:

dd if=/media/usbstick/mbr-bkp of=/dev/hda bs=512 count=1
Simple as :)

HTH,

-jk

Jongi 08-25-2006 02:14 AM

And would I be able to boot of the USB stick provided my BIOS allows?

J_K9 08-25-2006 03:22 AM

Erm, no, I don't think so, because you're aren't putting the MBR copy into the first block of the USB stick, which is where the MBR would be read from.

What exactly are you trying to do? There may be better solutions ;)

Jongi 08-25-2006 06:36 AM

I'm trying to back up the grub to the usb stick so that if I mess up something with my fiddling i can boot of the usb stick.

I'm pretty sure when i backed up to floppy I was able to boot off it. I no longer have a floppy on my system so I figured maybe the usb stick could serve the same purpose.

EDIT: The main reason for all this is that i want to create a seperate /boot partition and i am pretty sure that things will not go smoothly the first time. So instead of whipping out the FC5 disk and booting in rescue mode, I thought it would be easier to boot from a USB stick seeing as I would not be looking to add the /boot partition at the back end of the existing partitions, ie none of the partitions referenced in files like fstab, menu.lst and grub.conf should change.

J_K9 08-25-2006 07:46 AM

In that case, you can just use the commands above - but, instead of booting from the USB stick, you could just repair the MBR by copying the backup to it... I don't think you would be able to use the "MBR" on the USB stick unless you copied it to the first block on the stick, but then you might corrupt some data on it (if there is any) :)

Jongi 08-25-2006 08:17 AM

EDIT: The answer to the question was in the 1st reply.

No need to worry about what's on the USB stick. I'd be prepared to lose any info. If it's not possible to boot of it then I guess replacing the MBR like that won't be too much of a hassle.

EDIT2: Though shouldn't making the USB stick bootable be the same as making an external USB HDD bootable?


All times are GMT -5. The time now is 02:08 AM.