[dd] Uses in GNU / Linux systems

As we all know, the dear dd [dd command on GNU / Linux systems] is a great guy when it comes to making isos, saving / writing MBR among other tasks. But now well how do I make an ISO with it?

Very easy, just run the following in your terminal:

dd if=/dev/cdrom of=/home/Install/Isos/debian-7.0.0-i386-CD-1.iso

if, comes from "input file", Y of comes from "output files”, What obviously reading in the man takes a little more juice to the orange xD. At if the input device is specified, and in the of the output path of our ISO file will be specified. Important note, with cat it is possible to do the same, which cat it does not carry if ni of.

cat /dev/cdrom /home/Install/Isos/debian-7.0.0-i386-CD-1.iso

So, having already known this, let's go ahead. Another use is to sodomize the USB [Sodomize?], Yes, I know it sounds ugly, but hey, for those who buy USB memory sticks and are heartbroken to steal them, that is, to sell a USB stick of 4GB and is 128MB, which is very annoying, we can do a very basic test:

Writing test:
dd if=/dev/zero of=/dev/sdb1 bs=1M count=4096

Reading test:
dd if=/dev/sdb1 of=/dev/null bs=1M count=4096

Copying / reading 4GB of zeros to the USB, checking that it really is 4GB. If it finishes before and does not put the preset amount, you have been scammed xD.

Note: check well which is the USB device you connected, because you can invite the dance to your HDD [SATA] and lose all the info you have in it !!!

Other varied uses ...

Clone a hard drive, for IDE drives:
dd if=/dev/hda of=/dev/hdb bs=1M

for SATA drives:
dd if=/dev/sda of=/dev/sdb bs=1M

Copy the Master Boot Record:
dd if=/dev/hda of=mbr count=1 bs=512

To restore the MBR:
dd if=mbr of=/dev/hda

Create a 1GB swap file:
dd if=/dev/zero of=/boot/swap_space bs=1M count=1024
mkswap /boot/swap_space
swapon /boot/swap_space

