How to "clone" /home/<user> directory to new SSD partition *without* other /home/<directory>

I have a backup box with a single 1TB HDD, with 4 partitions:

<user>@backup:~> lsblk
sda      8:0    0 931,5G  0 disk 
├─sda1   8:1    0   199M  0 part /boot/efi
├─sda2   8:2    0  16,8G  0 part /
├─sda3   8:3    0 910,5G  0 part /home
└─sda4   8:4    0     4G  0 part [SWAP]

Directory sizes are:

backup:/home # du -sh */
692G    Backup/
16G     <user>/
16K     lost+found/
backup:/home # 

I want to clone /root and /home to a 120G SSD but keep the Backup/ folder and files in the HDD and mount it as /home/Backup in the new home partition on the ssd.

Cloning sda1 and sda2 to SSD is trivial, but I can’t clone only part of sd3. I don’t want to copy the 610,5G elsewhere as this would change the time stamps/whatever, and syncthing would need to resync everything again, which takes a long time in this very slow dual-core intel CPU (J1800).

I think the best way obviously would be to create a new empty sda3 /home partition is the SSD and make a full copy of the original /home/ folder, including all hidden and other special files, if any (fifo, links, etc.).

If this is doable, how should I proceed? Is there a backup utility that does this, not leaving anything behind, for specified directories/folders?

I intend to do this from a live utility distro like partition magic, including the /home/user copy and creation of the mount directory under the new /home and adjusting the cloned /etc/fstab before starting the box and re-enabling syncthing.


Could it be as simple as

cp --archive <source> <target>

According to man, --archive is the same as --no-dereference --recursive --preserve=all.

I’m not sure about the dereference option.

I would use rsync, myself (in fact, I do):

rsync -av /home/<user>/ /Backup/home/<user>/

This is one of the things rsync is designed to do. The -a switch is for archiving, and basically turns on a bunch of other switches. Check out man rsync for the details.

1 Like


Most of my rsync scripts backing up to an attached USB drive do something like this:

> /usr/bin/rsync --archive --backup --update --8-bit-output --xattrs --acls --omit-link-times --one-file-system --whole-file --progress --stats --human-readable --log-file=/tmp/$effectiveUserID-$systemHostName-rsync-$dateStamp /home/$effectiveUserID/ /mnt/Backup/$effectiveUserID/$systemHostName

The script’s parameters are:

systemHostName=$(hostname --short)
dateStamp=$(date +%Y-%m-%d)

Please note, an rsync peculiarity –

  • The source directory has a trailing slash – “/”
  • The target directory doesn’t have a trailing slash …
1 Like

Thanks for the suggestions, hendersj and dcurtisfra. I’ll try to migrate later next week.

1 Like

Hi, just a follow-up. Migration for SSD went OK with cp -a on /home, plus 3hs to resize sd3 (/home/Backup) partition to fill the HDD entirely.
However I lost secureboot, i.e., with secureboot on in BIOS openSUSE won’t load. It’s not important as this box doesn’t dual-boot. I think this happened because I just cloned sda1 and sda2, not the full HDD? Anyway, it’s working :slight_smile: