Is there a way to make Thunar display "recursive" file size?

6,083

Solution 1

I should explain a bit of Linux File System structure to explain this. Most linux file systems do something similar, but I assume ext4, which is the current default.

File System Structure

  • inode is the basic block that the file system understands as a logical unit.
  • A directory inode contains references to other inodes.
  • A file inode contains the metadata, actual data, and references to continuation blocks, in case the file had to be stored in a non contiguous manner.

Links

  • Ext4 supports two kinds of links. Hard and Soft.
  • A hard link is a reference to inode directly. Each file has atleast one hard-link, from the directory it belongs to.
  • Since a directory is just a inode, with information about group of inode references, it can reference itself, or a parent. In other words, a folder can be both child and parent to the same folder.

Okay, this may be getting confusing. Let me explain. Assume you have three folders, A,B,C as follows.

C is in B.  
B is in A.

Now, the fun part is, C can point to the same inode as A, creating what is sometimes called a circular reference loop. If you try recursing, you will encounter a never ending loop.

  • Soft links are ordinary files that record the directory path to their target location. They are just marked on the filesystem that instead of a line of text, they should be interpreted as a link to some other location. Nautilus, for example, creates soft links when you use its 'Create link'/'Link here' options.

So What?

Hence, trying to calculate sizes recursively has its quirks. It is a bad idea to try and compute sizes recursively by default. However, properties dialogs of all decent file managers I know show recursively calculated total sizes, because that is what an ordinary user expects.

Windows has no problem?

Actually, windows uses a different file system format called NTFS, which maintains a list of all files and their size. So it can always tell the total size easily.

Then why don't we use NTFS?

It does not support the Unix notion of permissions (rwx for owner, group, and universe separately), and that single reason makes it unfit for use as a Linux file system. Ext4 brings a lot to the table that this minor inconvenience doesn't matter to many.

Alright. Gimme the size I need.

Did you try du?

How does du work?

du stands for disk usage. It actually counts the inode blocks, taking care to not double-count them. Add up the sizes, and you have the total size.

TL;DR

Use du -hs <foldername> to find the actual size of the folder on disk. Read man du for more info.

Solution 2

At thunar top menu go to Edit>Configure Custom Actions, add a new Custom Action with:

  1. Basic tab: any Name [ex. Folder(s)-Files Size], Command du -h -c %N | grep total | zenity --text-info or du -chs %N | zenity --text-info for the selected folder or/and file size followed by the total size.
  2. Appearance Conditions tab: check all the boxes.

I found this solution at http://crunchbang.org

Share:
6,083

Related videos on Youtube

pzkpfw
Author by

pzkpfw

Hello world.

Updated on September 18, 2022

Comments

  • pzkpfw
    pzkpfw over 1 year

    I'm using Thunar 1.6.3 and currently when I'm looking at a bunch of folders it looks something like this:

    Folder 1        8,2 kB
    Folder 2        4,1 kB
    Folder 3        4,1 kB
    Folder 4        0   kB
    

    I'm not sure where these "size" numbers come from, but I'm sure they do not reflect the actual size of everything in the folders, because when I right click and choose "Properties" the folders (all of them only kilobytes in size) add up to over 100 Gb.

    Questions

    • Why does Thunar, just like the command line on both 12.04 and 14.04, show folder sizes like 4K? What does this number mean?
    • Is there a way to instead show compound size, that is the calculated recursive size of the folder and all contents, in the terminal, Thunar or any other file manager? (NB: I'm not looking for a shell script solution).
  • Alex
    Alex over 9 years
    Thanks for all the details! Nevertheless it would be nice to have the option to enable recursive file-size display in the default-view of file-managers. When searching why a bunch of folders needs so much memory, it is a pain to always right-click or use du + cd on console.
  • pzkpfw
    pzkpfw over 9 years
    @Alex if it's any help there is software designed to solve that problem, for example Baobab (gui) or ncdu in a terminal.