6

I'm copying a Raspbian partition from one SD Card to a stand alone Raspbian install on a new SD Card. Based on a suggestion elsewhere, I ran:

rsync -av --exclude=/mnt / /mnt

but now I'm concerned that I didn't preserve hard links because I didn't include the -H directive and instead rsync made copies of files instead of preserving hard links.

How can I correct this possible error? Can I run some form of rsync to fix this? such as:

rsync -avH --delete-after --exclude=/mnt / /mnt
4

Your idea is right.

Here is a test:

/foo$ stat -c '%i-%n' *
658846-egg
656129-spam
656129-test


/bar$ rsync -av /foo/ .
sending incremental file list
./
egg
spam
test
sent 229 bytes  received 76 bytes  610.00 bytes/sec
total size is 0  speedup is 0.00


/bar$ stat -c '%i-%n' *
657110-egg
663431-spam
663560-test


/bar$ rsync -Hav --delete-delay /foo/ .
sending incremental file list
test => spam

sent 107 bytes  received 19 bytes  252.00 bytes/sec
total size is 0  speedup is 0.00


/bar$ stat -c '%i-%n' *
657110-egg
663431-spam
663431-test

On a different note, its better to use --delete-after rather than other similar options i.e. --delete-before, --delete-delay, --delete-during because these options decide which files to delete either before or during the transfer.

  • 2
    In case this is not clear, heemayl is looking at the inode numbers to detect hardlinks -- hardlinked files will have the same, unique number. This is similar to what I mentioned to you elsewhere about doing a test with ls -l to see the link count. – goldilocks Jul 12 '15 at 19:54
  • "On a different note, its better to use --delete-after rather than other similar options..." so just like my originally posted suggestion? – BartmanEH Jul 12 '15 at 19:59
  • @BartmanEH yes..right.. – heemayl Jul 12 '15 at 20:01
  • @BartmanEH Glad i could help :) – heemayl Jul 12 '15 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.