Ubuntu – Migrating the / volume

12.04migrationrsyncserver

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.

Best Answer

  • 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.

  • Related Question