Keep or reuse lxc volume

rwanito

Member
May 25, 2021
14
0
6
25
Hi !

I use LXC to run services.
But, if a service goes down or be corrupted I want to remove the LXC container and renew it.
The same case if I upgrade the rootfs.

But, I have mount points that contain data and I want to keep them or reuse them without delete sensitive data.
My volumes are on a ceph rbd storage.

I'm unable to locate the disk and in fact to save it.

Is exisist a way to :
- Save data volume,
- Remove container,
- recreate the container,
- rebind the data volume

Thanks for your work !
Erwan
 
You can edit the config file directly (located in /etc/pve/lxc/<vmid>.conf) and remove the line specifiying your mountpoint (e.g. mp0: /some/path,mp=/mnt,size=16G, copy it somewhere else). This will not touch the data. Then simply delete and recreate your container, and after that's done, add the 'mp' options back into the new config file. The new container now references the data from the old one.
 
  • Like
Reactions: rwanito
If you do not want to edit the config file directly you can use:
pct move-volume 100 mp0 --target-vmid 200 --target-volume mp1
It just reassigns owner of the volume at mount point mp0 on ct number 100 to mount point 1 on ct number 200.
 

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!