Difference between revisions of "Ploop/Getting started"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Requirements)
(Marked this version for translation)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
<translate>
 +
<!--T:1-->
 
This article describes how to use container-in-a-file technology aka [[ploop]]
 
This article describes how to use container-in-a-file technology aka [[ploop]]
  
== Requirements ==
+
== Requirements == <!--T:2-->
  
 +
<!--T:3-->
 
The following is required for ploop to work:
 
The following is required for ploop to work:
  
 +
<!--T:4-->
 
# [[Download/kernel/rhel6|RHEL6-based OpenVZ kernel]], i.e. 042stabXXX.
 
# [[Download/kernel/rhel6|RHEL6-based OpenVZ kernel]], i.e. 042stabXXX.
 
# <code>/vz</code> partition formatted as <code>ext4</code> and mounted in ordered mode, or residing on NFSv3. No other filesystem is supported.
 
# <code>/vz</code> partition formatted as <code>ext4</code> and mounted in ordered mode, or residing on NFSv3. No other filesystem is supported.
 
# ploop library and tools installed (run <code>yum install ploop</code>).
 
# ploop library and tools installed (run <code>yum install ploop</code>).
  
== Making a CT on ploop ==
+
== Making a CT on ploop == <!--T:5-->
  
=== Global configuration ===
+
=== Global configuration === <!--T:6-->
  
 +
<!--T:7-->
 
In global VZ configuration file [[Man/vz.conf.5|/etc/vz/vz.conf]], set
 
In global VZ configuration file [[Man/vz.conf.5|/etc/vz/vz.conf]], set
  
  VE_LAYOUT=ploop  
+
  <!--T:8-->
 +
VE_LAYOUT=ploop  
  
 +
<!--T:9-->
 
This means that all new containers you will create will have ploop layout by default.
 
This means that all new containers you will create will have ploop layout by default.
  
 +
<!--T:10-->
 
You don't have to set this option if you don't want ploop to be default. Alternatively, you can:
 
You don't have to set this option if you don't want ploop to be default. Alternatively, you can:
  
 +
<!--T:11-->
 
* use <code>--layout</code> option of <code>vzctl create</code> command;
 
* use <code>--layout</code> option of <code>vzctl create</code> command;
 
* convert existing container to ploop.
 
* convert existing container to ploop.
  
=== Creating a new CT ===
+
=== Creating a new CT === <!--T:12-->
  
 +
<!--T:13-->
 
To create a new container on ploop, use:
 
To create a new container on ploop, use:
  
  vzctl create ''CTID'' [--layout ploop] [--diskspace ''nnn''G] [--diskinodes ''mmm'']
+
  <!--T:14-->
 +
vzctl create ''CTID'' [--layout ploop] [--diskspace ''nnn''G] [--diskinodes ''mmm'']
  
 +
<!--T:15-->
 
# You can omit <code>--layout</code> option if you have set <code>VE_LAYOUT=ploop</code> in {{Man|vz.conf|5}}
 
# You can omit <code>--layout</code> option if you have set <code>VE_LAYOUT=ploop</code> in {{Man|vz.conf|5}}
 
# You can specify initial file system size using <code>--diskspace</code> option (example: 10G for 10 gigabytes)
 
# You can specify initial file system size using <code>--diskspace</code> option (example: 10G for 10 gigabytes)
Line 35: Line 47:
 
# If <code>--diskinodes</code> is not specified, 1 inode per 16K of disk space will be created (see [[../diskinodes/]] for more info)
 
# If <code>--diskinodes</code> is not specified, 1 inode per 16K of disk space will be created (see [[../diskinodes/]] for more info)
  
=== Converting an existing CT ===
+
=== Converting an existing CT === <!--T:16-->
  
 +
<!--T:17-->
 
1. Stop the container:
 
1. Stop the container:
 
  vzctl stop ''CTID''
 
  vzctl stop ''CTID''
  
 +
<!--T:18-->
 
2. Set some sane diskspace value, and reset the [[../diskinodes/]] value. New value for diskspace will be used as a size of newly created ploop image. Here is the example to set diskspace to 10 gigabytes:
 
2. Set some sane diskspace value, and reset the [[../diskinodes/]] value. New value for diskspace will be used as a size of newly created ploop image. Here is the example to set diskspace to 10 gigabytes:
 
  vzctl set ''CTID'' --diskspace 10G --diskinodes 0 --save
 
  vzctl set ''CTID'' --diskspace 10G --diskinodes 0 --save
  
 +
<!--T:19-->
 
3. Convert:
 
3. Convert:
 
  vzctl convert ''CTID''
 
  vzctl convert ''CTID''
  
 +
