LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2011, 11:46 PM   #1
turtlemicro
LQ Newbie
 
Registered: Nov 2011
Posts: 3

Rep: Reputation: Disabled
I have a question about the dd command!


Please don't direct me to the dd thread here in the forums, it has a ton of examples, but no clear explanation about my question. I already read it.

My question is this.

When running dd like so ->

Code:
dd if=/dev/zero of=/dev/sda
I know the hard drive get's wiped. However it takes a very, very long time.

If I do this instead

Code:
dd if=/dev/zero of=/dev/sda bs=4K
It speeds up considerably. What is the difference?

Furthermore, there are so many examples, I can't help that most are careless use to do this. Could someone please go into detail about the best most efficient and correct way to do this to a standard hard drive and also what would be the best way to wipe a solid state drive and at last a flash drive.

I understand this may be a beginner question, but I hope for a professional answer. Many times I used drive partitioning software on windows that have options for standard and secure wipes later to find out they are tiny linux programs in dos mode that might acutally be using standard linux utilities.

I would like to be able to fully understand how to operate critical system utilities such as dd - Please point me in the right direction if you can.

The last part of my question is more difficult.

How can I run dd to wipe the first megabyte and last megabyte of the hard drive without having to manually get information about my hard drive on sectors and so on.
 
Old 11-06-2011, 12:45 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 190Reputation: 190
Quote:
What is the difference?
"bs" is the byte size that is written at a time. ie: 4k gets written at a time.
Quote:
I can't help that most are careless use to do this.
huh?
Quote:
Could someone please go into detail about the best most efficient and correct way to do this to a standard hard drive
Quote:
Please note: bs=4096 works fast for machines with at least 128 MB of ram. Dd uses a lot of buffers. At bs=4096, on modern machines, the optimal transfer rate is reached for hard drives.
(Taken from the dd article on LQ you claim to have read.) http://www.linuxquestions.org/linux/...ything_With_DD
Quote:
also what would be the best way to wipe a solid state drive and at last a flash drive.
It is best to avoid dding zeros (or random) over solid state devices, this includes SSD's and flash drives, as they have a limited number of writes, and dd'ing wastes these, across the entire device.
Quote:
How can I run dd to wipe the first megabyte and last megabyte of the hard drive without having to manually get information about my hard drive on sectors and so on.
the first Meg, is easy,
Code:
dd if=/dev/zero of=/dev/sdx bs=1M count=1
The LAST 1M, effectively you need to know how many megs there are, in order to know when to start.. So you need to have that information.. it can fairly easily be obtained from fdisk, grepped, and calculated with awk.
Code:
fdisk -l | grep "/dev/sda:" | awk '$5 -= 1048576 {print $5}'
will give you the number of bytes on the drive minus 1M (1048576 bytes)

You would then convert bytes to blocks (you can do that bit), and use dd's seek option, to seek that far through the output file before starting to write. Also, this can probably be piped to dd to create a one liner..

(This is entirely untested, unverified, and may well break. Use it only as a basis for pointing yourself in the right direction! Use at your own risk, blah blah)
 
  


Reply


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
MV command question. swamprat Linux - Newbie 4 04-23-2008 08:56 PM
command question simple2 Programming 4 04-09-2006 08:52 PM
mv command question skilletlicker Linux - General 2 02-03-2006 02:22 PM
cp command question satimis Linux - Newbie 1 09-13-2003 09:31 PM
cp command question . jesse_mair Linux - Newbie 3 07-09-2003 01:55 PM


All times are GMT -5. The time now is 07:01 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration