I’m currently running LEAP 15.1 on a SCSI disk and have recently purchased an SSD with different geometry. I plan to clone my /home partition and install LEAP 15.2 on the SSD. What is the best way to clone /home?
- cp
- rsynch
- tar
- E, none of the above
I’m currently running LEAP 15.1 on a SCSI disk and have recently purchased an SSD with different geometry. I plan to clone my /home partition and install LEAP 15.2 on the SSD. What is the best way to clone /home?
My normal practice is to use a tar pipeline
cd clone-directory
( cd /home && tar cf - ) | tar xpf -
I use rsync, both on local machine and on remote connections.
I install and mount new drive at some convenient point like /new
copy contents of /home to /new Note do not copy home just the contents. /home is the mount point for the files
In Yast remove old home partition from mounts mount and change /new to /home reboot then can check /ect/fstab to be sure all is right
Exact command to copy is not critical I use cp most time but dd and rsync etc are fine just need to copy files to new partition.
If links are involved be sure to use the parameters that preserve them.
Also be sure to use parameters the preserve file dates
Using cp, tar, rsync (all done by root and with the correct options to preseve ownership and permissions) are roughly equivalent. But dd is a complete different beast!
While those that work on the file level will create the new files in the new file sytem fresh as such, dd wil just write the bytes of the old container (partition probably) over the new container (also a partition probably) without any consideration. E.g. the file sytem on the new container, which probably has just created freshly, is overwritten with whatever file system there was on the old container. Only so many bytes as there are in the old container will fill the new one, which means that when the new one is larger, bytes will go unused and when the new one is smaller, the resulting file system weill be corrupt. Also the result will be two file systems with exactly the same UUID (maybe confusing when mounting by UUID is used) and the same is true for a LABEL (when used).
Thus except when you want what many people call a “clone”, do not use dd. Thus, repeating in other wording, not when the new file system should be be of a different type or size.or should exist together with the old one in the same system.
And all, when no user that has her/his home directory there is logged in!
Thus best with nobody login from the GUI (or even at run level 3) and a root login from the real console (when at runlevel 3 only the console is available, else use Ctrl-Alt-F1 to get there from the GUI login screen).
Run the command as root. Source partition activity is not a big deal:
erlangen:~ # time rsync -av --exclude .cache /home/ /home-HDD/backup/home/
sending incremental file list
karl/.mozilla/firefox/fixa83ds.default-1472189842958-1559074934539/webappsstore.sqlite
karl/.mozilla/firefox/fixa83ds.default-1472189842958-1559074934539/webappsstore.sqlite-wal
sent 51,339,756 bytes received 38,899 bytes 20,551,462.00 bytes/sec
total size is 256,233,337,319 speedup is 4,987.16
real 0m1.815s
user 0m0.792s
sys 0m1.018s
erlangen:~ #
Rerunning the command is incremental and thus really fast (size of /home is 248G). It shows the files affected.
Depends on the goal. When your goal is to have a new /home exeactly as the old one so you can switch by umount and mount to th new one, you better let not things change a millisecond after you copied something.
When your goal is to have a backup. doing it live is fine. And then, as Karl explains, you can repeat that without much penalty to keep your backup up to date.
Sure, the context matters. You may mount the source readonly or create a readonly snapshot, mount and mirror that one.
Yes, more precautions that one can take.
And I try to go on the safe side when giving advice so there is less chance that someone inexperienced will brake something.
Have used rsync for years for regular backups; so, when swapping from one physical device to another, I tidy everything up, do the backup, shut down, install the new physical device and restore. I have not had problems arising from doing it in a console from a GUI; I do nothing else while rsync is running.
I’d say “rsync -av /src /dst”: This is what I use for every copy command that requires reliability. “a” is for archive mode (recurse, keep permissions, save original dates, etc) while “v” is for verbose (makes it easier to keep track of exactly what’s being copied).
If you need maximum fidelity or this method doesn’t work for any reason, another way would be to clone the partition by booting into Clonezilla. Be careful with that as it can erase data or even an entire drive!
Self finds simple to use, is done frequently, for almost most every bundle
To copy and/or back up:
tar --preserve-permissions -zcvf Archive/20200409.tar.gz Documents
Extract Copy or Recover when needed:
tar -zxvf Archive/20200409.tar.gz
Copy to other machines:
scp -pr Archive/20200409.tar.gz username@hostname:/srv/OurArchive/
.
My goal was to get everything off of the disk drive and unto the (larger) SSD. I wound up using cp -a, more because it was less typing than any profound reason, and now my only issue is freeDOS; I believe that FAT16 doesn’t support 255 sectors/track and that my old FreeDOS doesn’t support FAT32. I’ve used it so little that I’m not sure it’s worth installing a new version.
At this point I have a usable LEAP 15.2 beta with the migrated /home and I’m ready to start tinkering. Thanks.