LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-04-2011, 02:29 AM   #1
turtlemicro
LQ Newbie
 
Registered: Nov 2011
Posts: 3

Rep: Reputation: Disabled
dd command a little confusing?


2 questions -

1. When using dd, it does not always work. Here is what I mean ->

Code:
dd if=/dev/zero of=dev/sda bs=1M count=1
What I want to do is clear the 1st megabyte of the hard drive. This would render it initialized. On Windows, the diskpart clean command erases the 1st and last megabyte of the drive. It is always initialized after that.

The dd command sometimes works sometimes it does not. What is the proper use of the command. (?Can you run the command from the host linux install on the host drive? or do I need to boot a recovery disk every time?)

2. How can I automatically use dd to erase 1st mb and last mb in one call? like diskpart clean. Can someone write a quick script and show how to call it.
 
Old 11-04-2011, 02:51 AM   #2
agambier
LQ Newbie
 
Registered: Nov 2010
Location: Annecy, France
Distribution: Fedora 13
Posts: 22

Rep: Reputation: 2
Hi,

Quote:
Originally Posted by turtlemicro View Post
1. When using dd, it does not always work. Here is what I mean ->
Can you clarify your question...
copy/paste the output of your command to see what actually happens.

Quote:
Originally Posted by turtlemicro View Post
2. How can I automatically use dd to erase 1st mb and last mb in one call? like diskpart clean. Can someone write a quick script and show how to call it.
When the command will work using a terminal we can then write a script.
 
Old 11-04-2011, 03:03 AM   #3
turtlemicro
LQ Newbie
 
Registered: Nov 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
That's the problem

The problem is, there is no error message. Since sometimes it works, the command is always run. When it does not work, after rebooting the OS, the OS still boots because it's there. Please excuse me, this might be silly anyway.

In Windows, the OS does not allow you to format the C:\ drive. In Linux, the OS allows you to run dd and sometimes it deletes the 1st mb. I understand it's possible that the operation of the system, protects certain areas of the drive, and so on. Too complicated for me to pursue, but since it works sometimes, I wanted to know what I was doing right or wrong. I am still interested in a script if you have one (bash?).

Also, if you have a specific sequence to initialize a drive, please let me know the best way to do it in Linux.

Last edited by turtlemicro; 11-04-2011 at 03:04 AM.
 
Old 11-04-2011, 03:13 AM   #4
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 190Reputation: 190
Quote:
Originally Posted by turtlemicro View Post
Code:
dd if=/dev/zero of=dev/sda bs=1M count=1
You need the preceding forward slash in "/dev/sda"
 
Old 11-04-2011, 03:28 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,625

Rep: Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088Reputation: 2088
There is a (huge) thread here on "dd".
I find it unlikely it "sometimes" works - unless you have some "anti-virus protection" (say in the BIOS) that gets in the way.
The second MBR copy at the end of the disk is a M$oft "feature" - shouldn't affect you if you only boot Linux.

I've had no issues doing similar to you - even with Windoze on the same system/disk.
 
Old 11-04-2011, 04:42 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
http://www.linuxquestions.org/questi...ommand-362506/

looking for a guide?
Someone has very nicely explained "dd" command
 
  


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
confusing behaviour of a command aggrishabh Linux - Newbie 2 01-05-2011 11:26 AM
I am confusing ram_rajavarapu Linux - Enterprise 3 11-12-2008 06:54 PM
very confusing metallica1973 Linux - Software 5 08-07-2006 07:21 PM
Confusing find command davidas Linux - Newbie 1 03-24-2004 06:26 AM
so confusing c12ayon Programming 5 10-26-2003 11:52 PM


All times are GMT -5. The time now is 04:02 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