Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an 80GB Intel X25-M SSD drive installed on a Linux box running Debian 5.0. The file system on the SSD is ext4. I've had no problems with the drive, and have been using it for quite some time as both swap file storage as well as a place to store a few large database files which require random access.

However, I noticed this odd size readout from ls:

> ls -lh /ssd
total 34G
-rwx------ 1 root root 23G 2010-12-11 18:00 file1.dat
-rwx------ 1 root root 22G 2010-12-11 18:00 file2.dat

I changed the names of the files here for security reasons, but other than that this is exactly what ls has output. Obviously, the total size readout is incorrect.

Here is the corresponding output from df

> df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              74G   35G   36G  50% /ssd

Despite this incorrect readout, the drive seems to be working fine, and diagnostic utilities turned up nothing wrong with the drive. Is this some sort of known bug in ext4, or is it more likely there's something physically wrong with the drive?

share|improve this question

migrated from Dec 11 '10 at 23:59

This question came from our site for system and network administrators.

up vote 6 down vote accepted

Most likely neither. The size displayed by ls is the length of the file, however most modern filesystems support "Sparse Files" where empty blocks are not actually written to disk. Try running du -h /ssd/* and see what size it reports the files as. 'du' will display the amount of disk actually used, which should be fairly close (excluding filesystem overhead & reserved blocks) to that reported by 'df'.

share|improve this answer
Thanks, you're right. I'd like to accept this answer as correct, but for some reason there is no "check" icon to accept it. (Yes, I'm logged in.) Perhaps this question wasn't properly associated with my account after the migration from serverfault. – Charles Salvia Dec 12 '10 at 1:20

Second hit from a google search: sparse files, explains this in detail.

share|improve this answer

You must log in to answer this question.

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