Exporting ISO filesystems to save disk space

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
 ./MAKEDEV vn1

If you happened to have FreeBSD4.6 disk2 ISO image at /home/freebsd/, 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

Historical note: This blog entry was actually made on June 11th 2012, to archive a web page I wrote on June 2002. Although largely for my own benefit, I’ve archived it in the hope it will be useful to others (like you, if you’re reading this page and you aren’t me).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: