1) SSH to the OpenVZ/Virtuzzo slave node where the source template container is running.
2) Stop the container via SolusVM interface.
3) Create a directory where you wish to mount the container image, e.g.:
mkdir /24x7template
4) Mount the container image using CTID:
mount -t ploop /vz/private/751/root.hdd/DiskDescriptor.xml /24x7template
Note : In the above example, the CTID is 751, you will need to replaced it with the actual your container ID.
``
[root@server ~]# mount -t ploop /vz/private/751/root.hdd/DiskDescriptor.xml /24x7template
Opening delta /vz/private/751/root.hdd/root.hds
Opening delta /vz/private/751/root.hdd/root.hds
Adding delta dev=/dev/ploop26012 img=/vz/private/751/root.hdd/root.hds (rw)
Mounted /dev/ploop26012p1 at /24x7template fstype=ext4 data=',balloon_ino=12'
[root@server ~]#
```
5) go to the directory, you will see the files like below:
cd /24x7template
```
[root@server ~]# cd /24x7template
[root@server 24x7template]# ls -la
total 100
dr-xr-xr-x 19 root root 4096 Dec 10 21:46 .
dr-xr-xr-x. 22 root root 4096 Dec 10 21:48 ..
drwx--x--x 2 root root 4096 Dec 9 02:00 backup
lrwxrwxrwx 1 root root 7 Mar 12 2019 bin -> usr/bin
dr-xr-xr-x 3 root root 4096 Mar 12 2019 boot
drwxr-xr-x 2 root solusvm 4096 Mar 12 2019 dev
drwxr-xr-x 88 root root 12288 Dec 10 21:45 etc
drwxr-xr-x 5 root root 4096 Dec 8 15:24 home
lrwxrwxrwx 1 root root 7 Mar 12 2019 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Mar 12 2019 lib64 -> usr/lib64
drwx------ 2 root root 16384 Mar 12 2019 lost+found
drwxr-xr-x 2 root root 4096 Apr 10 2018 media
drwxr-xr-x 2 root root 4096 Apr 10 2018 mnt
drwxr-xr-x 4 root root 4096 Dec 8 15:22 opt
dr-xr-xr-x 2 root root 4096 Mar 12 2019 proc
-rw-r--r-- 1 root root 109 Dec 8 15:25 razor-agent.log
dr-xr-x--- 14 root root 4096 Dec 10 03:35 root
drwxr-xr-x 3 root root 4096 Mar 12 2019 run
lrwxrwxrwx 1 root root 8 Mar 12 2019 sbin -> usr/sbin
lrwxrwxrwx 1 root root 25 Dec 8 15:20 scripts -> /usr/local/cpanel/scripts
drwxr-xr-x 2 root root 4096 Apr 10 2018 srv
drwx------ 2 root root 4096 Mar 12 2019 sys
drwxrwxrwt 7 root root 4096 Dec 10 21:47 tmp
drwxr-xr-x 13 root root 4096 Dec 8 15:21 usr
drwxr-xr-x 22 root root 4096 Dec 9 13:52 var
-rw-r--r-- 1 root root 0 Dec 9 13:54 .vzfifo
```
6) Create a template using the following command, e.g. for CentOS 7:
tar --numeric-owner --ignore-failed-read -czpf /vz/template/cache/centos-7-x86_64-ez.tar.gz ./*
```
[root@server 24x7template]# tar --numeric-owner --ignore-failed-read -czpf /vz/template/cache/centos-7-x86_64-ez.tar.gz ./*
tar: ./usr/local/cpanel/var/cpdoveauth_domainownerd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpauthd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpdoveauthd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpwrapd.sock: socket ignored
[root@server 24x7template]#
```
7) Unmount the ploop device:
cd ~
umount /24x7template
8) On OpenVZ 7 additional step should be done, the name of the template has to be the following format:
OS-version-bit-custom.tar.gz
It is /usr/libexec/ovz-template-converter --verbose /vz/template/cache/centos-7-x86_64-ez.tar.gz
So the template should be named centos-7-x86_64-ez.tar.gz
```
Unmounting file system at /tmp/tmpfoOqjQ
Unmounting device /dev/ploop26012
Opening delta /tmp/tmpBs5hMm/root.hds
Deleted the temporary template contents directory /tmp/tmpfoOqjQ
Creating cache file for the selected template
./
./DiskDescriptor.xml
./DiskDescriptor.xml.lck
./root.hds
Compressed 5293219840 bytes into 2133279899 bytes ==> 40.30%
Created cache file for the selected template: /vz/template/cache/centos-7-x86_64-ez.plain.ploopv2.tar.lz4
Deleted the temporary working directory /tmp/tmpBs5hMm
[root@server ~]#
```
Here if you get "No space left on device" error for /tmp
Refer to below "df -h" command output for /tmp from the node for more details:
```
/dev/ploop26012p1 4.8G 4.6G 0 100% /tmp/tmpfoOqjQ
```
It's because the ploop device has a bigger size then expected by default and additional tuning is required.
Following steps need to perform of the slave server over SSH.
Remove already made configuration for the template:
rm /vz/template/cache/distribution-version-arch[-customname.plain.ploopv2.tar.lz4
rm /vz/template/distribution/version/arch/config/os/customname
For example:
rm /vz/template/cache/centos-7-x86_64-custom.plain.ploopv2.tar.lz4
rm /vz/template/centos/7/x86_64/config/os/custom
Then, open the file /etc/vz/conf/vps.vzpkgtools.conf-sample with a text editor and Increase the value of DISKSPACE, for example:
DISKSPACE="20485760:20485760"
Convert the template again:
/usr/libexec/ovz-template-converter --verbose /vz/template/cache/centos-7-x86_64-ez.tar.gz
9) Upload the template file at /vz/template/cache directory on the Master server. Once the templates are uploaded, navigate to Media > List templates and click on the corresponding Add button under the SolusVM interface.
2) Stop the container via SolusVM interface.
3) Create a directory where you wish to mount the container image, e.g.:
mkdir /24x7template
4) Mount the container image using CTID:
mount -t ploop /vz/private/751/root.hdd/DiskDescriptor.xml /24x7template
Note : In the above example, the CTID is 751, you will need to replaced it with the actual your container ID.
``
[root@server ~]# mount -t ploop /vz/private/751/root.hdd/DiskDescriptor.xml /24x7template
Opening delta /vz/private/751/root.hdd/root.hds
Opening delta /vz/private/751/root.hdd/root.hds
Adding delta dev=/dev/ploop26012 img=/vz/private/751/root.hdd/root.hds (rw)
Mounted /dev/ploop26012p1 at /24x7template fstype=ext4 data=',balloon_ino=12'
[root@server ~]#
```
5) go to the directory, you will see the files like below:
cd /24x7template
```
[root@server ~]# cd /24x7template
[root@server 24x7template]# ls -la
total 100
dr-xr-xr-x 19 root root 4096 Dec 10 21:46 .
dr-xr-xr-x. 22 root root 4096 Dec 10 21:48 ..
drwx--x--x 2 root root 4096 Dec 9 02:00 backup
lrwxrwxrwx 1 root root 7 Mar 12 2019 bin -> usr/bin
dr-xr-xr-x 3 root root 4096 Mar 12 2019 boot
drwxr-xr-x 2 root solusvm 4096 Mar 12 2019 dev
drwxr-xr-x 88 root root 12288 Dec 10 21:45 etc
drwxr-xr-x 5 root root 4096 Dec 8 15:24 home
lrwxrwxrwx 1 root root 7 Mar 12 2019 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Mar 12 2019 lib64 -> usr/lib64
drwx------ 2 root root 16384 Mar 12 2019 lost+found
drwxr-xr-x 2 root root 4096 Apr 10 2018 media
drwxr-xr-x 2 root root 4096 Apr 10 2018 mnt
drwxr-xr-x 4 root root 4096 Dec 8 15:22 opt
dr-xr-xr-x 2 root root 4096 Mar 12 2019 proc
-rw-r--r-- 1 root root 109 Dec 8 15:25 razor-agent.log
dr-xr-x--- 14 root root 4096 Dec 10 03:35 root
drwxr-xr-x 3 root root 4096 Mar 12 2019 run
lrwxrwxrwx 1 root root 8 Mar 12 2019 sbin -> usr/sbin
lrwxrwxrwx 1 root root 25 Dec 8 15:20 scripts -> /usr/local/cpanel/scripts
drwxr-xr-x 2 root root 4096 Apr 10 2018 srv
drwx------ 2 root root 4096 Mar 12 2019 sys
drwxrwxrwt 7 root root 4096 Dec 10 21:47 tmp
drwxr-xr-x 13 root root 4096 Dec 8 15:21 usr
drwxr-xr-x 22 root root 4096 Dec 9 13:52 var
-rw-r--r-- 1 root root 0 Dec 9 13:54 .vzfifo
```
6) Create a template using the following command, e.g. for CentOS 7:
tar --numeric-owner --ignore-failed-read -czpf /vz/template/cache/centos-7-x86_64-ez.tar.gz ./*
```
[root@server 24x7template]# tar --numeric-owner --ignore-failed-read -czpf /vz/template/cache/centos-7-x86_64-ez.tar.gz ./*
tar: ./usr/local/cpanel/var/cpdoveauth_domainownerd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpauthd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpdoveauthd.sock: socket ignored
tar: ./usr/local/cpanel/var/cpwrapd.sock: socket ignored
[root@server 24x7template]#
```
7) Unmount the ploop device:
cd ~
umount /24x7template
8) On OpenVZ 7 additional step should be done, the name of the template has to be the following format:
OS-version-bit-custom.tar.gz
It is /usr/libexec/ovz-template-converter --verbose /vz/template/cache/centos-7-x86_64-ez.tar.gz
So the template should be named centos-7-x86_64-ez.tar.gz
```
Unmounting file system at /tmp/tmpfoOqjQ
Unmounting device /dev/ploop26012
Opening delta /tmp/tmpBs5hMm/root.hds
Deleted the temporary template contents directory /tmp/tmpfoOqjQ
Creating cache file for the selected template
./
./DiskDescriptor.xml
./DiskDescriptor.xml.lck
./root.hds
Compressed 5293219840 bytes into 2133279899 bytes ==> 40.30%
Created cache file for the selected template: /vz/template/cache/centos-7-x86_64-ez.plain.ploopv2.tar.lz4
Deleted the temporary working directory /tmp/tmpBs5hMm
[root@server ~]#
```
Here if you get "No space left on device" error for /tmp
Refer to below "df -h" command output for /tmp from the node for more details:
```
/dev/ploop26012p1 4.8G 4.6G 0 100% /tmp/tmpfoOqjQ
```
It's because the ploop device has a bigger size then expected by default and additional tuning is required.
Following steps need to perform of the slave server over SSH.
Remove already made configuration for the template:
rm /vz/template/cache/distribution-version-arch[-customname.plain.ploopv2.tar.lz4
rm /vz/template/distribution/version/arch/config/os/customname
For example:
rm /vz/template/cache/centos-7-x86_64-custom.plain.ploopv2.tar.lz4
rm /vz/template/centos/7/x86_64/config/os/custom
Then, open the file /etc/vz/conf/vps.vzpkgtools.conf-sample with a text editor and Increase the value of DISKSPACE, for example:
DISKSPACE="20485760:20485760"
Convert the template again:
/usr/libexec/ovz-template-converter --verbose /vz/template/cache/centos-7-x86_64-ez.tar.gz
9) Upload the template file at /vz/template/cache directory on the Master server. Once the templates are uploaded, navigate to Media > List templates and click on the corresponding Add button under the SolusVM interface.