[TUTORIAL] Migrating a Linux install into a Proxmox VE LXC container

danboid

New Member
Jul 5, 2012
6
0
1
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.
 

t.lamprecht

Proxmox Staff Member
Staff member
Jul 28, 2015
5,216
1,520
164
South Tyrol/Italy
shop.proxmox.com
  • Like
Reactions: danboid

danboid

New Member
Jul 5, 2012
6
0
1
Thanks t.lamprecht! I will apply for a wiki account if I write any more missing documentation.
 

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 your own in 60 seconds.

Buy now!