why is the output of `du` often so different from
2014-03-28 00:00
375 查看
why is the output of du often so different from du -b? -b is shorthand for --apparent-size --block-size=1. only using --apparent-size gives me the same result most of the time, but --block-size=1 seems to do the trick. i wonder if the output is then correct even, and which numbers are the ones i want? (i.e. actual filesize, if copied to another storage device)
A:
Apparent size is the number of bytes your applications think are in the file. It's the amount of data that would be transferred over the network (not counting protocol headers) if you decided to send the file over FTP or HTTP. It's also the result of cat theFile | wc -c, and the amount of address space that the file would take up if you loaded the whole thing using mmap.
Disk usage is the amount of space that can't be used for something else because your file is occupying that space.
In most cases, the apparent size is smaller than the disk usage because the disk usage counts the full size of the last (partial) block of the file, and apparent size only counts the data that's in that last block. However, apparent size is larger when you have a sparse file (sparse files are created when you seek somewhere past the end of the file, and then write something there -- the OS doesn't bother to create lots of blocks filled with zeros -- it only creates a block for the part of the file you decided to write to).
A:
Apparent size is the number of bytes your applications think are in the file. It's the amount of data that would be transferred over the network (not counting protocol headers) if you decided to send the file over FTP or HTTP. It's also the result of cat theFile | wc -c, and the amount of address space that the file would take up if you loaded the whole thing using mmap.
Disk usage is the amount of space that can't be used for something else because your file is occupying that space.
In most cases, the apparent size is smaller than the disk usage because the disk usage counts the full size of the last (partial) block of the file, and apparent size only counts the data that's in that last block. However, apparent size is larger when you have a sparse file (sparse files are created when you seek somewhere past the end of the file, and then write something there -- the OS doesn't bother to create lots of blocks filled with zeros -- it only creates a block for the part of the file you decided to write to).
相关文章推荐
- Is the type of “pointer-to-member-function” different from “pointer-to-function”?
- The database page size of 4096 bytes obtained from ASE is different from the database page size of 2
- wiggle sort Given a list of integers, sort them so the output is s1 <= s2 >=s3 <=s4 ... sN.
- The source file is different from when the module was built.
- It is not possible to run two different versions of ASP.NET in the same IIS process.问题的解决
- fatal error C1853: 'Debug\test.pch' precompiled header file is from a previous version of the compil
- Why Cloud Computing is the Future of Mobile
- Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7
- What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memor
- Question 30: What is the order of destructor calls for an object of class Y inherited from class X that has an object of class A
- Here is the reason why Fengguang turns from ipmitool to freeipmi
- 转载:Character data is represented incorrectly when the code page of the client computer differs from the code page of the database in SQL Server 2005
- Why The Future Of Digital Security Is Open(为什么数字安全的未来是开放)
- Question #49: What is the output of the program?
- android.util.AndroidRuntimeException Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? com.uethinking.microvideo.manag
- Why writing files from the kernel is bad ?
- Why is the size of an empty class not zero?
- atal error C1853: 'Debug\xxx.pch' precompiled header file is from a previous version of the compiler
- 【翻译】Why JavaScript Is and Will Continue to Be the First Choice of Programmers
- (转)fatal error C1853: precompiled header file is from a previous version of the compiler, or the pre