Mounting Disk Images


You can mount a disk image and access the image just as you would a disk partition. This is very useful for those times you want to extract a few files from an ISO image, without burning the image to CD-ROM and mounting it, or if you want to edit a floppy disk image. Mounting a disk image file has two steps. First, you need to attach disk image to a device node. Then, you can mount that device node as you would any other device.

OpenBSD provides the vnconfig(8) program to attach disk images to device nodes. Remember, a vnode is an abstraction layer between the kernel and a file system. vnconfig(8) tells the kernel that a file should have vnodes attached to it and which device node those vnodes should be accessible through.

Vnode Device Nodes

OpenBSD provides both standard and raw device nodes for vnode devices. The standard buffered vnode device nodes are /dev/svnd*, while the raw vnode device nodes are /dev/vnd*. All of the mount programs use buffered device nodes, so that's the sort of node you want to use.

If you look at the device nodes in /dev, you will notice that each of these device nodes has partition letters after it. Once the image is associated with a vnode, partitions within the disk will be available at the usual partition letters under the device node. For your initial steps, you will want to use the "c" partition that represents the whole disk, just as in disklabel(8).

The GENERIC kernel has four vnode devices. If you need to mount more than four disk images simultaneously, you will need to build a custom kernel.

Running vnconfig(8) and mount(8)

Vnconfig(8) takes two arguments, the node you want to use and the disk image you want to mount. Here, we mount a the floppy disk image /tmp/floppy33.fs on the vnode device /dev/svnd0.

 # vnconfig /dev/svnd0c /tmp/floppy33.fs 

This disk image is now tied to the device node /dev/svnd0.. You can mount it just as you would any other floppy disk device node.

 # mount /dev/svnd0c /mnt 

You can now access the contents of the disk image under /mnt.

Mount(8) cannot guess what sort of image is inside a disk image, so you must use the correct mount command. For example, if you're mounting an ISO, you must use mount_cd9660(8) instead of vanilla mount(8).

Disconnecting Disk Images

The svnd0c device will remain attached to this particular image until you tell it otherwise. You can mount and unmount the same image repeatedly using the same vnode device, but you cannot use the same vnode device for another file. Disconnect a vnode device from any disk image with vnconfig's "-u" flag.

 # vnconfig -u /dev/svnd0c 

You can now attach this vnode device to another image.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net