LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-23-2008, 03:07 PM   #1
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
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
 
Old 09-23-2008, 03:24 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,511

Rep: Reputation: 177Reputation: 177
1 megabyte = 1024 kilobytes. You are calculating as if 1 megabyte = 1000 kilobytes.

-------------------
Steve Stites
 
Old 09-23-2008, 04:02 PM   #3
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Original Poster
Rep: Reputation: 33
Sure, that explains why the first one (5000kB) is less than 5mB, but what of the other two?
 
Old 10-15-2008, 04:29 PM   #4
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Original Poster
Rep: Reputation: 33
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"

Last edited by djeikyb; 10-21-2008 at 11:53 AM. Reason: So as not to bump finished thread
 
  


Reply

Tags
dd, df, du, file, size


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display by File Name, File Size, and File Owner using ls akeenabawa Linux - Newbie 9 08-15-2008 02:21 PM
How to write crontab to check file size and all file in a directory? modpriest Linux - Newbie 1 02-14-2008 06:48 AM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 06:55 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 09:58 PM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 04:18 PM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration