dd is a great tool to do a raw (or binary) copy of a storage device or a file.
Basic dd usage
In most cases this command will do the trick.
dd if=/path/to/source of=/path/to/destination status=progress
You may optimize the block size according to your source/destination (it depends…) device for improved copy speed, with the bs=... command line switch.
Create an ISO image from a CD/DVD
CDs and DVDs have blank bytes at the end and those may break your checksum and bloat your image file.
Get ISO informations to know the real size.
isoinfo -d -i /dev/cdrom
Lines Logical block size is: 2048 and Volume size is: 187723 contain the information we need for dd.
Launch the copy with the values gathered above.
dd if=/dev/cdrom of=cdrom.iso bs=2048 count=187723 status=progress
Create an image of a 1.44MB floppy disk
DOS sector size is 512 bytes. My USB floppy drive shows up as /dev/sda.
dd if=/dev/sda of='floppy.img' bs=512 status=progress