Difference between revisions of "Mounting filesystems"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(simplify)
(Info about mount on start)
Line 5: Line 5:
 
* [[Bind mounts]] from Hardware Node
 
* [[Bind mounts]] from Hardware Node
  
Also, you can grant a container an access a physical block device, and use that device from inside the container. Not all file systems are working inside a container; check /proc/filesystems inside a container to find out.
+
Also, you can grant a container an access a physical block device, and use that device from inside the container. Not all file systems are working inside a container; check /proc/filesystems inside a container to find out.
 +
 
 +
=Mount filesystem on VE start=
 +
 
 +
You need to create mount script in openvz configuration directory (/etc/vz/conf) with name <veid>.mount. If you need to mount filesystem to all containers than name of script should be vps.mount and inside script ${VEID} variable can be used.
 +
 
 +
Example:
 +
<pre>#!/bin/bash
 +
mount --bind /mnt/disk /vz/root/${VEID}/mnt/disk
 +
exit ${?}</pre>
 +
 
 +
For unmounting filesystem file vps.umount can be used.
 +
 
 +
Example:
 +
<pre>#!/bin/bash
 +
umount /vz/root/${VEID}/mnt/disk
 +
exit 0</pre>
 +
 
 +
''Notice:''
 +
<veid>.umount scripts are not very necessary: everything will be umounted automatically on VE stop. But you should than mount with -n option in mount script.

Revision as of 06:16, 28 May 2009

To mount a file system inside a container, you have several choices:

  • NFS, when container as an NFS client
  • FUSE (filesystem in userspace)
  • Bind mounts from Hardware Node

Also, you can grant a container an access a physical block device, and use that device from inside the container. Not all file systems are working inside a container; check /proc/filesystems inside a container to find out.

Mount filesystem on VE start

You need to create mount script in openvz configuration directory (/etc/vz/conf) with name <veid>.mount. If you need to mount filesystem to all containers than name of script should be vps.mount and inside script ${VEID} variable can be used.

Example:

#!/bin/bash
mount --bind /mnt/disk /vz/root/${VEID}/mnt/disk
exit ${?}

For unmounting filesystem file vps.umount can be used.

Example:

#!/bin/bash
umount /vz/root/${VEID}/mnt/disk
exit 0

Notice: <veid>.umount scripts are not very necessary: everything will be umounted automatically on VE stop. But you should than mount with -n option in mount script.