0

I have a number of "tar" files created from an old proxmox 6 server, using the vzdump tool.

The person that originally created them has left the company, and the company has changed it's container server from "Proxmox VE" to a standard Linux Ubuntu 20.04 LTS server running the latest version of LXD for it's container system.

I've now been asked if I can take these Vzdump tar files, and turn them into regular standard LXC based deployments running on the new server.

Every search I do seems to ONLY turn up converting bare bones LXC containers to Proxmox VE containers, and asking in the proxmox forums is getting me no where, because all they want to do is get me back onto proxmox, which my client no longer wishes to use.

I can vzrestore onto the new server, but the meta data in the containers is not compatible with LXD/LXC so that's proven to be a dead end so far.

In the same vein, I've also tried converting the container to an LXC template image, and building from that, but again, that's not worked as I'd hoped.

shawty
  • 293
  • 4
  • 15
  • proxmox is using a standard lxc setup. please just try to use it – djdomi Nov 11 '21 at 19:35
  • Ummm... did you actually read my question properly? I'm well aware of what Proxmox uses under the hood, but that's not what I'm asking is it? – shawty Nov 11 '21 at 19:53
  • i read and used the backuo file which are basically just a copy of the filesystem to copy and start a container, the only thing you may to think about is to restore this because its a backup file and not a template – djdomi Nov 11 '21 at 20:42
  • That's the answer I'm looking for, how to take the archive file created by vzdump, and make it work with normal LXD/LXC that is NOT installed as part of Proxmox, if you can explain that, then that will be the answer. – shawty Nov 11 '21 at 22:38
  • i thibk you just need to use lxc import tarfile – djdomi Nov 13 '21 at 11:17
  • OK thanks, will try that and see what happens. – shawty Nov 16 '21 at 12:44
  • Tried that, got the following : "Error: Backup is missing index.yaml" so at least I have something to hunt on. – shawty Nov 16 '21 at 12:59

1 Answers1

1

So after 2 weeks of research and reading many, many blog posts, I finally figured out how to do it.

It's not particularly staright forward, but it's not rocket science either, I do however get the feeling (and the hostility) from asking in the proxmox forums that they would rather you didn't move away from the proxmox platform, temporary or otherwise.

Anyway, the steps you need to follow are essentially

  1. at the proxmox command line, "pct list" to get the ID of the container you want to copy.

  2. at the same command line "vzdump -compress gzip -dumpdir /tmp" , you don't need the dump dir parameter, but the default is nested a stupid amount of folders deep, so I'd advise to use the tmp dir for easiness.

  3. you then need to create a "meta data file" using the following commands (Please NOTE: the # symbols need to be changed to BACKTICKS before you copy and paste/use the command, I've had to use the # symbol as markdown in a SO post cannot display the backtick symbol due to the way markdown uses it) :

    echo architecture: #pct config $1 | grep arch: | awk '{print $2}'# > metadata.yaml

    echo creation_date: #date +%s# >> metadata.yaml

    tar -czvf metadata.tar.gz metadata.yaml

    rm metadata.yaml
  1. Move the ".tar.gz" files that you created, across to the target machine running a modern version of LXD, I used rsync for this.

  2. ON the command line of your LXD machine, use the following command to import the metadata and dump file into an lxc image:

    sudo lxc image import metadata.tar.gz <vzdump name>.tar.gz

This will import the container as an image, which is not directly runnable, type

lxc image list

and get the fingerprint of the image you just created

LXC image list

  1. still at the LXD command line, using the fingerprint from your image use:

    lxc launch <fingerprint> <name you want to give your container>

At this point, you'll have a new container, that is an exact duplicate of your original proxmox one running.

What you may not have are the same network settings however. For me, I have everything on my network running off of DHCP, including the static leases, so it was important that my new containers had the same MAC address, that was easily done by using

pct config <container id>

on the proxmox cli to display the hardware configuration, then copy and pasting the MAC address from that, followed by

lxc stop <container name>
lxc config set <container name> volatile.eth0.hwaddr <copied mac address>
lxc start <container name>

If your DHCP static leases are driven from the mac address, then this will ensure that they get the same IP address, as long as your LXD host is set up to bridge IP's on the same network as your original proxmox host.

I've written a blog post which can be found at : https://shawtyds.wordpress.com/2021/11/16/converting-containers-from-proxmox-ve-back-to-plain-old-lxd-lxc/ that goes into a little more detail.

Once your copied container is running, then it's just a matter of using lxc to delete the temporary image (unless you want to keep it) and to erase the ".tar.gz" files from both servers, and possibly removing the old container from proxmox if you no longer need it.

shawty
  • 293
  • 4
  • 15