Sep 022000
 

mounting an ISO image

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 (added on 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.

  5 Responses to “mounting an ISO image”

  1. If you get this error, remember to read <A HREF="/phorum/read.php?f=1&i=3084&t=3084">this thread</A> in the phorum.

  2. vnconfig is no longer used in 5.x. To mount an image under FreeBSD 5.x, you’ll need to do something like this:

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

    note that -u 1 matches up with /dev/md1. If you needed to mount more than one device this way, you would use -u x with /dev/mdx as appropriate.

    To dismount the ISO and destroy the virtual device (thus allowing you to do things like write to the ISO file), you would issue the following:

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

    Hope that helps some folks…

  3. To do this in FreeBSD 5 this is the way:
    mdconfig -a -t vnode -f cdrom.iso
    mount -t cd9660 /dev/md0 /cdrom
    <snip>
    umount /cdrom
    mdconfig -d -u 0

  4. FreeBSD6.3

    iso file is saved on disk at ~test/
    to mount this file run following two commands as root user.

    mdconfig -a -t vnode -u 10 -f ~test/6.3-RELEASE-i386-docs.iso

    then

    mount_cd9660 /dev/md10 /media/

    iso image is mounted.
    confirm by

    # mount |grep medi
    /dev/md10 on /media (cd9660, local, read-only)

    anuj.

    [%sig%]

    Post Edited (24-02-08 18:36)