Lastlog is gigantic

From Noah.org
Revision as of 12:58, 5 July 2007 by Root (Talk | contribs) (New page: Why does the /var/log/lastlog file appear so huge on 64-bit machines? You might do a directory listing and see something like this: <pre> # ls -l /var/log/lastlog -r-------- 1 root root ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Why does the /var/log/lastlog file appear so huge on 64-bit machines? You might do a directory listing and see something like this:

# ls -l /var/log/lastlog
-r--------  1 root root 1254130450140 Jul  4 17:26 /var/log/lastlog
# ls -lh /var/log/lastlog
-r--------  1 root root 1.2T Jul  4 17:26 /var/log/lastlog

Why does the file appear to be 1.2 TB? This is because space is "allocated" for all possible user IDs, which is about 2^32 users time 256 bytes for each user which is about 1.2 TB -- more or less. This is, thankfully, an illusion. The fail is created as a sparse file, so only the chunks of the file that are used are allocated. So the space really isn't allocated. This just shows you how big the would would be if you tried to copy it or if you 2^32 users.

To see how big the file really is use the `du` command:

$ du --si /var/log/lastlog
74k     /var/log/lastlog

74K seems like a much more reasonable size.