Grub - how to boot a copy of Linux (full system backup)

Hi All,

I have successfully backup & restore (using tar) one of my Debian Lenny Servers.

On the restore server (standby machine), everytime i have to erase the disk & extract the tar backup.

I want to extract the tar on the running restore server on a directory for e.g /systembackup-01, /systembackup-02, etc.. & be able to boot one of the backup using grub.

Thanks to help me on this.

coolAtt

  • have you heard about "mondo" ?

  • it's GPL disaster recovery solution.

--> Mondo Rescue - GPL disaster recovery solution

  • checki it out, and if possible, give it a try...

BTW in order for grub to boot from some partition, it must be able to find a "boot sector" (or "boot record") already there.

(in your case, you should at least use `dd' to save your boot sector, and restore it along with your 'tar' stuff..

ok ?

HTH

good luck, and success !

alexandre botao
("comets never dodge")

I think u didnt understand me.
Let me clarify.
I do FULL backup of my Debian Lenny 5 server (machine A) using tar.
The restore of tar backup is Ok..its working great on the spare machine (machine B).

/
 etc
 dev
 root
 bin
 etc...

Now on the above running system (the spare machine) i want to create a directory
named "SystemBackup02":

/
 etc
 dev
 root
 bin
 SystemBackup02
 etc...

Next time I want to

  1. untar the contents of my backup in the "SystemBackup02"
    directory.
    2.change ip in /SystemBackup02/etc/network/interfaces & modify other confs
    3.add an entry in grub, telling grub that it can also boot from this directory.

so the aim is to be able to boot from several versions of system backup

OK, first question - are you using GRUB Legacy or GRUB2? Second question - will SystemBackup02, etc, be on a separate partition or filesystem?

  1. Am using Debian Lenny 5 & its using GRUB Legacy.

  2. "SystemBackup02" will be on the same disk, created in / (root)

Its easy, a two step process.
You only need to edit grub.conf to add another boot option only for the vmlinux image you get into SystemBackup02/boot directory. Run 'install-grub /dev/<device holding SystemBackup02>'.

Hope both primary and backup machines have same architecture & device configurations!!!

A word of caution: It's a bit risky with little scope for mistakes; however don't assume that you are doomed on your mistake (until you delete your own data), if the backup system doesn't boot. You'll need to re-boot them again with a backup CD images and mount the drives temporarily and re-do the process correctly, BUT this time differently (mind that mounting may change paths). I've landed into mess and bounced back too but tensions run always high.

Do I need to absolutely reinstall Grub? (Its a bit scary for me even though its not a PROD Machine :slight_smile: )

Also note that the "SystemBackup02" is just another directory on the same disk /dev/sda.

Someone please help me..I take backup very seriously. :mad:

just to calm you down:

the command

grub-install

is part of the 'grub' package.

  • you can check it out with
man grub-install
  • and for the sake of correctness, "reinstall grub" refers to the 'grub package' as a whole, while "running grub-install" is just making good use of the same package.

please note that "running grub-install" is indeed a risky operation - specially if you do not plan ahead - and know - what you are doing.

HTH

good luck, and success!

alexandre botao
("comets never dodge")

When you edit grub.conf to add another boot option, you will have to re-build the stage-2 GRUB loader; which is why is a necessary step.

The GRUB stage-1 is just a 512 bytes system boot loader which is written at MBR (which is located in most PC based machine at track-0, sector-1 of their boot disk) and by the common disk architecture it can only be limited to 512 bytes (Till you actually get the newer 4KB sector disks).

GRUB stage-1 is what which actually let your machine to boot after POST (Power On Self Test done by BIOS) and subsequently loads the stage-2 which could be of different sizes (based on the total number of boot-menu displayed) and is actually responsible to rendered the boot menu options; Which you would need to create to get your new boot option menu displayed.

This needs to be built when you run 'grub-install'. This is specially true if you have GRUB version below GRUB-2 (under GRUB-2, there is a intermediate stage of stage1.5, loaded by stage-1, instead of stage-2 directly. Stahe-1.5 is basically enabler of basic file system reading capability to GRUB). Hence under GRUB-2 one can just modify the boot configuration and it reads the configuration to be rendered and displayed under stage -2 for you to boot your machine.

But there are issues:
1) If the disk file system is a custom one (i.e. not of common FS like UFS, ext2, ext3..4, reiserFS, etc.. or anything drives out of lineage) then the GRUB can't directly access the disk to access the boot.conf; hence won't give you the menu.

2) Incase, stage-1.5 is not present the still stage-2 gets loaded by stage-1 and in this case too the boot menu would not be rendered out of the latest configuration you saved into your grub.conf.

In both these cases (at least) you will have to perform the grub-install to create the grub images (both Stage-1 and Stage-2). It creates Stage-2 first and then the Stage-1 and inserts the starting sector number of the location of Stage-2 inside Stage-1 image. Hence Stage-1 can access and transfer control while boot strapping.

Hence in majority of the cases one should do the 'grub-install' except a few when your boot disk is formatted with most common Linux FS.

Hope that I answered your query.

1 Like

Ok..Great Theory on the Grub Thing.
please guide me on the technical part...thanks

If you really got this Theory you would know what to do.
Look at my previous post too & deduce inference and get your job done.

That's one way it is done. At least I do.

---------- Post updated at 09:01 PM ---------- Previous update was at 08:51 PM ----------

If you are taking tar archive of the '/' and on your backup machine; the kernel & H/w configuration is exactly same; then you may also try running 'chroot <systembackup_dir>' to mount the same as fake root. This is way safer (from your perspective) as nothing will change actually on your backup server system.