Verifying a CD/DVD against an ISO image

One way of verifying that a CD/DVD matches an ISO image is to calculate a hash sum (e.g. SHA-256) of both the CD/DVD and the ISO image and compare them afterwards.

For the ISO image this could look like that...

$ sha256sum original.iso

...and for the optical drive:

$ sha256sum /dev/cdrom

Though you might get matching hash sums in many cases you won't. This post is about why that happens and how you can compare them the right way.