<!--T:20-->
 
4. Once your CT is well tested, you can free disk space by removing files that may have remained from the old container file system in /vz/root/''CTID''. VERY CAREFULLY (and after testing your converted container) you can stop, remove old files and start container again, e.g.:
 
4. Once your CT is well tested, you can free disk space by removing files that may have remained from the old container file system in /vz/root/''CTID''. VERY CAREFULLY (and after testing your converted container) you can stop, remove old files and start container again, e.g.:
 
  vzctl stop ''CTID''
 
  vzctl stop ''CTID''
Line 51: Line 67:
 
  vzctl start ''CTID''
 
  vzctl start ''CTID''
  
== Resizing a ploop image ==
+
== Resizing a ploop image == <!--T:21-->
  
 +
<!--T:22-->
 
Ploop image can be resized in both directions (i.e. either shrank or grown). Ploop also supports online/live resize so you don't have to stop a CT to do resize.
 
Ploop image can be resized in both directions (i.e. either shrank or grown). Ploop also supports online/live resize so you don't have to stop a CT to do resize.
  
 +
<!--T:23-->
 
To resize a ploop CT image, use
 
To resize a ploop CT image, use
  
  vzctl set ''CTID'' --diskspace ''nnn''G --save
+
  <!--T:24-->
 +
vzctl set ''CTID'' --diskspace ''nnn''G --save
  
 +
<!--T:25-->
 
Note that
 
Note that
 
* resize can safely be performed online (i.e. when container is running)
 
* resize can safely be performed online (i.e. when container is running)
Line 64: Line 84:
 
* there is no way to limit or change the number of inodes available for an existing container (i.e. option <code>--diskinodes</code> is ignored); see [[../diskinodes/]] for more details
 
* there is no way to limit or change the number of inodes available for an existing container (i.e. option <code>--diskinodes</code> is ignored); see [[../diskinodes/]] for more details
  
== Showing disk space usage / limits ==
+
== Showing disk space usage / limits == <!--T:26-->
  
 +
<!--T:27-->
 
You can use {{Man|vzlist|8}} to see CT disk space usage and limits in a uniform way for any containers (simfs or ploop, started or stopped).
 
You can use {{Man|vzlist|8}} to see CT disk space usage and limits in a uniform way for any containers (simfs or ploop, started or stopped).
  
 +
<!--T:28-->
 
The field '''diskspace''' is showing the current disk space usage, and the fields '''diskspace.s''' and '''diskspace.h''' are showing the filesystem size (or disk space quotas, for simfs case).
 
The field '''diskspace''' is showing the current disk space usage, and the fields '''diskspace.s''' and '''diskspace.h''' are showing the filesystem size (or disk space quotas, for simfs case).
  
 +
<!--T:29-->
 
The field '''diskinodes''' is showing the current inodes usage, and the fields '''diskinodes.s''' and '''diskinodes.h''' are showing the filesystem size (or disk inodes quotas, for simfs case).
 
The field '''diskinodes''' is showing the current inodes usage, and the fields '''diskinodes.s''' and '''diskinodes.h''' are showing the filesystem size (or disk inodes quotas, for simfs case).
  
 +
<!--T:30-->
 
Examples:
 
Examples:
  
  vzlist -o smart_name,diskspace.h,diskspace
+
  <!--T:31-->
 +
vzlist -o smart_name,diskspace.h,diskspace
 
  vzlist -o smart_name,diskinodes.h,diskinodes
 
  vzlist -o smart_name,diskinodes.h,diskinodes
  
 +
<!--T:32-->
 
On a lower level, same info can be obtained via '''ploop info''' command:
 
On a lower level, same info can be obtained via '''ploop info''' command:
  
  ploop info /vz/private/501/root.hdd/DiskDescriptor.xml
+
  <!--T:33-->
 +
ploop info /vz/private/501/root.hdd/DiskDescriptor.xml
  
== Using disk quotas inside container ==
+
== Using disk quotas inside container == <!--T:34-->
  
 +
<!--T:35-->
 
If you want to use standard Linux per-user and per-group disk quota inside a container, you have to enable it using
 
If you want to use standard Linux per-user and per-group disk quota inside a container, you have to enable it using
  
  vzctl set ''CTID'' --quotaugidlimit 1000 --save
+
  <!--T:36-->
 +
vzctl set ''CTID'' --quotaugidlimit 1000 --save
  
 +
<!--T:37-->
 
Note that:
 
Note that:
 
* unlike with simfs, <code>--quotaugidlimit</code> argument can be any non-zero value;
 
* unlike with simfs, <code>--quotaugidlimit</code> argument can be any non-zero value;
 
