Revert CT from template after accidentally converted

dellannajw

Member
Aug 25, 2020
4
0
21
42
Dear friends I made a mistake while accidentally convert a LXC container to template.
Now I'm disperately trying to revert it but till now I couldn't.
I cloned it to a new CT (either linked and full copy mode) but I receive an error when I try to start it.
I also tryed to modify the /etc/pve/lxc/<CTID>.conf file changing the boolean value of "template" option from 1 to 0 but when I try to start the CT it give me the following error:

() mount_autodev: 1225 Read-only file system - Failed to create "/dev" directory lxc_setup: 4395 Failed to mount "/dev" do_start: 1272 Failed to setup container "100" sync_wait: 34 An error occurred in another process (expected sequence number 3) __lxc_start: 2107 Failed to spawn container "100" TASK ERROR: startup for container '100' failed

Can anyone help me to understand what happened and if there's a way to recover it or quantomeno at least data in it?

Thank you to all in advance!
 
Hi,
creating a full-clone is the way to go. Which error message do you get, when trying to start the cloned container?
 
Hi,
creating a full-clone is the way to go. Which error message do you get, when trying to start the cloned container?
() sync_wait: 34 An error occurred in another process (expected sequence number 7)
__lxc_start: 2107 Failed to spawn container "102"
TASK ERROR: startup for container '102' failed
 
Assuming your storage is of type LVM the template conversion can be nearly reverted by following steps:
In this example the rootfs of the container is stored in LV base-101-disk-0 in Volume Group pve
You can look up details of that in the config of the container and with lvdisplay command.
Code:
lvchange -a y pve/base-101-disk-0
lvchange -p rw pve/base-101-disk-0
lvrename pve/base-101-disk-0 pve/vm-101-disk-0
remove template line from containers config file (e. g.) /etc/pve/nodes/<yourNode>/lxc/101.conf and change the rootfs entry to match the just renamed disk.

Better way nevertheless is making a full clone of the template.
For the error you posted: please start the container via cli with pct start 102 --debug and post the output.
 
Assuming your storage is of type LVM the template conversion can be nearly reverted by following steps:
In this example the rootfs of the container is stored in LV base-101-disk-0 in Volume Group pve
You can look up details of that in the config of the container and with lvdisplay command.
Code:
lvchange -a y pve/base-101-disk-0
lvchange -p rw pve/base-101-disk-0
lvrename pve/base-101-disk-0 pve/vm-101-disk-0
remove template line from containers config file (e. g.) /etc/pve/nodes/<yourNode>/lxc/101.conf and change the rootfs entry to match the just renamed disk.

Better way nevertheless is making a full clone of the template.
For the error you posted: please start the container via cli with pct start 102 --debug and post the output.
Thank you so much for your help Croit. I followed all the the steps you suggested above but the start fails anyway. (see the attached pct start --debug log).

[Update]
I also tried to mount the 2 disks to see if there was my data but seem to be empty.
 

Attachments

Last edited:
The error there is
ERROR start - ../src/lxc/start.c:start:2197 - No such file or directory - Failed to exec "/sbin/init"
either the file /sbin/init itself is missing in the container or it is a link which isn't working anymore. Anyhow, something is off within the container most likely.
You can have a look at the content by mounting the volume in cli (example is for LVM again).
mkdir -p /mnt/test && mount /dev/mapper/pve-vm--100--disk--0 /mnt/test

ls -lah /mnt/test/sbin/init might provide output like
lrwxrwxrwx 1 100000 100000 20 Sep 20 2023 /mnt/test/sbin/init -> /lib/systemd/systemd
and then just check if the linked file exists. If not, it might be best to recreate the container from source.
 
  • Like
Reactions: waltar
Unfortunately the disk is empty.
How is it possible?
I didn't more than convert to template a CT that was fully working.