How come file size differs between ls and df?
Hi there,
I have a large file (a VirtualBox hard disk) which shows a size of about 8 GB in ls and about 4 GB of total disk usage in df. How come? Code:
$ ls -l disk.vdi |
Do you know that disk.vdi is on /dev/sda7?
What does "du disk.vdi" tell you? since the file is for a VM, is it possible that the file size gets reported differently? |
Maybe it is a "sparse file". You can find a definition on the Wikipedia. A common example on many systems is the file /var/log/lastlog
Code:
$ ls -l /var/log/lastlog Code:
# the following will print the allocated (total) space |
Quote:
Code:
$ ls -lh disk.vdi |
How would you create a "sparse file"? (Other than the dd method in the Wikipedia article)
|
I don't know any other *NIX utility to do that. On the other hand you can always use a programming language like C or Python. Here is a simple example in Python
Code:
#!/usr/bin/python |
|
All times are GMT -5. The time now is 07:17 PM. |