format / reset rootfs disk in container


Mar 12, 2018
Dear Community,

When I provision a LXC container in Proxmox, it is quite difficult to reset it to an initial state. I want to override the rootfs with a clean image from the template and reinitialize the basic setup Proxmox does (like install SSH keys, configure network).

The reason for this is that I am working with configuration management systems (like Ansible) and sometimes, when you try out things that don't work as expected during development, it is easier to just revert and reinstall everything from scratch than try to undo what you have done. Like with a Dockerfile that builds an image from scratch.

Now when you work with storage that does not support snapshots (I work with LVM in one case as LVM-Thin has not the performance I need because of fragmentation and zeroing) and when you have automatic backups that delete the old ones automatically, then you have no point to return most of the time. Currently I have to show the config, delete and recreate the container each time.

With VMs, it is very easy to just reinstall over the drive, just reformat the drive during installation. The configuration can be the same, I just add an IDE ISO image and boot from CD/DVD and I have not to delete and recreate the VM. But with containers, no such method exists, to just overwrite the rootfs disk.
When you have to delete and recreate the container, it takes a lot of time to click through the wizard.

A button that just recreates the container with the current config from the template would be perfect. Overwrite the container would it be.

Or is there any other possibility, like for example show the console command that is needed to create the container (which can be appended with --force flag and should do it)?

Thank you!
  • Like
Reactions: zaphyre

if you already have a CT template, you can do:

pct clone TEMPLATE_ID NEW_ID --full
Thank you for your quick reply,
the Problem with the template is that I have different mounts of different underlying storages in addition to the configuration, the rootfs disk for example lies on a ceph SSD storage, additional mount points on a local LVM disk. This has practical performance reasons, for example when you want to run a distributed database inside a container.
The template also changes the MAC address of the network card, which leads to wrong IP addresses from the DHCP server with static leases (which is better for distributed services as name resolution changes can lead to longer timeouts of services).
Moreover, I have different configurations, I would need dozens of templates for dozens of containers.

So unfortunately, cloning or templating modifies the configuration, which is a problem in my case, as I want to reinstall the services as in continous integration with the same underlying system, just cleaned from mistakes.

Nevertheless, thank you for your idea!
Hi, sorry for digging this topic up. I am also looking for a solution to reset a container to a fresh install state but keep its config and all dependencies. Is it still the only solution to create a new container?

As far as I understood by reading the above; what I would do now is saving the original container config file, delete the original container, create a new container from my template and manually edit relevant parts form the old config in the new config (MAC, IP, features,...)

That gives me a new ID, what happens with the old (PBS-)backups?

Is it common practice to just use a snapshot after install with containers to be able to go to a clean start?

Or, regarding pct clone, would it be possible to shutdown the original container and clone (the filesystem) from the template and keep the container config and the original ID?

Thanks a lot
Last edited:


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!