LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Backup GRUB (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-backup-grub-880787/)

danost 05-15-2011 12:44 AM

How to Backup GRUB
 
Looking for a GUI based tool to backup and restore GRUB to / from another hard drive, or CD, or USB stick. I have a few Linux distros on one hard drive.

Thank you
Dan

AwesomeMachine 05-15-2011 01:34 AM

I'm not aware of any tool like that. Usually, you just reinstall grub. There isn't much to it. You might back up the /boot/grub directory to external media. There could be some use to that.

tommcd 05-15-2011 03:29 AM

See this tutorial for how to reinstall grub2 to the master bot recordd (MBR) from the Ubuntu live CD:
https://help.ubuntu.com/community/Gr...ing%20GRUB%202
The first method there titled simplest should work just fine.
Read the entire tutorial to learn just about everything you would ever want to know about grub2.

danost 05-16-2011 02:15 AM

Thank you for this. My concern remains, what it seems that is referred to at the link your provided is for the boot info for a particular a particular Linux install. I have several installs on one hard drive, so I've set things such that the boot info is in the MBR of the hard drive, not in a particular Linux install. Thus I presume that backing up from inside a particular Linux install will not backup the MBR for all installs.
If you have any ideas on this, please do post again.
Thanks again
Dan

Larry Webb 05-16-2011 04:38 AM

When you install grub it should list all the distros, but may not in some cases. The best thing is to make a copy of your grub.cfg file.

catkin 05-16-2011 08:41 AM

Quote:

Originally Posted by danost (Post 4357555)
I have several installs on one hard drive, so I've set things such that the boot info is in the MBR of the hard drive, not in a particular Linux install.

Are you using GRUB or GRUB2? Assuming GRUB, there's a nice explanation here which describes how the MBR is only 446 bytes long so can do very little; it contains GRUB stage 1; when GRUB stage 1 is installed to the MBR it is configured with the block address of the file to load for the next stage of GRUB (stage 1.5 when the root file system is an "exotic" type, directly to stage 2 otherwise). This is why the usual advice is to "re-install GRUB".

A conventional arrangement is to have a single /boot file system for GRUB. It contains files the GRUB stages beyond 1 and the GRUB configuration, including "the boot info". For convenience the /boot file system can be mounted by all the installs, allowing you to read/modify it when they are running but it does not have to be this way -- just as long the file system used by GRUB is a "non-exotic" file system type (from GRUB's perspective).

The difficulty about backing up GRUB is that stage 1, in the MBR, needs to know the block address of the file for the next stage. If that file is restored by a file-level restore, it is unlikely to be put in the same place, that is at the same block address on the HDD.

In theory (not tested), one way to do this, assuming a separate /boot file system at the start of the drive, is a block level copy of the HDD from the beginning to the end of the /boot file file system using dd. Normally dd cannot be used to backup mounted file systems because they may be changing while they are copied and an inconsistent image would be recorded. In the case of the /boot file system this should (TM) not apply because it is only changed during kernel installs and GRUB customisation.

Such a block-level copy would also copy the partition table; if the partition table was changed between the copy and the restore then it would point to some wrong locations. In practice the chances of this happening could be mitigated (not eliminated!) by an automated backup run frequently or by sysadmin discipline to run the backup immediately after changing the partitions.

danost 05-18-2011 12:17 AM

This is a reply to "catkin". Many thanks for your well thought out reply. I do not know which version of GRUB I have, its what ever comes with Ubuntu 10.10. If this is GRUB2, then my question still remains on how to back up the complete GRUB, for the two distributions that I have on the one hard drive.

Thank you
Dan

tommcd 05-18-2011 12:48 AM

Ubuntu 10.10 uses grub2.
You may want to have a look at Super Grub2 Disk: http://www.bootproblems.com/super-grub2-disk/
This is a live CD that can detect and repair and reinstall grub2 for any operating system.


All times are GMT -5. The time now is 10:45 AM.