Little Things Doth Crabby Make – Part XII. Please, DD, Lose My Data! I Didn’t Need That Other 4K Anyway.

It’s been a while since the last installment in my Little Things Doth Crabby Make series. The full series can be found here. So, what’s made me crabby this time? Well, when a Linux utility returns a success code to me I expect that to mean it did what I told it to do. Well…

What’s 4K Between Friends?
Really? I’m just picky! If I use dd(1) to write 2GB (2 * 2^30 sort of 2GB by the way) I’m not looking for a successful transfer of (2 * 2 ^ 30) – 4096 bytes! Imagine that.

Folks, don’t trust the return code from dd(1). I’ve been burned more than once.

Is He Totally Crazy? Using dd(1) with a 2GB write size?
Sure, why not? If it doesn’t want to do what I ask it is supposed to fail the command, not lose data.

I just did this on a 2.6.18 Kernel:

# file /tmp/OH.tar
/tmp/OH.tar: POSIX tar archive
# ls -lh  /tmp/OH.tar
-rw-r--r-- 1 oradb oinstall 19G Jun 16 17:23 /tmp/OH.tar
# dd if=/tmp/OH.tar bs=2147483648 count=1 | wc -c
0+1 records in
0+1 records out
2147479552
2147479552 bytes (2.1 GB) copied, 2.52849 seconds, 849 MB/s
# echo $?
0
# bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
2147483648-2147479552
4096

3 Responses to “Little Things Doth Crabby Make – Part XII. Please, DD, Lose My Data! I Didn’t Need That Other 4K Anyway.”


  1. 1 Noons June 17, 2010 at 6:25 am

    Jeeeez! That’s a trap if ever I saw one!
    Thanks for the warning, Kevin!

  2. 2 Freek June 17, 2010 at 9:15 am

    Kevin,

    dd will indeed return a 0 exitcode, but in your example, would the exit code not come from wc instead of dd?

    regards

    • 3 kevinclosson June 17, 2010 at 3:43 pm

      Yes, Freek, good catch. I discovered the erroneous success code before I plugged the wc in. I though the wc would make the point easier to understand. I’ll quicklu follow up with proof that it fails the same was with a file to file dd.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




DISCLAIMER

I work for Amazon Web Services. The opinions I share in this blog are my own. I'm *not* communicating as a spokesperson for Amazon. In other words, I work at Amazon, but this is my own opinion.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2,987 other followers

Oracle ACE Program Status

Click It

website metrics

Fond Memories

Copyright

All content is © Kevin Closson and "Kevin Closson's Blog: Platforms, Databases, and Storage", 2006-2015. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Kevin Closson and Kevin Closson's Blog: Platforms, Databases, and Storage with appropriate and specific direction to the original content.

%d bloggers like this: