Re: DD Command question



joe wrote:

Just started using Linux, so forgive my newbiness.
Lets say I have 1 hard disc (HDA) with only 1 partitioin (HDA1), and I
wanted to DD only the first 300MB into an arbritary folder. What DD
command would I need to copy the first 300MB of HDA and how would this
differ from DD`ing the first 300MB of HDA1 ?
Thanks in advance.

Welcome to the world of linux, Joe!

"hda" refers to the entire drive, starting with the master boot record that
is located in the first sector and including your hda1 partition that
follows. "hda1" begins with its own boot record followed by your files (and
unallocated sectors). You direct dd to start somewhere and process all of
the bytes within a specified range or leave out the range and allow dd
continue on to the end of the disk. It doesn't know or care whether the
bytes are data or just slack space: everything in the path is processed.
That's a lot different than a file copy operation.

To copy the first 1024 bytes of hda1 to a file save-this in the current
default directory, you could set blocksize to 1024 and do one move:

# dd if=/dev/hda1 of=save-this bs=1024 count=1

.... or copy two sectors:

# dd if=/dev/hda1 of=save-this bs=512 count=2

dd counts bytes, so you need to choose the blocksize and count values that
multiply out to your meaning of "300MB" (i.e., 300*1024*1024 or 3*10^8).
In either case, the resulting file will likely contain less than "300MB"
of data due to the slack space dd includes.

BE REALLY-REALLY CAREFUL!! dd is powerful. Screw up when typing in the
command and you will be appropriately rewarded. (Read this again.)

Having linux installed on an old clunker machine is a great place to
experiment without risking learning-curve damage to your good install.

Oh. And read the dd man page too!
.



Relevant Pages

  • Re: DD Command question
    ... command would I need to copy the first 300MB of HDA and how would this ... differ from DD`ing the first 300MB of HDA1? ... unallocated sectors). ... command and you will be appropriately rewarded. ...
    (alt.os.linux)
  • Re: how to get permission to mount devices and save files as user
    ... >> That's the FIRST hard drive, hda, and the FIRST partition on it, hda1. ... >> then you don't tell us if it is or not, nor what command you issued, so ...
    (comp.os.linux.misc)
  • Re: DD Command question
    ... wanted to DD only the first 300MB into an arbritary folder. ... What DD command ... would I need to copy the first 300MB of HDA and how would this differ from ... DD`ing the first 300MB of HDA1? ...
    (alt.os.linux)
  • Problem with HD
    ... I don't know what hapen in my Fedora Core 4, i have it installed, and ... hda: ST3120022A, ATA DISK drive ... ReiserFS: hda1: found reiserfs format "3.6" with standard journal ...
    (Fedora)
  • Re: grub error 22. Bad partition table? [solved]
    ... I misunderstood by not seeing the difference between hda and ... get the idea that while there is a _Master_ BR at the start of hda, ... there is also a space at the start of hda1 and each partition - for the ... purpose of each partition being able to be bootable and hold a boot manager. ...
    (Fedora)