Skip to main content
Topic: To move a partition to another being prepared readily (Read 407 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

To move a partition to another being prepared readily

How do we move a fully partition to another, being prepared to adequately contain it, preferably by one by one commands / CLI?

Re: To move a partition to another being prepared readily

Reply #1
Code: [Select]
# mount /dev/sd?1 mnt1
# mount /dev/sd?2 mnt2
$ cd mnt2
# cp -a ../mnt1/* ./
Perhaps something like that? Use cp -a not -r to preserve file attributes, copy links etc. If it's intended to be bootable then you might need to chroot in and do some things like edit fstab, regenerate the initcpio's, and run update-grub. That is more than one command though, not sure if it could be done without mounting, possibly using dd I suppose, but cp does error checking on what it writes while dd doesn't which is why cp is recommended for that kind of operation.


Re: To move a partition to another being prepared readily

Reply #3
Don't try and copy the OS from itself while it's running, boot from an iso or another partition and mount it - but it's mostly very easy, you simply need to copy all the contents over like any directory tree then adjust the relevant settings to make the OS recognize it's now on a different partition. If you have space to do so, you don't need to delete the old partition immediately either, you can get the new copy running first.


Re: To move a partition to another being prepared readily

Reply #5
Definitely don't copy the OS from within itself while it's running, bad things are likely to happen. Files are constantly changing but the copy process is a linear one that takes quite a while to complete so the system could be saved in an inconsistent state. You would have to avoid recursively copying the mounted directories. There are also many special files in /dev, /proc and /sys and also tmpfs and possibly other partitions like /boot that shouldn't be copied. Strange bugs can be triggered that might cause unpredictable results and damage both the original and copy even if you think you have taken precautions. This is also true when making full system backups with rsync. You can safely copy or rsync unchanging files within your OS in normal everyday operations of course.

Re: To move a partition to another being prepared readily

Reply #6
I'd like to add that if the fstab is using UUID's the copied system will most likely not boot unless you edit that.

Your home directory can be copied just fine though as the system is running, probably just some sockets will issue a warning but will be okay.

There are backup schemes who can cherrypick only the modified system files you need and restore them upon a reinstall, but this depends on what exactly you need to achieve.