LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   help restoring MBR on cloned disk having Grub boot loader (https://www.linuxquestions.org/questions/general-10/help-restoring-mbr-on-cloned-disk-having-grub-boot-loader-4175499720/)

ron7000 03-27-2014 05:03 PM

help restoring MBR on cloned disk having Grub boot loader
 
I'm trying to clone linux disks but run into a MBR problem.
what i have is a tar file of a working linux os, SLES 11 with Grub boot loader.
on a separate working system, i slave and mount a new hard drive as /dev/sdb.
i format /dev/sdb1 as swap 1 gb in size.
i format /dev/sdb2 as ext3 rest of hard drive, and mount as /newdisk.
cd /newdisk
tar -xf /root/linuxsystem.tar
unmount /newdisk.

now when i take this newly created disk and plug it into a new computer, i get missing boot device. so i put my SLES install disk in cd drive and boot with that and choose repair system, it sees a bad MBR and i can tell it to fix it. then i can boot this new disk no problem and it works fine.

so i'm reading online about saving and restoring the MBR.
I'd like to do this a quicker way then having to boot from the SLES install cd which is time consuming.
they say all i need to do from my working disk when i initially create that linuxsystem.tar file- if that disk were /dev/sdc on the system then i should do
dd if=/dev/sdc of=/root/saved_mbr count=1.

then after my "tar -xf /root/linuxsystem.tar" above I should do
dd if=/root/saved_mbr of=/dev/sdb count=1.

I've tried that, and it saved 512 bytes or blocks worth when doing the dd but it did not work. how do i get that to work ?
when i remounted this cloned disk to my working system to start over, it also said partition table messed up was not gpt, so i had to redo that even.

syg00 03-27-2014 05:15 PM

Cloning the MBR was always a bad idea - these days with gpt disk possibly in the mix, it's even more so.
Your cloning of filesystem up to that point is good - and safe. Keep it that way by repairing the bootloader properly, as you did from the boot CD.

Much better option IMHO.

ron7000 03-27-2014 05:24 PM

not what i wanted to hear :(

what does the install cd actually do during the MBR repair?
I'd like to be able to do that manually when i clone the disk to save time.

enorbet 03-27-2014 09:21 PM

It is my understanding that MBR and GPT are "oil and water". You need to use tools especially for UEFI implementation of GPT afaik. Also basic Grub cannot be used. You must use Grub2-efi or eLilo.

sundialsvcs 03-27-2014 10:23 PM

I, too, would not attempt to "clone" the MBR. Instead, you should be able to format and then partition the disk, load each of the partitions with data, and then do a grub-install to write the necessary boot information into all the right places. The MBR, partition table and so-forth are very architectural things. I would not advise trying to "copy and restore" them.

ron7000 03-28-2014 11:47 AM

ok, i'll stick with booting from cd and performing the repair.

thanks.


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