I have been using rsync
to clone ext4
root partitions, something along the lines of the following…
# rsync -ax -HAX --delete --devices --sparse --itemize-changes / /mnt/altroot/
It seemed to work quite well, or at least I though it did, but in the last few weeks, it started to miss files because some zypper dup updated files had the same size and date. I user `rsync --checksum`` to investigate further:
rsync -ax -HAX --delete --dry-run --checksum --devices --sparse --itemize-changes / /mnt/altroot/
More than 100 files were different. I picked a text file for closer examination…
# ls -l /usr/share/man/man1/spamc.1.gz /mnt/altroot/usr/share/man/man1/spamc.1.gz
-r--r--r-- 1 root root 6254 Jan 21 02:29 /mnt/altroot/usr/share/man/man1/spamc.1.gz
-r--r--r-- 1 root root 6254 Jan 21 02:29 /usr/share/man/man1/spamc.1.gz
# rpm -q -f /usr/share/man/man1/spamc.1.gz
spamassassin-spamc-4.0.1-78.3.x86_64
# rpm -V spamassassin-spamc-4.0.1-78.3.x86_64
# chroot /mnt/altroot/
# rpm -q -f /usr/share/man/man1/spamc.1.gz
spamassassin-spamc-4.0.1-78.3.x86_64
kosmos1.gentoo.co.nz:/ # rpm -V spamassassin-spamc-4.0.1-78.3.x86_64
..5...... /usr/bin/spamc
..5...... d /usr/share/man/man1/spamc.1.gz
In the above, the rpm -V
listed no issues for /
, but incorrect md5sums for two spamc files on /mnt/altroot
.
From the above, it seemed that some files were updated by the zypper dup without altering their dates and sizes. I took a look and confirmed it:
# zcat /usr/share/man/man1/spamc.1.gz > root-spamc.1
# zcat /mnt/altroot/usr/share/man/man1/spamc.1.gz > altroot-spamc.1
# diff root-spamc.1altroot-spamc.1
58c58
< .TH SPAMC 1 2025-01-20 "perl v5.40.1" "User Contributed Perl Documentation"
---
> .TH SPAMC 1 2025-01-20 "perl v5.40.0" "User Contributed Perl Documentation"
I then checked the mount options, they were rw,noatime
, so that doesn’t explain it.
It seems zypper dup or the build process may update files without changing their dates .
For safety I need to pass --checksum
to rsync if I’m cloning root partitions. (Fortunately, they’re on SSD and NVME.)