The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
mounting an ISO image 2 September 2000
Need more help on this topic? Click here
This article has 5 comments
Show me similar articles
This is how to mount an ISO image. Actually, it can be used for other images as well. See the note at the end of this article for details.

If you have just created an ISO image, say with mkisofs, there is a way to mount the image and view it without creating a CD ROM.  Let's assume you have an ISO image named image.iso and it resides in the current directory.

FreeBSD 4.x

vnconfig /dev/vn0c ./image.iso
mount -t cd9660 /dev/vn0c /cdrom

When you're finished with the image, here's how you reverse the above:

umount /cdrom
vnconfig -u /dev/vn0c

Thanks to Odinn for asking about this and to blackend for coming up with it.

FreeBSD >= 5.x

As pointed out by Jim Salter in his comment and by Irritum Nihil via email, the above became deprecated in FreeBSD 5.x. Instead, you should do this:

mdconfig -a -t vnode -f /path/to/image.iso -u 1
mount -t cd9660 /dev/md1 /mnt/cdrom

To reverse the process:

mount -u /mnt/cdrom
mdconfig -d -u 1

In all cases....

NOTE: Once mounted, you cannot write to your ISO image. ISO images are readonly by design. If you want to change what is in your ISO image, use mkisofs. If you didn't create the ISO, then you could mount the image, copy everything from the image to disk, then use mkisofs to create a new ISO.

mounting any image 4 September 2000
After a question on undernet #FreeBSD, I realised that the above method can be used for any image.  As such, I've added the following note.

If you want to mount, say an msdos image, you could do it like this:

vnconfig /dev/vn0c ./image.iso
mount -t msdos /dev/vn0c /cdrom

And use the same steps as shown in the previous section to umount it.  Have a look at man mount for the various image types which you can mount.

Need more help on this topic? Click here
This article has 5 comments
Show me similar articles