1

After a hardware failure of the motherboard and subsequently a few disks, I am migrating the root partition over to another drive. However, given /dev and other peculiar locations I was wondering whether my method is sound?:

rsync -avzPHAKXS /mnt/old/ /mnt/new/

Note that the new designated root drive is mounted as /mnt/new and the old one as /mnt/old.

Will this work or will it fail? I would find out later this week anyway simply by trying, but getting an authoritative answer and perhaps a working alternative would save me some hours.

0xC0000022L
  • 5,720

2 Answers2

2

Yes, the method you describe will work assuming neither disk is your current root/active partition (since they're both under /mnt/ it looks like you're OK.

Also, you're right that since md devices are involved, it's probably best not to dd the entire partition. That would also need you to grow the filesystem, a step that can be avoided using rsync which is perfectly safe in this case.

A few comments:

  • No need to worry about special filesystems like /dev, /proc, /sys, /run; since neither disk is your current root partition, these filesystems are not mounted (let's say they're not "live") and all they contain are files. Some of the file are "special" (maybe fifos or block/char special files) but these copy over OK.

  • No need for -z in your rsync line; since it's a local copy and I assume the hard disks are fast enough, it's faster if you avoid the compress/decompress overhead.

roadmr
  • 34,222
  • 9
  • 81
  • 93
  • Great, thanks for the detailed answer. Good point about the -z ... snuck in as cargo cult from my own Wiki I presume :) – 0xC0000022L Feb 13 '13 at 21:53
1

For copying whole partitions you should use dd. Unmount the partition you want to copy. You need to to know what your partitions are called. You can use GParted or sudo blkid for that. For an example lets assume your partition you want to copy is sdb1 and your target is sdc1. Then your dd command would be

sudo dd if=/dev/sdb1 of=/dev/sdc1

Be very careful with dd as the target partition specified with the of parameter is overwritten. Always make sure you got your partition names right. Also the partition names can change after reboot so don't rely on them after rebooting.

  • Well, I'm aware of dd but that creates another bigger problem. The source and target are "partition-less" MD devices and of different size. – 0xC0000022L Feb 13 '13 at 21:26
  • I'm not familiar with that. Isn't there a single device file or something similar for that which can be used as parameters for dd? – André Stannek Feb 13 '13 at 21:29
  • yes, the /dev/mdX could be used, I suppose but I'm somewhat afraid to shoot myself in the foot with that ... not to mention the different volume sizes. – 0xC0000022L Feb 13 '13 at 21:31
  • This somewhat sounds like a bad idea, yes. If your target volumes are still empty you got nothing to loose but if not I wouldn't risk it myself. At least not with my experience level. – André Stannek Feb 13 '13 at 21:38