Convert CT from OpenVZ to LXC manually?

ramses

Active Member
Dec 2, 2013
33
7
28
Hi everybody,

I have upgraded from PROXMOX 3.4 to 4.2 and then I have viewed that I have not backup of some CT OpenVZ to migrate to LXC.

I have the CT in /vz/private/200/ with all files inside.

Is there any way to migrate from OpenVZ (/vz/private/200) to LXC if I have not a backup of CT 200?

I know that in KVM, if I create a VM and then I overwrite the 'file-disk.raw' with the file of another VM KVM, it works well.

Is there something similar to this to convert manually from OpenVZ to LXC if I have not a backup of CT?


Best regards,

Ramses
 
Two options:
  • You can create a container with the same OS and rsync the OpenVZ data into the LXC. Afterwards do the same steps that are on the previously mentioned page
  • Install the older version with OpenVZ on another machine (e.g. inside your current Proxmox) and copy the OpenVZ folder and config in, do the backup and import in your new Proxmox.
 
Two options:
  • You can create a container with the same OS and rsync the OpenVZ data into the LXC. Afterwards do the same steps that are on the previously mentioned page
  • Install the older version with OpenVZ on another machine (e.g. inside your current Proxmox) and copy the OpenVZ folder and config in, do the backup and import in your new Proxmox.

LnxBil, very thanks by the answer.

I have done this:

- Create a LXC Container with the same OS that had the old OpenVZ Container.

- Access to the new LXC Container (1600).

- Install rsync package.

- Execute rsynk with this line in the new LXC Container:

rsync -vaz --delete -e 'ssh -p 1111' root@<source-PROXMOX-server>:/vz/private/600 / --exclude '/proc/*' --exclude '/dev/*' --exclude '/sys/*' --exclude '/tmp/*'

** Note: I put (-e 'ssh -p 1111') in the previous line because I have the SSH Service in the 1111 port of the PROXMOX Server.

- Remove the Network Interface of LXC Container from PROXMOX.

- Add the new Network Interface of LXC Container form PROXMOX Console with this line:

pct set 1600 -net0 name=eth0,bridge=vmbr0,ip=192.168.20.90/24,gw=192.168.20.10


Best regards,

Ramses
 
You did this from inside your container? It's better to do it from outside and in non-started mode. Then you do not have to exclude the runtime directories. I'd also suggest to use '-x' and '--numeric-ids'.

But glad it worked.
 
You did this from inside your container? It's better to do it from outside and in non-started mode. Then you do not have to exclude the runtime directories. I'd also suggest to use '-x' and '--numeric-ids'.

But glad it worked.

LnxBil, can you tell me where are the content of LXC Containers when they are stopped?
Can you explain me how to do that?
I don't understand, I am very clumsy or newbie with PROXMOX.

Best regards,
Ramses
 
you can just do a "pct mount CTID" to mount a container's volumes to /var/lib/lxc/CTID/rootfs/
 
That depends on the used storage backend. If you choose a file-based storage backend (e.g. directory, ZFS) it is mounted, e.g. for ZFS you'll have "real" mount points:

Code:
Filesystem                               Size  Used Avail Use% Mounted on
...
zpool/proxmox/subvol-100-disk-1          121G   52G   70G  43% /zpool/proxmox/subvol-100-disk-1
zpool/proxmox/subvol-1003-disk-1         8.0G  1.5G  6.6G  19% /zpool/proxmox/subvol-1003-disk-1
zpool/proxmox/subvol-1004-disk-1         8.0G  1.4G  6.7G  17% /zpool/proxmox/subvol-1004-disk-1
zpool/proxmox/subvol-1005-disk-1         4.0G  1.1G  3.0G  27% /zpool/proxmox/subvol-1005-disk-1
zpool/proxmox/subvol-1006-disk-1         8.0G  346M  7.7G   5% /zpool/proxmox/subvol-1006-disk-1
zpool/proxmox/subvol-1007-disk-1         4.0G  315M  3.7G   8% /zpool/proxmox/subvol-1007-disk-1
zpool/proxmox/subvol-1008-disk-1         4.0G  703M  3.4G  18% /zpool/proxmox/subvol-1008-disk-1

For directory-based containers, you'll have subfolders inside your specified directory sub-folders.

If you have block storage device like LVM, Ceph you have to mount it yourself. Then you'll have to mount it manually.
 
or you can just use "pct mount", which will follow the exact same mounting procedure used when starting the container, but does not "hide" the mountpoints in a different name space.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!