Best Practices with LXC

Joern Bredereck

Renowned Member
Mar 25, 2016
15
0
66
48
I'm in the process of evaluating Promox with LXC as a replacement for our Citrix Xen environment. As much as I like the openness of Promox I'm little bit frustrated with the use of LXC. But maybe that's just due to my lack of experience. So I would love to hear from the LXC power users in this forum how to do it right.

I'm in particular interested in the following tasks:

1. Migrating Linux VMs from XEN, ESXi and physical installations: Are there any best practice solutions?

I tried creating a new container and simply rsyncing the VM over the new one. But the containers won't start afterwards.

I also tried attaching a new disk to a container and rsyncing the old server into the new disk. I changed /etc/fstab and attached the new disk as the root device to a new container but it won't boot either.

2. Creating clones of existing container installations for new ones.

3. Backing up LXC disks and restoring them. I'm using ZFS for all disks and I tried to backup a container by sending a snapshot (zfs send) to an offsite backup server. After restoring the Snapshot the container would not boot any more. Any idea? I'm aware that Promox has a backup feature built in, but to my knowledge incremental backups are not supported. With ZFS snapshots (using zetaback) I could run incremental snapshots. That works for KVM-based VMs by the way.


As you can see I'm pretty lost here. Are there any good LXC (proxmox specific) tutorials on how to handle the above tasks?
 
for backup and restore we use at least two systems:

pve-zsync and backups from pve web page.

I suggest you try starting with a lxc template from pve , make a lxc and practice backup and restore.

for the restored lxc, just delete and add the nic , and change hostname / IP .

I've read that pve-zsync sometime in the future may be put to pve web page. There are many other good zfs snapshot backup systems. we use pve-zsync because the virtual machine configuration file gets backed up with the snapshot. cli needed but life is boring with just web based configuration systems.
 
1. Migrating Linux VMs from XEN, ESXi and physical installations: Are there any best practice solutions?

I tried creating a new container and simply rsyncing the VM over the new one. But the containers won't start afterwards.

I also tried attaching a new disk to a container and rsyncing the old server into the new disk. I changed /etc/fstab and attached the new disk as the root device to a new container but it won't boot either.

I created a container on ZFS with the OS I want to migrate, delete the ZFS filesystem, create a new one and then rsync the files to the new one. This worked every time. Afterwards you can delete all kernel and modules stuff.
 
Hi,

thanks to everyone who answered. I will check out pve-zsync. That sounds promising.
And in the meanwhile I figured out how to migrate VMs to LXC. But since we're using ZFS in most of our VMs LXC is not really an option. Or is there any way to run a zpool inside an LXC container?
 
we run lxc on zfs at pve host.

use storage > add > zfs

/etc/pve/storage.cfg ends up looking like this when done:
Code:
zfspool: lxc-zfs
  pool tank/lxc
  nodes sys3,sys4,sys5,dell1
  content rootdir

zfspool: kvm-zfs
  pool tank/kvm
  nodes sys4,dell1,sys5,sys3
  content images

it is not necessary to have separate storage for lxc and kvm, I just prefer it.

Are you using local zfs ?
 
Hi,

thanks to everyone who answered. I will check out pve-zsync. That sounds promising.
And in the meanwhile I figured out how to migrate VMs to LXC. But since we're using ZFS in most of our VMs LXC is not really an option. Or is there any way to run a zpool inside an LXC container?

You can use LXC with ZFS, using the ZFS pool plugin in Proxmox VE. The ZFS filesystems will be mounted on the host, and then bind-mounted into the container. Running a zpool inside an LXC container is not supported, you would have to disable or heavily adapt the apparmor containment of the container which is a security risk. I am also not sure how well that would perform (RAM limits of the container vs. RAM requirements of ZFS).
 

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!