Date created: Friday, March 12, 2021 8:36:01 AM. Last modified: Sunday, April 30, 2023 4:26:45 PM

'dd' Notes

dd commands:

Dump CD to ISO

$ dd if=/dev/cdrom of=/tmp/cdimg1.iso

Generate 10GBs

$ dd if=/dev/zero of=/tmp/image bs=1M count=10000

To view dd progress with more recent dd:

$ time sudo dd status=progress if=ubuntu-18.04.3-4.9-minimal-odroid-n2-20190806.img of=/dev/mmcblk0

To view dd progress in a separate terminal (for older dd):

$ pgrep -l '^dd$'
4858 dd
$ kill -USR1 4858

The progress will be dumped in terminal window where dd is running. Use watch to have continuous output:

$ watch -n 60 'sudo kill -USR1 4858'

To compress a drive copy:

dd if=/dev/hdb | gzip -c > /image.img

To restore a compressed drive copy:

gunzip -c /image.img.gz | dd of=/dev/hdb

Zero out free space on a drive before copying into gzip for better compression:

mkdir /mnt/hdb
mount /dev/hdb /mnt/hdb
dd if=/dev/zero of=/mnt/hdb/zero
rm /mnt/hdb/zero
umount /mnt/hdb
dd if=/dev/hdb | gzip -c > /image.img

Faster copy:

bs=100M conv=notrunc

Previous page: 'curl' Notes
Next page: 'dig' - Notes