The proxmox wiki has this page covering various migration scenarios but at the time of writing it doesn't cover migrating a physical Linux box (or a LXC/LXD container) into a PVE (LXC) container. I have opened a ticket requesting they update that page with instructions such as these, which I am posting in case there are any delays in getting that page updated or they decide not to document this process. This process should be documented somewhere publicly as it took me several days of experimenting to avoid various pitfalls and arrive at a working method.
Migrating a Linux install into a Proxmox VE LXC container
Log into the machine you want to migrate into a PVE container as root and first stop any running services such as web servers or databases eg `systemctl stop apache2`, `systemctl stop mysql` etc. You need to be root (or run with sudo) so that tar can access and archive all files correctly using commands such as:
# cd /
# tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz /
The tar -p switch is critical for preserving file permissions. Copy this tarball into the container templates cache directory on the PVE server which defaults to /var/lib/vz/template/cache . You may then create a new container using this tarball as a template via the web UI or using pct. If you choose to use the PVE web UI to create the new container, be sure to uncheck the 'Unprivileged Container' option (under the General options tab) else you are likely to run into file ownership issues. Creating a new privileged i386 container on ZFS storage with container ID 101 using pct would look something like this:
# pct create 101 local:vztmpl/backup.tar.gz -arch i386 -hostname your.hostname.here -onboot 1 -rootfs local-zfs:300 -memory 4096 -cores 2
Note this command doesn't configure networking. I enable networking after creating the container via the proxmox web interface.
Migrating a Linux install into a Proxmox VE LXC container
Log into the machine you want to migrate into a PVE container as root and first stop any running services such as web servers or databases eg `systemctl stop apache2`, `systemctl stop mysql` etc. You need to be root (or run with sudo) so that tar can access and archive all files correctly using commands such as:
# cd /
# tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz /
The tar -p switch is critical for preserving file permissions. Copy this tarball into the container templates cache directory on the PVE server which defaults to /var/lib/vz/template/cache . You may then create a new container using this tarball as a template via the web UI or using pct. If you choose to use the PVE web UI to create the new container, be sure to uncheck the 'Unprivileged Container' option (under the General options tab) else you are likely to run into file ownership issues. Creating a new privileged i386 container on ZFS storage with container ID 101 using pct would look something like this:
# pct create 101 local:vztmpl/backup.tar.gz -arch i386 -hostname your.hostname.here -onboot 1 -rootfs local-zfs:300 -memory 4096 -cores 2
Note this command doesn't configure networking. I enable networking after creating the container via the proxmox web interface.