Dd

From LinuxBBQ Wiki
Jump to: navigation, search

dd is a program that copies a file (from standard input to standard output, by default) with a changeable I/O block size, while optionally performing conversions on it.

That all sounds very complicated, but let's have a look at what you will mostly use dd for.

dd a .iso to USB

We'll do this in a couple of clear steps. The assumption here is that you have downloaded the linuxbbq-boner.iso (for the Boner release) and are performing the commands below in the directory where that file is. Also, you have a USB stick that contains no data of any worth to you or others, and it is big enough to hold the .iso file.

1. plug in your USB stick

2. open a terminal and check to see where the stick was placed in the /dev tree:

[15:10:12]$ sudo blkid -o list
device     fs_type label    mount point    UUID
-------------------------------------------------------------------------------
/dev/sda1  ext4             /              f0c32a86-db83-41fa-b963-61c8a7a0ddd3
/dev/sda4  ext4    storage  /media/storage 0fd2b600-ced7-4ee3-80f4-b97bd3005a95
/dev/sdb1  ext3    MY USB   (not mounted)  6495334e-ccb4-4e46-9764-c4097f56d9d6

Here you can see that on my computer, the USB stick was placed at /dev/sdb1. However, the '1' at the end indicates that this is a partition on the drive. I want to install the .iso to my entire stick, so I got a bootable live system. So, just remove the number and you got the entire stick: /dev/sdb.

3. start the dd:

dd if=linuxbbq-rocks.iso of=/dev/sdb;sync

I add the 'sync' bit at the end because of settings where files are not written to drives synchronously, but the actual writing is delayed by the system for whatever reasons it might have to do that. This means that when a drive is set to work non-synchronously, when you unplug your USB stick the write of the file might not be complete, even though the 'dd' command seems to have finished. So, to be on the safe side, I sync.

4. when all is finished, reboot your computer

sudo reboot

and boot into your new live system! (assuming you set up the computer to boot from USB in the BIOS of course...)

A word of warning

The unofficial expansion of the 'dd' abbreviation is 'Disk Destroyer', because it is very easy to overwrite the wrong disk with data. Switch around the 'if' and 'of' parameters, and you could write the wrong thing to the wrong other thing. In the example case this wouldn't be a huge problem (you wouldn't be able to boot from USB though), but say you want to dd one hard drive to the other, then mix up your variables? That would suck.

Links