[And for hackers xD, #ZOMG, hackers]

A few days ago I was reading ways to format our HDD, without leaving a trace on it of anything that was previously there, not even using some top secret information retrieval tool, and to my intrigue / satisfaction dd it was among the possible alternatives.

But how can I do this? Easy:

dd if=/dev/zero of=/dev/sda bs=1M

Filling the hard drive with zeros. With bs = 1M, we are saying that both reading and writing is done in 1 megabyte blocks. We can also use / dev / random, but it takes a world, earning it last place in the quick erase test: D.

So the FBI won't find anything on your HDD xD ...

References:

http://en.wikipedia.org/wiki/Dd_%28Unix%29
http://es.wikipedia.org/wiki//dev/zero

dd: clone and burn hard drives easily


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   sieg84 said

    what difference is there with dd_rescue?

    1.    koratsuki said

      I've never used it, I owe it to you my friend ...

      1.    sieg84 said

        I ask because in the openSUSE wiki to create a live-usb, before they had it with dd, now it is (it has time) with dd_rescue, something like this:
        ~> your
        # grep -Ff <(hwinfo –disk –short) <(hwinfo –usb –short)
        # umount / dev / sdXY
        # dd_rescue openSUSE-11.4-KDE-LiveCD-x86_64.iso / dev / sdX

        en.opensuse.org/SDB:Live_USB_stick#Record_la_ISO_a.C2.A0la_USB_memory_3

  2.   Manuel R. said

    Thanks for the information, although I know that there are graphical tools to create the isos, I have always liked using the terminal ^^. Also I didn't know that MBR could be backed up. Regards.

  3.   proper said

    It's great but for USB Drives the number you put is in base 2 and it should be in base 10, which is what is used to store information.

    1.    koratsuki said

      I hadn't noticed that, thank you ...

  4.   auroszx said

    It helped me 🙂 I made a backup of the Arch partition, deleted it, recreated it as logic (it was primary) and with dd I put the data back in place. Very useful ^^

    1.    koratsuki said

      A pleasure to have helped you colleague 😀

  5.   chrisnepite said

    If you add a pipe »| »With the« pv »command you can see a progress bar and the writing details.

    For example like this for a USB:

    dd if = / path / of / image.iso | pv | dd of = / dev / sdX

    1.    KZKG ^ Gaara said

      WTF !! Super interesting ... this progress helps a lot 😀

      1.    Hugo said

        Certainly. I had seen another trick with the same objective, but I never managed to make it work for me, instead this one did.

    2.    giskard said

      The best way to see progress is to use dcfldd which is a replacement for DD but with a progress display. It's what I use. The syntax is the same as in dd.

      http://dcfldd.sourceforge.net/

      I was going to comment on it a long time ago but the post was closed to comments.

  6.   Hugo said

    Something curious is that the original meaning of the initials dd apparently it has been erased over time, so it can be called in many ways: duplicate device, disk duplicator, data dump, disk destroyer, etc.

    An application of dd is to clean up a partition table. This can be useful to make a clean partition scheme on a used disk, without having to erase the entire disk. For example, if the system detects the disk as / Dev / sdb We could write the first 256MB to zero (actually the partition table is in the first 512 bytes, but since the first sectors of the disk are usually critical, for greater security I clean more space)

    dd if=/dev/zero of=/dev/sdb bs=512 count=512K

    In addition, sometimes zeroing a flash memory can help to recover it, for which a similar procedure can be used.

    Another more interesting use is to obtain information about the BIOS without having to restart, which is possible because in Linux almost all resources are managed as files, including RAM (BIOS information is cached in the last 32KB of the first MB memory).

    dd if=/dev/mem bs=32k skip=31 count=1 | strings -n 8 | grep -i bios

    What this command does is define the block size in 32 kilobytes and skip the first 31 blocks (that is, skip 992 kilobytes), filter the output to show only strings of 8 or more characters, and search in those strings for the one that contains the word BIOS.

    1.    elynx said

      Very useful Hugo, Thank you!

  7.   Dr Byte said

    What a good post, I think how great it can be used.

    Greetings.

    1.    KZKG ^ Gaara said

      A pleasure to know that you liked it 🙂

  8.   Hugo said

    Another use that I did not remember is to create a file of a suitable size that can then be formatted and mounted with a loop as if it were a partition, which is very useful to create a partition with restricted permissions on a system that has been mounted with a single partition on the disk. Even a file prepared in this way can be exported over the network as a block device using AoE and another PC would detect it as if it were a local disk. Additionally, dd can be used to dump RAM and then calmly review it (if necessary) without breaking down your computer. Anyway…

  9.   Sys said

    > Very easy, just run the following in your terminal:

    > dd if = / dev / cdrom of = / home / Install / Isos / debian-7.0.0-i386-CD-1.iso

    It is not that easy.

    *** In http://www.tech-recipes.com/rx/2769/ubuntu_how_to_create_iso_image_from_cd_dvd it was said:

    Dd doesn't have any checking. What happens if you have some wild hard drive activity, and you don't get all the bits copied? You have a bad ISO, and you won't know it.

    Instead, you should be using the right tool for the right job. In this case, you need to check out the 'readom' command (read optical media). It does exactly what you're looking for, and has built in error checking.

    readom dev = / dev / scd0 f = / home / shamanstears / test.iso

    If you want to record the ISO, then you should be using 'wodim', not 'dd', or any other horrible «solution».

    wodim -v -eject /home/shamanstears/test.iso

    This will burn your 'test.iso' to your blank CD, assuming it's already inserted, and eject when it's finished. It'll even be verbose about it's output along the way. These sort of shoddy tips and tricks are what get a lot of users in trouble. Remember- use the right tools for the right job, and everyone will be happy.

    *** In http://www.tech-recipes.com/rx/2769/ubuntu_how_to_create_iso_image_from_cd_dvd it was said:

    I tried using dd to create an ISO of a SLES11 DVD but instead of creating a 3GB image it created a 4.4GB iso - a full DVD's worth with all

  10.   Alex said

    Great, thank you very much.

  11.   Sodom said

    I've done it before and it works, but I always have the same problem of not knowing which usb is (in my case an SD). I always forget the same