Category Archives: Virtualization

Convert OpenVZ to LXC


Convert OpenVZ VM to LXC VM

Install same version lxc OS
lxc launch ubuntu:20.04 lxc-server
lxc stop lxc-server

rm -rf /var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs
mkdir /var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs

On Ubuntu 20.04 OpenVZ VM run:
rsync -avz -e ssh --exclude=etc/inittab --exclude=etc/network/interfaces --exclude=dev/ --exclude=sys/ --exclude=proc/ / [email protected]:/var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs/

vim /var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs/etc/network/interfaces
auto lo
iface lo inet loopback
source /etc/network/interfaces.d/*.cfg

mkdir /var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs/etc/network/interfaces.d/
vim /var/snap/lxd/common/lxd/storage-pools/default/containers/lxc-server/rootfs/etc/network/interfaces.d/eth0.cfg
# The primary network interface
auto eth0
iface eth0 inet dhcp

lxc start lxc-server

For sure you need to stop MySQL/PostgreSQL before rsync or if huge database you can resync database after syncing data from OpenVZ server

Error: /usr/bin/apt-get failed, exitcode=100

Downloading packages
Failed to register the CT: PRL_ERR_VZCTL_OPERATION_FAILED (Details: Creating OS template cache for ubuntu-20.04-x86_64 template

tune2fs 1.42.9 (28-Dec-2013)
Setting maximal mount count to -1
Setting error behavior to 2
Setting interval between checks to 0 seconds
E: Unable to determine a suitable packaging system type
Error: /usr/bin/apt-get failed, exitcode=100
Error: Failed to umount ploop image /vz/tmp//vzpkg.2WxExF/cache-private/root.hdd: Error in ploop_umount_image (ploop.c:2804): Image /vz/tmp/vzpkg.2WxExF/cache-private/root.hdd/root.hds is not mounted 40
VE_PRIVATE is not set
Creation of Container private area failed

service vz restart

docker detach from running container

To detach the tty without exiting the shell, use the escape sequence Ctrl+P followed by Ctrl+Q. More details here.

Additional info from this source:

docker run -t -i → can be detached with ^P^Qand reattached with docker attach
docker run -i → cannot be detached with ^P^Q; will disrupt stdin
docker run → cannot be detached with ^P^Q; can SIGKILL client; can reattach with docker attach

podman read logs

sudo podman run --name web1 -dt -p 80:80 docker.io/library/httpd httpd -D FOREGROUND
bf5a2456f8f7e878405097402fe3ed32eb6f9e7b677ac09df1cce841cd7bf527

links -dump http://localhost
It works!

sudo podman container logs -f web1
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.33. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.33. Set the 'ServerName' directive globally to suppress this message
[Mon Aug 17 20:32:18.221008 2020] [mpm_event:notice] [pid 1:tid 139846430241920] AH00489: Apache/2.4.46 (Unix) configured -- resuming normal operations
[Mon Aug 17 20:32:18.221243 2020] [core:notice] [pid 1:tid 139846430241920] AH00094: Command line: 'httpd -D FOREGROUND'
10.88.0.1 - - [17/Aug/2020:20:32:45 +0000] "GET / HTTP/1.1" 304 -
10.88.0.1 - - [17/Aug/2020:20:32:45 +0000] "GET / HTTP/1.1" 304 -
10.88.0.1 - - [17/Aug/2020:20:32:48 +0000] "GET / HTTP/1.1" 304 -

add container to pod


sudo podman pod create
4d03c9f1ef5f8f944cb61d598084a1191802694e59e7438b36e1dfecdaa04fe3

sudo podman ps -a --pod
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES POD ID PODNAME
e14f13b36519 k8s.gcr.io/pause:3.2 About a minute ago Created 4d03c9f1ef5f-infra 4d03c9f1ef5f loving_northcutt

sudo podman run -dt --pod loving_northcutt docker.io/library/alpine:latest top

sudo podman ps -a --pod
269ea28c6217 docker.io/library/alpine:latest top 14 seconds ago Up 14 seconds ago strange_hertz 4d03c9f1ef5f loving_northcutt
e14f13b36519 k8s.gcr.io/pause:3.2 3 minutes ago Up 14 seconds ago 4d03c9f1ef5f-infra 4d03c9f1ef5f loving_northcutt

sudo podman pod ps
POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID
4d03c9f1ef5f loving_northcutt Running 6 minutes ago 2 e14f13b36519

2 containers, it like array for containers

Failed to register the CT: PRL_ERR_VZCTL_OPERATION_FAIL

Failed to register the CT: PRL_ERR_VZCTL_OPERATION_FAILED (Details: Creating OS template cache for centos-8-x86_64 template
Can’t open /proc/sys/kernel/virt_osrelease: No such file or directory
Error: /usr/share/vzyum/bin/yum failed, exitcode=1
VE_PRIVATE is not set
Creation of Container private area failed

Make sure you are using vz7 kernel:
uname -a | grep vz7
Linux CentOS-78-64-minimal 3.10.0-1127.8.2.vz7.151.14 #1 SMP Tue Jun 9 12:58:54 MSK 2020 x86_64 x86_64 x86_64 GNU/Linux