LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Questions about file size and dd (http://www.linuxquestions.org/questions/linux-software-2/questions-about-file-size-and-dd-671871/)

djeikyb 09-23-2008 03:07 PM

Questions about file size and dd
 
According to DD, I'm making at least 5mB files, right? But according to ls and du, they're a tenth of a mB or so short. Anyone know why?

bash-3.2$ dd if=/dev/random of=foo.bsKB-count.5000 bs=KB count=5000
5000+0 records in
5000+0 records out
5000000 bytes (5.0 MB) copied, 1.202 s, 4.2 MB/s

bash-3.2$ dd if=/dev/random of=foo.bsKB-count.5120 bs=KB count=5120
5120+0 records in
5120+0 records out
5120000 bytes (5.1 MB) copied, 1.304 s, 3.9 MB/s

bash-3.2$ dd if=/dev/random of=foo.bsMB-count.5 bs=MB count=5
5+0 records in
5+0 records out
5000000 bytes (5.0 MB) copied, 0.97 s, 5.2 MB/s

bash-3.2$ ls -1sh foo*
4.8M foo.bsKB-count.5000
4.9M foo.bsKB-count.5120
4.8M foo.bsMB-count.5

bash-3.2$ du -h foo*
4.8M foo.bsKB-count.5000
4.9M foo.bsKB-count.5120
4.8M foo.bsMB-count.5

jailbait 09-23-2008 03:24 PM

1 megabyte = 1024 kilobytes. You are calculating as if 1 megabyte = 1000 kilobytes.

-------------------
Steve Stites

djeikyb 09-23-2008 04:02 PM

Sure, that explains why the first one (5000kB) is less than 5mB, but what of the other two?

djeikyb 10-15-2008 04:29 PM

Ah. Seems I missed the section of man dd that says:
Quote:

BLOCKS and BYTES may be followed by the following multiplicative suffixes: xM M, c 1, w 2, b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
Also relevant is the du command. To get an actual human readable size, use "du -bh"


All times are GMT -5. The time now is 11:59 AM.