If you ever happen to mount a .iso file on OpenBSD, you may wonder how to proceed as the command `mount_cd9660` requires a device name.
While the solution is entirely documented into man pages and in the official FAQ, it may not be easy to find it at first glance, especially since most operating system allow to mount an iso file in a single step where as OpenBSD requires an extra step.
OpenBSD FAQ: Mounting disk images
OpenBSD manual page: vnconfig(8) EXAMPLES section
Note that this method does also work for disk images, not only .iso files.
On OpenBSD you need to use the command `vnconfig` to map a file to a device node, allowing interesting actions such as using a file as a storage disk (which you can encrypt) or mounting a .iso file.
This command must be used as root as it manipulates files in /dev.
Now, let's see how to mount a .iso file, which is a dump of a CD9660 file (most of the time):
vnconfig vnd0 /path/to/file.iso
This will create a new device `/dev/vnd0`, now you can mount it on your file-system with:
mount -t cd9660 /dev/vnd0c /mnt
You should be able to browser your iso file content in /mnt at this point.
If you are done with the file, you have to umount it with `umount /mnt` and destroy the vnd device using `vnconfig -u vnd0`.
If you want to use a single file as a file system, you have to provision the file with disk space using the command `dd`, you can fill it with zeroes but if you plan to use encryption on top of it, it's better to use random data. In the following example, you will create a file `my-disk.img` of a size of 10 GB (1000 x 10 MB):
dd if=/dev/random of=my-disk.img bs=10M count=1000
Now you can use vnconfig to expose it as a device:
vnconfig vnd0 my-disk.img
Finally, the command `bioctl` can be used to configure encryption on the disk, `disklabel` to partition it and `newfs` to format the partitions. You can follow OpenBSD FAQ guides, make sure use the the device name `/dev/vnd0` instead of wd0 or sd0 from the examples.