LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Backing up MBR: Should I use 512 or 1024 or higher (https://www.linuxquestions.org/questions/linux-general-1/backing-up-mbr-should-i-use-512-or-1024-or-higher-4175452347/)

codergeek 03-01-2013 11:14 PM

Backing up MBR: Should I use 512 or 1024 or higher
 
Hi,

dd if=/dev/sda of=mbr.img bs=512 count=1

I know how to backup my MBR but I am unsure if 512 bytes still applies to today's large size hard drives. It's been eons since I done this so I am unsure if I should still use 512 bytes or higher.

Thanks

allend 03-02-2013 01:46 AM

Personally, I prefer to backup all of Track0 as bootloaders can place code there.
For a disk with 63 sectors/track and 512 bytes/sector
Code:

dd if=/dev/sda of=track0.img bs=512 count=63

syg00 03-02-2013 02:54 AM

And on the contrary, except when testing the effect(s) of deliberately introducing boot level virii, I have never seen any sense in backing up just the MBR - or immediately following sectors.

Use something like s[fg]disk to backup the partition structure; having backed-up the data separately of course.
For the boot code, simply boot from a liveCD, then chroot and reinstall the loader of choice.

Nothing gets "missed", no mistakes to make.
KISS.

H_TeXMeX_H 03-02-2013 03:22 AM

I know lilo backs up the MBR when first run, you can find it at '/boot/boot.0800', it is still 512 bytes.

I don't see any reason to back it up, because you can just re-install just as easily.

bloody 03-02-2013 03:25 AM

The MBR is still, as always, only 1 sectror of 512 bytes. The bootloader, however, does not fit into the few hundred bytes available within the MBR, so it takes about 29KB (GRUB2) additional space, usually in the follow-up sectors. You *may* backup the first 62 (or 63) sectors but you need to be careful, esp. when you restore this. Make dam sure that you do not write over the beginning of the first partition, like, for example, if the layout has changed meanwhile.

Running grub-install is much safer than such lowlevel stuff.

Backing up the first sector (512 bytes) is helpful because if you restore the MBR, sfdisk will know what kind of partition scheme it is dealing with when it's called to restore the (remaining) partition table. If you're not using an extended partition, you won't even need sfdisk because the (up to) 4 primary partitions are defined in the MBR itself.

syg00 03-02-2013 04:41 AM

gpt ?.

codergeek 03-02-2013 03:02 PM

Anyway, I will continue to use 512 byres as I done in the pass. I just though that a larger hard drive like one terabyte would use a higher number than 512 bytes for the MBR/partition area.

Thanks to all repliers for your feedback and assuring me that 512 bytes is still applied to today's larger hard drives.


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