# How do I verify a FreeBSD installation ISO image burned (or written) to a USB stick?



## ikevin8me (Jul 2, 2021)

How do I verify a FreeBSD installation ISO image (ie. FreeBSD-13.0-RELEASE-amd64-dvd1.iso) burned --- or written  - to a USB stick?

The USB stick is created by the following command:
`#  dd if=FreeBSD-13.0-RELEASE-amd64-dvd1.iso of=/dev/da0 bs=1m conv=sync`

I've tried by issuing the following commands and the checksum is different from the downloaded original ISO file.
`#  md5 FreeBSD-13.0-RELEASE-amd64-dvd1.iso`
RESULT is: = e20b9dd4270da6bf4db9cf9f7675e3a8

Method #1
`#  dd if=/dev/da0 bs=1m | head -c 4784017408 | md5`

... and 

Method #2
`#  dd if=/dev/da0 of=/check/FreeBSDcheck.iso bs=4096 count=1167973 conv=sync`
`#  md5 /check/FreeBSDcheck.iso`

Both Methods #1 and #2 produced the same checksum, but it is *different* from the downloaded original.

I'd like to know how to verify whether a burned USB stick is the same as download original ISO file.


----------



## Tieks (Jul 2, 2021)

ikevin8me said:
			
		

> Both Methods #1 and #2 produced the same checksum, but it is *different* from the downloaded original.



Methods 1 and 2 cannot give you the same result as the md5 checksum from the original .iso file. The latter is a checksum from a file only. Methods 1 and 2 give you a checksum over a complete flash disk, that includes all partition and file system stuff. However, the fact that method 1 and method 2 give you the same result is imho a very good indication that both were correct.


----------



## ikevin8me (Jul 2, 2021)

Tieks said:


> Methods 1 and 2 cannot give you the same result as the md5 checksum from the original .iso file. The latter is a checksum from a file only. Methods 1 and 2 give you a checksum over a complete flash disk, that includes all partition and file system stuff. However, the fact that method 1 and method 2 give you the same result is imho a very good indication that both were correct.


So, how do I get the same result as the original .iso file?


----------



## Tieks (Jul 2, 2021)

Getting the same checksum could be difficult, because file systems cd9660/UDF differ from file systems UFS and MSDOSFS. You need to get that part out of the equation.
To make sure that all files are the same you can mount both the flash drive and the .iso (using something like `mdconfig -a -t vnode -o readonly -f <your-iso-file> -u 9 ; mount -t cd9660 /dev/md9 <your-mount-point>`).
Once both are mounted, you can use `mtree` to compare the contents, that is, all files and directories. I suppose that is what you want to know.


----------



## ikevin8me (Jul 2, 2021)

That sounds like comparing the contents inside. I copied and mounted another disk image (using mdconfig) and, compared with the the plugged-in USB stick using “diff”. Strange enough, it found 2 files “missing”. On examination, the files weren’t missing, but with an @-sign added after the filename (when I tried by “cd “ to the directory and pressing tab to list thr possible files.)


----------



## Tieks (Jul 2, 2021)

These two files were probably symlinks. Don't know how diff handles symlinks, `man diff` doesn't say much about it. If these were valid symlinks and diff found no other differences then you know that USB stick and .iso file are indeed identical on file system level. Good to know.


----------



## CuatroTorres (Jul 2, 2021)

I'd be more interested in checking the integrity of the .md5 file using the signature than the checksum itself, which will only tell you if you've downloaded the file successfully and the installation media is supposedly valid. You could even check the signature of the .asc file.
You can avoid `diff` with `md5 -c file.md5` as long as the .iso file is in the same directory.
If you are moving the installation media out of your home, you would check the fs (`fsck`) and initially run the installer to verify the media. Which can be a simple method.


----------



## VladiBG (Jul 2, 2021)

Don't copy the ISO to the USB. You need to download the FreeBSD-13.0-RELEASE-amd64-mini-memstick.img or FreeBSD-13.0-RELEASE-amd64-memstick.img if you need to use USB.


			Index of /ftp/releases/amd64/amd64/ISO-IMAGES/13.0/


----------



## CuatroTorres (Jul 2, 2021)

Could this question come from choosing the wrong medium and not a problem in itself? Can it be closed?









						Why does a USB flash disk refuse to boot? A great mystery...
					

I'm experiencing something strange the two USB flash disks: (1) an 8GB USB flash disk (2) an 16GB USB flash disk ... both are from the same manufacturer.  I downloaded FreeBSD-13.0-RELEASE-amd64-dvd1.iso using a Mac, and executed the same command below to write to the two USB flask disks: # dd...




					forums.freebsd.org


----------



## VladiBG (Jul 3, 2021)

you can't copy ISO9660 or ISO13346 (UDF) file system on USB disk it won't work. USB disk must have partition scheme with supported bootable partition. The installation image file (img) has MBR scheme with FAT32 (EFI) boot partition and UFS so when you write this image on the USB it actually create the partition scheme on the USB disk.


----------



## ikevin8me (Jul 3, 2021)

Thanks for your info. I'll keep it in mind. However, it is just that I copied the FreeBSD...dvd1.iso to USB disk and it works. This questions is related to my other post.

The *problem* of the memstick.img is it doesn't contain more packages (esp. the desktop env).


----------

