How to convert a VM into LXC in Proxmox VE 6.0.2+?

ceweithr

New Member
Feb 28, 2021
2
0
1
34
  • PVE version: 6.2-4
  • Kernel version: 5.4.41-1
  • source VM: ubuntu1804-amd64
  • target LXC: ubuntu1804-amd64 in LXC format
I've used PVE for almost 2 years and I love it very much. Now I want to convert my VM created by PVE into LXC that can ran on PVE with full features like other LXC orginally created by PVE Web Interface.

I just wonder if that is a solution. Although I would like to use the converted LXC in console mode, its source system is VM with GUI. I don't know if that is compatiable.

Looking forward to find a way to get it done...

ps: I would prefer to manage my converted LXC by xterm.js :)
 
There is no one button migration, basically you have to:
  1. Create a new LXC container
  2. Copy all settings and data, eg. with rsync
 
No I have never tried it, sorry
Well. I made myself some test here, and realize that when do rsync copy, after start the ct, I was unable to login with root or any other user.
Just could do that, after change unprivileged to 0, like that:
unprivileged: 0

Don't know if has secucirty concern about that. Thanks
BTW I have had used this like to copy
rsync -av . --exclude=/etc --exclude=/usr/src --exclude=/bin --exclude=/lib --exclude=/lib32 --exclude=/lib64 --exclude=/libx32 --exclude=/sb
in --exclude=/boot /var/lib/lxc/100/rootfs/
 
Last edited:
My vm was on a zvol with an LVM filesystem, I managed to convert to a container by first mounting then activating the LVM as per:
https://gist.github.com/pshchelo/6ffabbffaedc46456b39c037d16e1d8c
and instead of <image.qcow2> put /dev/<device> device being where the disks symlink points in /dev/pool/vm-110-disk-0(root disk)
Then once inside root: tar the whole directory which you can then use to create a container with.
 
Last edited:

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!