Import non-PVE-created LXC container into PVE 5.2

Will Dennis

Member
Oct 10, 2016
10
0
21
59
Princeton NJ
Hi all,

I have a number of LXC containers that were created on Ubuntu 14.04 (LXC ver 1.0.7) that I would like to import into PVE 5.2.

I have seen/read this post: https://forum.proxmox.com/threads/h...xc-container-to-a-proxmox-lxc-container.24138 but even after reading that, it is nebulous as to exactly how to do this... I did make a tarball of the non-PVE LXC container's rootfs, but must I inject a "etc/vzdump/pct.conf" file into the container then use "pct restore", or is there another way of doing this using the rootfs tarball? (note that I don't want to create a template, just "import" an existing container off another system.)

Seems like importing non-PVE-created LXC containers might be a thing, but can't find any "HOWTOs" about doing this.

Thanks.
 
a template is also just a rootfs + associated metadata ;) have you tried using your rootfs archive as ostemplate via 'pct create' ? depending on whether you want to keep network, dns etc. setup you might want to set the 'ostype' to unmanaged (or not)
 
Perhaps you missed this, but...
[...] (note that I don't want to create a template, just "import" an existing container off another system.)

Here's what I ended up doing, seems like it may have worked...

1) On the source LXC system, I backed up the desired containers "rootfs" contents to a tarball via:
root@oldlxchost:/tmp# find /var/lib/lxc/my_old_container/rootfs -printf "%P\n" | tar -czf my_old_container_amd64.tar.gz --no-recursion -C /var/lib/lxc/my_old_container/rootfs -T -
2) Then I transferred this tarball onto the target Proxmox 5.2 system.
3) Since I am storing container root disk images on a ZFS filesystem ("datapool"), I pre-created a subvolume for the disk (having pre-determined that I'd make this container ID '150' and that the target disk size would be '500G'):
root@pve01:/# zfs create datapool/subvol-150-disk-1
root@pve01:/# zfs set xattr=sa datapool/subvol-150-disk-1
root@pve01:/# zfs set acltype=posixacl datapool/subvol-150-disk-1
root@pve01:/# zfs set refquota=500G datapool/subvol-150-disk-1

4) Then, I restored from the previously-made tarball, passing all required config statements that would be found in a "pct.conf" file on the command line:
root@pve01:/tmp# pct restore 150 my_old_container_amd64.tar.gz \
> --arch amd64 \
> --cores 12 \
> --hostname my-new-container \
> --memory 98304 \
> --net0 name=eth0,bridge=vmbr0,hwaddr=E2:E6:48:01:02:03,ip=dhcp,ip6=dhcp,type=veth \
> --ostype ubuntu \
> --rootfs local-zfs:subvol-150-disk-1,size=500G \
> --swap 2048

Even though the restore process issued a message stating "No config file found", it did create a container, and upon starting it, it is running correctly, and looks OK.

I took the "cores", "memory", and "swap" values from the old container's settings, and made up the "hwaddr" value in the "net0" stanza by starting with "E2:E6:48:" (which seems to be the Proxmox OUI) and then appending three random hex values for the host ID.

A bit of work, but seems to give me what I need in the way of "importing" containers from LXC 1.x to Proxmox...
 

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!