LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   backup and restore boot partition (https://www.linuxquestions.org/questions/programming-9/backup-and-restore-boot-partition-4175413609/)

ajayyadavmca 06-27-2012 03:52 AM

backup and restore boot partition
 
what is the best way to backup and restore boot partition.

using lvm snapshots is not right way as it doesnt deal with MBR.
tried using tar but cudnt make it successfull.

Please let me know if you have known any?
Thanks, Ajay

firstfire 06-27-2012 08:47 AM

Hi.

If you ask how to backup/restore MBR, then `dd' is your friend:

Backup:
Code:

dd if=/dev/sda of=mbr.bin bs=512 count=1
Restore:
Code:

dd if=mbr.bin of=/dev/sda bs=512 count=1
As mentioned here, `sfdisk' is another possibility.

ajayyadavmca 06-27-2012 10:45 PM

thanks
 
thanks for reply
sfdisk should not be used for partitions, its mainly for disks.

for dd it looks to be better option, but my problem was backing up whole partition(with MBR) not just the MBR.
please let me know if anybody has done it successfully.

syg00 06-27-2012 11:02 PM

The MBR is not part of any partition.

For LVM you would be better concentrating on maintaining a good backup of the LVM metadata - see "man vgcfgbackup".

kinneyd 06-28-2012 01:26 AM

You mention the /boot partition. I'm assuming boot is it's own filesystem and not in a logical volume. You just use tar to get this data. If you lost the system I assume you'll be rebuilding the partition table anyway. From a rescue disk you could 1) build the partition table, 2) restore /boot from the tar 3) rebuild the rest of the system from your snapshots, 4) do a chroot and re-run grub install to re-install the boot loader in the mbr. I've done this successfully a few times when moving a system to new hardware.

If you just want to preserve the mbr, I agree with fistfire.


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