Exporting ISO filesystems to save disk space
Grenville Armitage
June 23rd, 2002

FreeBSD's vnconfig command allows us to create a mountable "cd9660" filesystem from an on-disk binary ISO image. So, for example, you can download the latest FreeBSD or RedHat CDROM images and export their contents without actually burning a CDROM and copying the entire file system back to your harddrive.
vnconfig can halve the amount of diskspace you need on a fileserver suppling access to both the ISO images and the full filesystem inside the ISO.

Creating a mountable filesystem

From FreeBSD 4.4 (and perhaps earlier - I haven't checked) the vnconfig command has allowed us to create new filesystems from regular, on-disk files. The new filesystems are vnode disks, and become accessible through special vn devices. These vn disks are then mountable using the regular mount command. Mounting ISOs is only one of vnconfig's uses, others can be found in the man page.

Assume you have the lastest FreeBSD4.6 disk1 ISO image at /home/freebsd/4.6-disc1.iso, and you want to access it as a regular filesystem. The first step is to create a vnode disk equivalent:
/usr/sbin/vnconfig vn0 /home/freebsd/4.6-disc1.iso
A new cd9660 filesystem is now available on /dev/vn0c, and can be mounted with the following:
/sbin/mount_cd9660 /dev/vn0c /mnt/freebsd46
(The last parameter, /mnt/freebsd46, can be any convenient mount point inside your current directory structure.)

You can now access /mnt/freebsd46 like any other mounted filesystem, including NFS exporting it to other machines on your network, and you've only used the disk space required to hold the ISO itself.

'df' shows:
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
/dev/vn0c      591520   591520        0   100%    /mnt/freebsd46

Adding more vnode filesystems

Additional ISOs can be vnconfig'ed and mounted, but remember to create new /dev/vn special devices for each filesystem. For example, the following creates vnode disk 1:
cd /dev
If you happened to have FreeBSD4.6 disk2 ISO image at /home/free, you would then additionally mount it as:
/usr/sbin/vnconfig vn1 /home/freebsd/4.6-disc2.iso
/sbin/mount_cd9660 /dev/vn1c /mnt/freebsd46-2
(Additional vnode special devices are created with ./MAKEDEV vnX)


The regular umount command is sufficient. To unmount the first example above, just use:
/sbin/umount /mnt/freebsd46
If you wish to reuse the vnode disk, you then need to de-construct the vnode filesystem with:
/usr/sbin/vnconfig -u vn0

Creating a special vnode filesystem and mounting it can be combined into one operation with the "-e" flag. The following line is equivalent to the first example above:
/usr/sbin/vnconfig -e vn0 /home/freebsd/4.6-disc1.iso  mount=/mnt/freebsd46