Replace Contents of Container?

mattlach

Well-Known Member
Mar 23, 2016
169
17
58
Boston, MA
Hey all,

I have a quick question.

I have a container with a rather complex configuration with many mounted folders, and several Ethernet devices. I'd like the keep the container as is, but replace the template it is running off of with a different distribution.

Is this possible?

I was thinking something like this:
1.) Shut down container
2.) ZFS Snapshot "rpool/subvol-110-disk-1" in case I want to go back
3.) rm -fr /rpool/subvol-110-disk-1
4.) Manually uncompress (tar -zxvf) template tarball from /var/lib/vz/template/cache to /rpool/subvol-110-disk-1
5.) Start container back up, and configure.

Is this something I can/should do, or could there be problems? I have to do a complicated upgrade of a container, and this would greatly help me if possible.

Many thanks,
Matt
 
Is this something I can/should do, or could there be problems? I have to do a complicated upgrade of a container, and this would greatly help me if possible.

Maybe just create a new container with the respective distro, then open both configs (from /etc/pve/nodes/NODE/lxc/VMID.conf ) and copy those mount points and other stuff over to the new CT? (with some adaption if/where needed)

Stuff, which does not need an volume image to be setup (created) can just be copied over as it's setup on CT start, e.g. network, mounpoints, ....
This should be faster and less dangerous for overwriting existing stuff, if something goes wrong you can just start the oild CT and figure it out calmly.
 
Maybe just create a new container with the respective distro, then open both configs (from /etc/pve/nodes/NODE/lxc/VMID.conf ) and copy those mount points and other stuff over to the new CT? (with some adaption if/where needed)

Stuff, which does not need an volume image to be setup (created) can just be copied over as it's setup on CT start, e.g. network, mounpoints, ....
This should be faster and less dangerous for overwriting existing stuff, if something goes wrong you can just start the oild CT and figure it out calmly.


Thank you for your suggestion.

Part of my problem is that this container hosts a back end service that relies on an external device on a dedicated Ethernet interface (10.0.3.x) and storage on yet another dedicated interface (10.0.2.x), and then has frontends on my local network accessing it based on its IP address on the main 10.0.1.x network.

While I am setting up the replacement, I will need it to have the correct IP addresses for testing.

The problem is, I don't think the interface will allow me to assign the same IP addresses to two different containers at the same time, even if one of them is not running (but I could be wrong about this)

My intent here was to create an easy and safe way to restore my old configuration using ZFS snapshots, so I don't have to keep going back and forth and changing IP addresses in the configuration over and over during testing.

The example being first shut down old container and change three IP addresses on the old container to alternate IP addresses, then add these three IP addresses to the new container, and then have to repeat this as I go back and forth between them

Maybe you are right though, keep it simple, even though it is more work.
 
The problem is, I don't think the interface will allow me to assign the same IP addresses to two different containers at the same time, even if one of them is not running (but I could be wrong about this)

From the PVE side this is no problem. But you obviously should not run both CTs at the same time for address conflicts.

My intent here was to create an easy and safe way to restore my old configuration using ZFS snapshots, so I don't have to keep going back and forth and changing IP addresses in the configuration over and over during testing.

You could do this with my proposed approach to, even with less possibility to delete the wrong zfs volume by mistake.

The example being first shut down old container and change three IP addresses on the old container to alternate IP addresses, then add these three IP addresses to the new container, and then have to repeat this as I go back and forth between them

Maybe you are right though, keep it simple, even though it is more work.

It shouldn't be more work, though - at least if you don't change IPs on the old CT until you're done with the new one. But it just may be that I overlook something in your setup/requirements which make it really more work :)
 

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!