Leaderboard (728 x 90)

Thursday, May 6, 2010

How do I mount an ISO image in Virtuozzo container?

In Parallels Virtuozzo Containers 4.0 you may use FUSE (filesystem in userspace) to mount ISO image inside a container.

1. Make sure that 'fuse' module is loaded on hardware node:

~# lsmod | grep fuse

If it is not there, use:

~# modprobe fuse
~# lsmod|grep fuse
fuse 45320 0

In case you would like to load 'fuse' module automatically before starting the service 'vz' please implement init script '/etc/rc.modules' on your node, as described in the article:

---8<--- http://kb.parallels.com/en/696
...
In order to automate modules loading before Virtuozzo services are started you may install 'openvpn' package from Virtuozzo distrib (in HW/RPMS directory) and enable it in default runlevel (use 'chkconfig' utility to do that). Please also use instructions on automated module loading suitable for base OS installed on hardware node.
Just for example, for RedHat-based systems (such as Fedora Core, RedHat AS3/AS4, CentOS 3/4) it should be enough to add 'modprobe tun' command into /etc/rc.modules file and make it executable:

# chmod a+rx /etc/rc.modules
--->8---


and then put the command 'modprobe fuse' inside the file.

After that please restart the hardware node to make sure that 'fuse' module is loaded correctly before the service 'vz'.

2. Grant a container #101 the permission to work with /dev/fuse character device and create corresponding device inside a container (run these commands on Virtuozzo server):

~# vzctl set 101 --devices c:10:229:rw --save
~# vzctl exec 101 mknod -m 666 /dev/fuse c 10 229
~# vzctl exec 101 cp -a /dev/fuse /lib/udev/devices/


In case the file /dev/fuse already exist please make sure it has proper access permissions. Also if the directory '/lib/udev/devices' does not exist, please create it and set correct access permissions:

# vzctl exec 101 mkdir /lib/udev/devices
# vzctl exec 101 chmod 755 /lib/udev/devices/



Check these files:

~# vzctl exec 101 ls -l /lib/udev/devices/fuse
crw-rw-rw- 1 root root 10, 229 Oct 25 19:37 /lib/udev/devices/fuse

# vzctl exec 101 ls -l /dev/fuse
crw-rw-rw- 1 root root 10, 229 Oct 25 19:37 /dev/fuse


3. Install packages fuseiso and fuse into container. Names of packages may be different on different Linux distributions: for Debian and Ubuntu install fuseiso and fuse-utils packages (available in repository) for RHEL/CentOS 3/4/5 use DAG's packages fuse-iso and fuse for Fedora 7/8 both fuseiso and fuse are available from the main/updates repositories for Fedora 6, fuse is available from extras repo, use dries for fuse-iso To mount an ISO image run the command inside a container:

~# fuseiso IMAGE.iso /mnt

Replace IMAGE.iso in the command above with the exact name of ISO image (including path) on filesystem, replace /mnt with path where you want ISO image to be mounted.

To umount image use this command:

~# fusermount -u /mnt

Again - replace /mnt with exact path where ISO image was mounted.

Reference: http://kb.parallels.com/en/4628

How to allow container to use device on hardware node in Virtuozzo Container?

Make sure the device has been already loaded on the hardware node using lsmod. If doesn't load, using modprobe command to load it.

Example:
# lsmod | grep tun
If it is not there, use
# modprobe tun


run the command on hardware node
vzctl set 101 --devices c:10:200:rw --save

where

101 means container ID 101 will be granted permissions to use the device
c:10:200:rw means allow read/write permissions over character device with major number 10 and minor number 200

Then run the command
vzctl exec 101 mknod /dev/net/tun c 10 200

where /dev/net/tun
is device file for character device with major number 10 and minor number 200

Check for major number and minor number of the device for devices.txt in kernel documentation.