2

I have an empty disk mounted as /data

The df -h shows me that 188M are used while a du -h shows me 4,0K.

root@marc:~# du -h --max-depth=1 /data
4,0K    /data

root@marc:~# df -h
Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
/dev/sdb1          910G    117G  747G  14% /
udev               3,9G    8,0K  3,9G   1% /dev
tmpfs              1,6G    808K  1,6G   1% /run
none               5,0M       0  5,0M   0% /run/lock
none               3,9G    164K  3,9G   1% /run/shm
AFS                8,6G       0  8,6G   0% /afs
/dev/sdc1          230G    197G   21G  91% /backup
/dev/sda1          230G    188M  218G   1% /data

I was planning to reformat the disk in order to install a new system on it but I would like to know what these 188M are.

The /dev/sda1 is formated as ext4 partition. Could this be ext4 specific information I can safely erase ?

2 Answers 2

9

Filesystems like ext3 or ext4 use journaling mechanism. It helps to protect the filesystem consistency when situations like power outage or system crash happen. Whenever metadata (data) are changed they are first written to the journal without changing the rest of the filesystem. Once all of those changes have been journaled the changes are commited and the kernel can continue with writing actual metada (data) to the disk.

The ext3/ext4 journal is maintained on a dedicated portion of the filesystem. In your case, it occupies 188MB of the filesystem on /dev/sda1.

You can try to create an ext3/ext4 filesystem without journal (on spare partition)

mkfs.ext4 -O ^has_journal /dev/sdXY

to see the difference. You can find more about ext3/ex4 journaling in the related man pages of mkfs.ext3 or man mkfs.ext4 commands.

1
  • 3
    I understand the intention behind showing how to create a file system without journal. But you should not use the resulting file system unless you know exactly what you are doing. Just for the record.
    – scai
    Aug 19, 2013 at 11:20
-1

The answer lies in man page of du and df. Let me quote

NAME
   df - report file system disk space usage


NAME
   du - estimate file space usage

When you run du -h --max-depth=1 /data it tries to find the first level directories (i.e. just the directories inside /data directory) and shows how much space they have taken. Unless you specify --block-size= it will show in human readable format i.e. 1 KiB or 1024 bytes. So, inside your /data directory, you have 4,0 KiB of data. NOTE - this is size of data.

But when you run df on it, it calculates the filesystem size of /data and that is the total space of the filesystem. So, you get big space.

And it has nothing to do with ext3 or ext4.

4
  • Someone give me the rationale of downvoting the answer. I am very keen to know and learn from you. Aug 19, 2013 at 17:05
  • I didn't down vote. The 4K yield by du is not the problem. The problem is the 188M. Apparently It's the file system usage. So it has to do with ext3 and ext4. This is probably the reason your answer was wnvoted. The later has a journaling system which I guess now is reserving the 188M.
    – chmike
    Aug 20, 2013 at 13:21
  • Yeah that's reserve space usage (5%) for root fs so that the root fs doesn't go to ENOPSC error. Now it looks like I misunderstood the question. Anyway, cheers. Aug 20, 2013 at 17:10
  • No, df does not report root reserve as usage. It is the file system journal that is reported as usage.
    – misiu_mp
    Dec 4, 2016 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .