Malmö 09.12.2012
dd is the Unix program for low-level copying and conversion of raw data. It is both in busybox and GNU coreutils - so already is available in all systems based on Linux and Unix even them on LiveCD. Disk copying
dd if=/dev/sda of=/dev/sdbPartition copying
dd if=/dev/sda1 of=/dev/sda2CD 1:1 copy
dd if=/dev/scd0 of=/home/$USER/image.isoCopy the compressed disk over the network with netcat from computer A to B: ComputerA
# dd if=/dev/sdb |gzip |nc 192.168.1.10 5555ComputerB
$ nc -l 5555 > disk-kopia.img.gzCopy the raw data to floppy
dd if=/home/floppy.img of=/dev/fd0Copying MBR:
dd if=/dev/sda of=/home/kopia_mbr bs=512 count=1Erase the entire hard drive by overwriting with random data
dd if=/dev/urandom of=/dev/sdbI have created a file with the limited size that I use as upload folder. Even if bad guy breaks passwords can not fill up the entire partition. Create a file size 1G - (copy from /dev/zero works faster):
dd if=/dev/zero of=/home/file bs=512 count=2097152Create filesystem on the file (I choose ext.3):
mkfs.ext3 /home/fileCreate a mount directory:
mkdir -p /www/uploadMount the file in mount directory:
mount -o loop /home/file /www/upload/You can create and activate 512MB swap file:
dd if=/dev/zero of=/swap bs=512 count=1048576 mkswap /swap swapon /swapand add to /etc/fstab if you want it permanently:
/swap swap swap defaults 0 0How to calculate file size: It all depends on block size (bs value) and number of blocks (count value). Default block size of the system is 512b but you can create other value - eg 1024 (possibly 1M). For bs = 512 there is: the size in MB multiply by 1024 ² and divided by 512. For 128MB file:
128×1024²÷512