* enabling or disabling in-container disk quotas requires a container restart, so you might find <code>--setmode</code> option helpful.
 
* enabling or disabling in-container disk quotas requires a container restart, so you might find <code>--setmode</code> option helpful.
  
 +
<!--T:38-->
 
See {{Man|vzctl|8}} for more details.
 
See {{Man|vzctl|8}} for more details.
  
== See also ==
+
== See also == <!--T:39-->
  
 +
<!--T:40-->
 
* [[Ploop]]
 
* [[Ploop]]
 
* [[Ploop/backup]]
 
* [[Ploop/backup]]
Line 100: Line 132:
 
* {{Man|vz.conf|5}}
 
* {{Man|vz.conf|5}}
 
* {{Man|vzctl|8}}
 
* {{Man|vzctl|8}}
 +
</translate>
  
 
[[Category: Storage]]
 
[[Category: Storage]]
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]

Latest revision as of 22:30, 25 December 2015

<translate> This article describes how to use container-in-a-file technology aka ploop

Requirements[edit]

The following is required for ploop to work:

  1. RHEL6-based OpenVZ kernel, i.e. 042stabXXX.
  2. /vz partition formatted as ext4 and mounted in ordered mode, or residing on NFSv3. No other filesystem is supported.
  3. ploop library and tools installed (run yum install ploop).

Making a CT on ploop[edit]

Global configuration[edit]

In global VZ configuration file /etc/vz/vz.conf, set

VE_LAYOUT=ploop

This means that all new containers you will create will have ploop layout by default.

You don't have to set this option if you don't want ploop to be default. Alternatively, you can:

  • use --layout option of vzctl create command;
  • convert existing container to ploop.

Creating a new CT[edit]

To create a new container on ploop, use:

vzctl create CTID [--layout ploop] [--diskspace nnnG] [--diskinodes mmm]

  1. You can omit --layout option if you have set VE_LAYOUT=ploop in vz.conf(5)
  2. You can specify initial file system size using --diskspace option (example: 10G for 10 gigabytes)
  3. If --diskspace is not specified, the size defaults to DISKSPACE limit value in sample CT config used
  4. If --diskinodes is not specified, 1 inode per 16K of disk space will be created (see diskinodes for more info)

Converting an existing CT[edit]

1. Stop the container:

vzctl stop CTID

2. Set some sane diskspace value, and reset the diskinodes value. New value for diskspace will be used as a size of newly created ploop image. Here is the example to set diskspace to 10 gigabytes:

vzctl set CTID --diskspace 10G --diskinodes 0 --save

3. Convert:

vzctl convert CTID

4. Once your CT is well tested, you can free disk space by removing files that may have remained from the old container file system in /vz/root/CTID. VERY CAREFULLY (and after testing your converted container) you can stop, remove old files and start container again, e.g.:

vzctl stop CTID
rm -rf /vz/root/CTID;mkdir /vz/root/CTID
vzctl start CTID

Resizing a ploop image[edit]

Ploop image can be resized in both directions (i.e. either shrank or grown). Ploop also supports online/live resize so you don't have to stop a CT to do resize.

To resize a ploop CT image, use

vzctl set CTID --diskspace nnnG --save

Note that

  • resize can safely be performed online (i.e. when container is running)
  • there is no need to specify two values for diskspace (unlike simfs, there is no soft and hard quota).
  • there is no way to limit or change the number of inodes available for an existing container (i.e. option --diskinodes is ignored); see diskinodes for more details

Showing disk space usage / limits[edit]

You can use vzlist(8) to see CT disk space usage and limits in a uniform way for any containers (simfs or ploop, started or stopped).

The field diskspace is showing the current disk space usage, and the fields diskspace.s and diskspace.h are showing the filesystem size (or disk space quotas, for simfs case).

The field diskinodes is showing the current inodes usage, and the fields diskinodes.s and diskinodes.h are showing the filesystem size (or disk inodes quotas, for simfs case).

Examples:

vzlist -o smart_name,diskspace.h,diskspace

vzlist -o smart_name,diskinodes.h,diskinodes

On a lower level, same info can be obtained via ploop info command:

ploop info /vz/private/501/root.hdd/DiskDescriptor.xml

Using disk quotas inside container[edit]

If you want to use standard Linux per-user and per-group disk quota inside a container, you have to enable it using

vzctl set CTID --quotaugidlimit 1000 --save

Note that:

  • unlike with simfs, --quotaugidlimit argument can be any non-zero value;
  • enabling or disabling in-container disk quotas requires a container restart, so you might find --setmode option helpful.

See vzctl(8) for more details.

See also[edit]

</translate>