Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a CentOS 6 server with two hard drives in it. My old 3TB drive has been giving me some issues so I'm moving things over to a new drive. Because my / and /home partition are managed by a LVM it was easy to migrate those to the new drive. Now I want to move over my /boot partition and the MBR that makes it all start up.

I loaded up a live CD and rsynced over my /boot partition to the same size partition on my new drive. I also tried to copy over my MBR with the following commands:

dd if=/dev/sda of=mbrbackup bs=512 count=1
dd if=mbrbackup of=/dev/sdb bs=446 count=1

After doing this I rebooted, told my BIOS not to look at the old hard drive during the boot cycle and only look at the new drive but all I ended up with was a blinking cursor.

Did I miss a step here? Or is there something else I need to do to make things boot so I can completely remove my old drive?

EDIT: I'm starting to think rsync was not the way to copy the /boot partition from one drive to another. Based on this guide, I tried using the dump command instead. In this command I copied my old, unmounted boot partition to my new, empty, mounted boot partition.

dump -0f - /dev/sdaX | (cd /mnt/boot; restore -rf -) 

I'm getting a grub error 15 on boot which is better than a blinking cursor but I don't know if that is any closer to a solution.

share|improve this question
    
Why not grub-install on the new drive? –  frostschutz Feb 7 '13 at 1:15
    
Each time I tired running grub-install I ended up booting and getting only a grub prompt. –  Cloudkiller Feb 7 '13 at 13:58

3 Answers 3

up vote 2 down vote accepted

If the two hard-disks are of the same size (or the new one is bigger), why didn’t you just copy the old disk to the new disk? I.e.

dd if=/dev/sda of=/dev/sdb

Now, if the new hard-disk is bigger, change the partition sizes with parted or gparted. All this done booting from a live CD/USB-stick.

share|improve this answer
    
They are different size. 3tb was just overkill for the server so I moved down to a 1tb raptor hoping to get a bit more speed. Regardless, the cloning does not seem to be the problem. At least the LVM part moved easily and it appears the boot partition copied completely with my last dump. Now I think the problem is somehow related with my grub or the MBR. I think the problem is i don't know enough about grub2 and how it interacts with LVMs to fix it. –  Cloudkiller Feb 7 '13 at 13:18

It turns out that using rsync or dump to copy the /boot partition was causing the problem. Based on erick's answer above, I booted a live CD into rescue mode and ran the following dd commands.

dd if=/dev/sda of=mbrbackup bs=512 count=1
dd if=mbrbackup of=/dev/sdb bs=446 count=1
dd if=/dev/sda1 of=/dev/sdb1

I ran the first two dd's again just to make sure everything was copied correctly and not corrupted with all the testing I've been doing. Then I ran the third dd to copy the boot partition from my old drive to my new one. After that I shut down, pulled out my old drive and booted without issue into my CentOS.

There must have been some issue caused by using dump on a mounted drive that caused the copy to not work correctly. Regardless, dd did the trick. Thanks for your help everyone.

share|improve this answer

The problem is that you should not be using dd to copy the MBR like that. You simply need to reinstall grub on the new drive to get a correctly updated MBR. The MBR contains the location of the grub stage 2 file, which changed when you restored the dump.

Also you should upgrade to grub2 since grub legacy has not been maintained for years, and grub2 doesn't require a non lvm /boot partition.

share|improve this answer
    
I am using grub2, it is what the CentOS 6 installer put on my disk. In addition, the non lvm /boot partition was also the default setup provided by CentOS. I attempted to reinstall grub2 many times on the drive but getting it to work was something that eluded me. –  Cloudkiller Feb 7 '13 at 19:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.