Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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).
share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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