Bug 126112

Summary: du -h gives size in KB on lastlog file
Product: [Fedora] Fedora Reporter: Gregory Petit <thunderbirds>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-06-25 10:54:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Gregory Petit 2004-06-16 07:52:39 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7)
Gecko/20040614 Firefox/0.8

Description of problem:
du -h gives the output in KB where it should be MB on the lastlog file.

[root@homer log]# ll lastlog
-r--------  1 root root 19136220 jun 16 06:34 lastlog
[root@homer log]# ll -h lastlog
-r--------  1 root root 19M jun 16 06:34 lastlog
[root@homer log]# du -h lastlog
21K     lastlog

Same problem on RedHat 9 (i386):

[root@superpc log]$ rpm -qf /usr/bin/du
[root@superpc root]# cd /var/log
[root@superpc log]# ll lastlog
-r--------    1 root     root     19136220 jun 16 09:45 lastlog
[root@superpc log]# ll -h lastlog
-r--------    1 root     root          18M jun 16 09:45 lastlog
[root@superpc log]# du -h lastlog
23K     lastlog

-> Problem doesn't occurs on other files bigger than 1MB.
-> Problem doesn't exists on RedHat 7.0
[greggy@mission-control greggy]$ rpm -qf /usr/bin/du
[greggy@mission-control greggy]$ cat /etc/redhat-release
Red Hat Linux release 7.0 (Guinness)

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. execute du -h on /var/log/lastlog

Actual Results:  Output shows K (kilobytes)

Expected Results:  K should be M (megabytes)

Additional info:

lastlog seems to be the only file for which the du output is not
correct. Renaming the file doesn't solve the problem.

Comment 1 Tim Waugh 2004-06-25 10:54:14 UTC
It's a sparse file, and du is telling the truth: it really does only
take up that much disk space.  The file is largely zeros, and the
filesystem has an efficient way of representing that.