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

danboid

Renowned Member
Jul 5, 2012
16
0
66
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.
 
  • Like
Reactions: danboid
Thanks t.lamprecht! I will apply for a wiki account if I write any more missing documentation.
 
Maybe this is the old method but it seems to be all I can find.
I'm trying to convert a live manjaro machine to a proxmox vm.

I did as explained above, creating the compressed file but when I try to use pct create, I get 'contains illegal characters'.

Does anyone have any thoughts on this?

Code:
pct create 500 local-lvm:/mnt/pve/nfs/leena.tar.gz -arch i386 -hostname leena-manjaro -onboot 1 -rootfs local-zfs:300 -memory 4096 -cores 2
lvm name '/mnt/pve/nfs/leena.tar.gz' contains illegal characters
 
I'm really not sure and I've not tried using `pct create` since so it usage may have changed but from simply having a quick look I suspect the problem part of your command is:

local-lvm:/mnt/pve/nfs/leena.tar.gz


You have used an absolute path to the tar file and maybe that isn't permitted? Instead it probably must match the format that I used in my example eg:

local:vztmpl/backup.tar.gz

but adjusted to match your config, so in your case maybe try:

local-lvm:vztmpl/leena.tar.gz

Instead?
 
In my case, the file is actually in /mnt/pve/nfs.
I changed directory to that and ran the command without the full path but got the same error.
I should have mentioned that.
 
Copy/paste your exact command and the exact error to give the proxmox support team a better chance of helping you. Are you saying your error now is:

lvm name 'vztmpl/leena.tar.gz' contains illegal characters

Don't make us guess your error.
 
No you did not. The full text of your previous post was:

"In my case, the file is actually in /mnt/pve/nfs.
I changed directory to that and ran the command without the full path but got the same error.
I should have mentioned that."

No command and no error. If you had tried again with an adjusted option as I advised, you should've posted the revised command and its error in full.
 
Again, to be sure, I've tried from the directory where the file is and the full path.

Code:
root@pro01:/mnt/pve/nfs# ls -la leena.tar.gz
-rw-r--r-- 1 root root 51900734340 Dec 14 08:22 leena.tar.gz

root@pro01:/mnt/pve/nfs# pct create 500 local-lvm:/mnt/pve/nfs/leena.tar.gz -arch i386 -hostname leena-manjaro -onboot 1 -rootfs local-zfs:300 -memory 4096 -cores 2
lvm name '/mnt/pve/nfs/leena.tar.gz' contains illegal characters

root@pro01:/mnt/pve/nfs# pct create 500 local-lvm:leena.tar.gz -arch i386 -hostname leena-manjaro -onboot 1 -rootfs local-zfs:300 -memory 4096 -cores 2
unable to parse lvm volume name 'leena.tar.gz'
 
Um, just look one post above that one :).
Anyhow, here it is again, above this post.
 
Last edited:
I guess this is too advanced for me.
Is there any other way to import a live running manjaro OS into 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!