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/sdb
Partition copying
dd if=/dev/sda1 of=/dev/sda2
CD 1:1 copy
dd if=/dev/scd0 of=/home/$USER/image.iso
Copy the compressed disk over the network with netcat from computer A to B: ComputerA
# dd if=/dev/sdb |gzip |nc 5555
$ nc -l 5555 > disk-kopia.img.gz
Copy the raw data to floppy
dd if=/home/floppy.img of=/dev/fd0
Copying MBR:
dd if=/dev/sda of=/home/kopia_mbr bs=512 count=1
Erase the entire hard drive by overwriting with random data
dd if=/dev/urandom of=/dev/sdb
I 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=2097152
Create filesystem on the file (I choose ext.3):
mkfs.ext3 /home/file
Create a mount directory:
mkdir -p /www/upload
Mount 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 /swap
and add to /etc/fstab if you want it permanently:
/swap           swap         swap          defaults          0     0
How 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: