Difference between revisions of "Lastlog is gigantic"

From Noah.org
Jump to navigationJump to search
(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 ...)
 
Line 10: Line 10:
  
 
Why does the file appear to be 1.2 TB? This is because space is "allocated" for all possible user IDs, which is
 
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.
+
about 2^32 users time 256 bytes for each last login record which is about 1.2 TB -- more or less.
 
This is, thankfully, an illusion. The fail is created as a sparse file, so
 
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.
 
only the chunks of the file that are used are allocated. So the space really isn't allocated.

Revision as of 13:59, 5 July 2007

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 last login record 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.