[Windows] How do I account for hardlinks when checking disk usage?

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
turtlejay
Posts: 20
Joined: 13 Mar 2020, 00:20

[Windows] How do I account for hardlinks when checking disk usage?

Post by turtlejay »

Hi.

Im using the AMC script in --action hardlink. After it completes and does the job its intended to do (awesome), my nas reports free space including both files created by amc, essentially using twice the space even though I know it isnt. To be clear, if i download a 5GB file on a 100GB disk, the nas thinks theres only 90GB free. if someone could clarify for me id appreciate it. Thanks to rednoah for an amazing piece of software
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Hardlink space question

Post by rednoah »

:?: What tool do you use to count file size and disk usage? (TIP: a screenshot would have preemptively answered this question)


:idea: Use df -h and du -h to check disk usage and count file size:

Code: Select all

df -h

Code: Select all

du -h

:arrow: https://stackoverflow.com/a/19952240/1514467
:idea: Please read the FAQ and How to Request Help.
turtlejay
Posts: 20
Joined: 13 Mar 2020, 00:20

Re: How do I account for hardlinks when checking disk usage?

Post by turtlejay »

I was going by what free space windows and my Nas’ interface was showing the volume has left. I will run those commands to see the breakdown but what my concern is is does windows still know that technically if I fill the drive half way will it still think it’s full because every media file has a hard link.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I account for hardlinks when checking disk usage?

Post by rednoah »

Your NAS manufacturer (Synology? QNAP? A different one?) may not have accounted for this use case well during testing.


:idea: It'll probably just work, even if some tools "double count" things and end up displaying unreasonable values. You could take some 1 GB file, and then create 10.000 hardlinks with a bash script, just to see what will happen in your specific case and software at play.

e.g.

Code: Select all

# create a 1 GB file
dd if=/dev/zero of=1g.img bs=1 count=0 seek=1G

Code: Select all

# create 10k hardlinks
for i in {1..10000}; do ln -v 1g.img 1g-${i}.img; done

Code: Select all

# check total size
du -h
:idea: I get 264K as total file size. Looks like du -h is even aware of sparse files. ls -lh will report lots of 1 GB files though.
:idea: Please read the FAQ and How to Request Help.
turtlejay
Posts: 20
Joined: 13 Mar 2020, 00:20

Re: How do I account for hardlinks when checking disk usage?

Post by turtlejay »

Ok I will mess around with those commands on my Asustor NAS. So lastly, in my case QBit is running on a windows machine using the Nas for storage as a mapped network drive. Shouldn’t windows understand the hard links properly? Or because they were created on a network drive would windows disregard and just report both files as equal size consumption?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I account for hardlinks when checking disk usage?

Post by rednoah »

Few Windows users use hardlinks, so most Windows applications do not account for hardlinks. I am already very surprised that creating hardlinks from a Windows client via SMB works at all. I would be 10x surprised if Windows Explorer were to account for hardlinks on a remote SMB share correctly.

Well, all you can do is create a few thousand hardlinks, and then report your findings back to us. Because we'd like to know too! :D
:idea: Please read the FAQ and How to Request Help.
turtlejay
Posts: 20
Joined: 13 Mar 2020, 00:20

Re: [Windows] How do I account for hardlinks when checking disk usage?

Post by turtlejay »

That's interesting to me because I've only ever used the script via windows this way. the script never throws a hardlink error and always completes. do you have a suggestion besides hardlink? symlink maybe? its basically just for plex purposes which i know handle symlinks very well
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Windows] How do I account for hardlinks when checking disk usage?

Post by rednoah »

If it doesn't error out, then it works. You can use the stat /path/to/file command on the Linux device to see if two files are the same file, i.e. same device / inode.


:!: You'll want to stick to hardlinks cause they're indistinguishable from normal files (because normal files are hardlinks) while symlinks (i.e. files that just contain the file path to another file) probably are nothing but trouble if you create them on one machine and then use them on another.
:idea: Please read the FAQ and How to Request Help.
Post Reply