How to mount ISO or file disk images on OpenBSD

=> Comment on Mastodon

Introduction

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.

Exposing a file as a device

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.

Mounting an ISO file

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.

Unmounting

If you are done with the file, you have to umount it with umount /mnt and destroy the vnd device using vnconfig -u vnd0.

Going further: Using a file as an encrypted disk

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.

=> OpenBSD FAQ: Encrypting external disk

Proxy Information
Original URL
gemini://perso.pw/blog//articles/mount-iso-file-openbsd.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
140.586091 milliseconds
Gemini-to-HTML Time
0.735839 milliseconds

This content has been proxied by September (3851b).