
Noerror means to keep going if there is an error. Notrunc means 'do not truncate the output file'. Do not reverse the intended source and target. This copies the first 2 sectors of the floppy.ĭd if=/dev/sda of=/dev/sdb conv=notrunc,noerror Now set the BIOS to USB boot, plug in the thumb drive, and boot the machine.Ĭopy just the MBR and boot sector of a floppy to hard drive image:ĭd if=/dev/fd0 of=/home/sam/MBRboot.image bs=512 count=2

Do:ĭd if=/home/sam/insert.iso of=/dev/sdb ibs=4b obs=1b conv=notrunc,noerror Look where the new drive is, sdb, or something similar.
#Dev dd wikipedia download#
To make a bootable USB thumb drive: Download 50 MB Debian based distro here: Now you have a shell script for seven passes of random characters over the whole disk Do: #!/bin/bash for n in `seq 7` do dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc done The second example uses default "bs=" of 512, which is the sector size of a floppy.If you're concerned about spies with superconducting quantum-interference detectors you can always add a "for" loop for government level secure disk erasure: copy and paste the following two lines into a text editor. This makes a hard drive image of the floppy, with bootable info intact. This issues a single 1474560-byte read request to /dev/fd0 and a single 1474560 write request to /home/sam/floppy.image. The 18b specifies 18 sectors of 512 bytes, the 2x multiplies the sector size by the number of heads, and the 80x is for the cylinders-a total of 1474560 bytes. Then the file system will be viewable as files and directories in the directoryĭd if=/dev/fd0 of=/home/sam/floppy.image bs=2x80x18b conv=notruncĭd if=/dev/fd0 of=/home/sam/floppy.image conv=notrunc home/sam/mycd.iso /mnt/mycd iso9660 rw,user,noauto 0 0 The result will be a hard disk image file of the CD. So, if you have room for the data, and the zeroes get truncated that's ok.ĭd if=/dev/hdc of=/home/sam/mycd.iso bs=2048 conv=notrunc The very last part of the drive is usually zeroes. What you want to do is this:ĭd if=/dev/sda3 of=/dev/sda2 bs=4096 conv=notrunc,noerror Now, if you are copying sda3 to sda2, this is different. Mount -o loop /home/sam/smaller_partition.img /mnt/directory cd /mnt/directory cp -r * /mnt/larger_partition_already_partitioned_and_formatted_to_the_size_you_wantĬp has an -r switch for recursive copy. The way around this is to build a partition image file.ĭd if=smaller_partition of=/home/sam/smaller_partition.img If you dd a smaller partition to a larger one the larger one will now be formatted the same as the smaller one and there won't be any space left on the drive. This is because fdisk reads the partition table and df reads the format info. If you are copying a smaller partition to a larger one, the larger partition will read the correct size with: The first 63 sectors of a drive are empty, except sector 1, the MBR. You don't want to tell a drive it is bigger than it really is by writing a partition table from a larger drive to a smaller drive. By doing this, you leave the first 8k bytes (4k*2 bs, bs applies to both seek and/or skip) on each drive untouched. Seek skips over so many blocks on the output media before writing (sdb).

Skip skips input blocks at the beginning of the media (sda). If you are copying sda to sdb, an entire drive with a single partition, sdb being smaller than sda, then you have to do:ĭd if=/dev/sda skip=2 of=/dev/sdb seek=2 bs=4k conv=noerror The only difference between a big partition and a small partition, besides size, is the partition table. You can write a blank disk to a good disk if you get confused. If sdb2 doesn't exist, dd will start at the beginning of the disk, and create it. This feature has inspired the nickname "dd" Data Destroyer.Įxamples: Copy one hard disk partition to another hard disk:ĭd if=/dev/sda2 of=/dev/sdb2 conv=notrunc,noerror

Warning!! If you reverse the source and target, you can wipe out a lot of data. The basic command is structured as follows:ĭd if= of= bs=("USUALLY" some power of 2, not less than 512 bytes(ie, 512, 1024, 2048, 4096, 8192, 16384, but can be ANY reasonable number.) skip= seek= conv=. It is a bitstream duplicator for copying data, but can use input or output pipes to another command.
