2

I want to create snapshots/hard links for my backups, using the cp -al command. While cp -al does create hardlinks when using it on my main system (Mint 18.1), where the parent directory size stays mostly the same after several snapshots, on my backup server (Mint 17.3) it seems to ignore the -l flag, making what seems like regular copies, since the parent directory increases by the size of each new snapshot. The file systems on both machines is ext4. The difference on the backup server is that it's a logical volume. I get the same problem on another machine that has a regular physical volume though, so I don't think that's the problem. Any idea what the problem could be? Thanks.

  • So, I made a test with two virtual machines, one with Mint 18.1 and one with Mint 17.3, and I get the same behaviour. So it seems that hard links just don't work in 17.3... Can anyone confirm that, and why? Thanks. – maks Jun 20 '17 at 20:33
  • Is Hard Links the opposite of Symbolic Links? If it is they are called files. Files points to sector, so they are links to sectors, when you create a hard link, you just copy the file reference, so the both files are real. – Luciano Andress Martini Jun 20 '17 at 20:57
  • I'm basically following this guide to create snapshot, or "time machine-like" backups: mikerubel.org/computers/rsync_snapshots The "Review of hard links" sections explains the concept. – maks Jun 20 '17 at 22:11
  • 2
    @maks, did you check the inode numbers of the original and copied files? What are you using to check the directory size? – ilkkachu Jun 20 '17 at 22:37
  • @ilkkachu, on mint 18.1 the inode number for a specific file in both folders is 1302, on Mint 17.3 the inode number is 266098 for the same file in both folders. What does than mean? I'm not familiar with inode numbers. To check the directory size I used the Properties dialog of Caja and Thunar. – maks Jun 21 '17 at 1:40
1

on mint 18.1 the inode number for a specific file in both folders is 1302, on Mint 17.3 the inode number is 266098 for the same file in both folders. What does than mean? I'm not familiar with inode numbers. To check the directory size I used the Properties dialog of Caja and Thunar.

The idea of hard links is to have multiple links to the same inode, so if you find files with the same inode, it means that they are hard links. The second column of ls -l is also a link count. (Note that directories will also always be shown with a link count greater than one, since dir/. and dir/subdir/.. are hard links).

To show that hard links do not take extra space, either look at the free space on the filesystem as a whole before and after (e.g. with df: cd /my/backup/filesystem && df -h .). Or, use a tool which is aware of hardlinks to measure the space taken up by the directory which ultimately contains both hardlinks. According to man du, du (note the one-letter difference!) is such a tool: cd /my/backup/directory && du -s -h ..

I don't know whether versions of Thunar or Caja implement hard-link aware measuring - you can tell us whether they show the "right" value when compared to du :-).

  • 1
    my bad, the problem was indeed Thunar not taking into account hard-links. du -sh shows the correct size, as does Caja, so I'm happy to see that my snapshot copies are in the end working as expected! Thanks a lot for your help! :) – maks Jun 24 '17 at 1:20

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.