[SOLVED] How to delete a VM or Container that has no storage and no or missing storage pool.

francoisd

Renowned Member
Sep 10, 2009
49
3
73
Hi,

I have an old VM that was existing on an old pool that I stopped and deleted in between.
The VM is still listed in the web GUI, but I can't delete it.
From the GUI, I have the error :
TASK ERROR: storage 'pool1' does not exist
(which is true). And from the command line:

Code:
root@hystou2:~# grep 118 /etc/pve/.vmlist
"118": { "node": "hystou3", "type": "lxc", "version": 76 },
root@hystou2:~# qm destroy 118
Configuration file 'nodes/hystou2/qemu-server/118.conf' does not exist
 
Last edited:
Just realized, since it's an LXC, qm might not be the best way ;-)

So :
Code:
root@hystou2:~# lxc-destroy --name=118
root@hystou2:~# lxc-destroy --name=118
lxc-destroy: 118: tools/lxc_destroy.c: main: 242 Container is not defined
root@hystou2:~# grep 118 /etc/pve/.vmlist
"118": { "node": "hystou3", "type": "lxc", "version": 76 },

As you can see, it seems to delete the container on the first execution since there's no error, and a "Container is not defined" during the second execution. But it remains in the GUI and in the /etc/pve/.vmlist

So, how should I definitely delete traces of this container ?
 
You mean 118.conf, but no, there's none in qemu-server. However, thanks for this double check, since I found the definition of the container in :
/etc/pve/lxc/118.conf

So, the lxc-destroy did not remove it.

After digging a bit more in the docs, the Proxmox way to manage lxc is with the pct command:
Code:
root@hystou3:~# pct destroy 118
storage 'pool1' does not exist
At least, the error message is consistent with the one from the Web GUI.
The --force gives the same answer:
Code:
root@hystou3:~# pct destroy 118 --force
storage 'pool1' does not exist
 
Last edited:
Hi,

Bash:
root@hystou3:~# pvesm add dir pool1 --path /mnt/pool1
root@hystou3:~# pvesm list pool1
Volid Format  Type      Size VMID
root@hystou3:~# pct destroy 118
unable to parse directory volume name 'vm-118-disk-0'
root@hystou3:~# pct destroy 118 --force 1 --purge 1
unable to parse directory volume name 'vm-118-disk-0'

Well, this did not really help. So, I finally root@hystou3:~# mv /etc/pve/lxc/118.conf /root/Archive/ which almost instantly removed the LXC 118 from the web interface.

Was not really the way I was expecting, but it seems fine.

Thanks ph0x,
 
Try this next time:
lxc-ls --fancy
lxc-destroy {-n name} [-f] [-s]

Code:
root@NODE1:~# lxc-ls --fancy
NAME STATE   AUTOSTART GROUPS IPV4        IPV6 UNPRIVILEGED
101  RUNNING 0         -      10.10.1.101 -    true         
103  STOPPED 0         -      -           -    true         
104  STOPPED 0         -      -           -    true         
201  STOPPED 0         -      -           -    true         
302  STOPPED 0         -      -           -    true         
303  STOPPED 0         -      -           -    true         
304  STOPPED 0         -      -           -    true         
305  STOPPED 0         -      -           -    true         
306  STOPPED 0         -      -           -    true         
root@NODE1:~# lxc-destroy -n 103 [-f] [-s]
root@NODE1:~# lxc-destroy -n 104 [-f] [-s]
root@NODE1:~# lxc-destroy -n 105 [-f] [-s]
lxc-destroy: 105: ../src/lxc/tools/lxc_destroy.c: main: 240 Container is not defined
root@NODE1:~# lxc-destroy -n 201 [-f] [-s]
root@NODE1:~# lxc-destroy -n 202 [-f] [-s]
lxc-destroy: 202: ../src/lxc/tools/lxc_destroy.c: main: 240 Container is not defined
root@NODE1:~# lxc-destroy -n 302 [-f] [-s]
root@NODE1:~# lxc-destroy -n 304 [-f] [-s]
root@NODE1:~# lxc-destroy -n 305 [-f] [-s]
root@NODE1:~# lxc-destroy -n 306 [-f] [-s]
root@NODE1:~# lxc-ls --fancy
NAME STATE   AUTOSTART GROUPS IPV4        IPV6 UNPRIVILEGED
101  RUNNING 0         -      10.10.1.101 -    true         
303  STOPPED 0         -      -           -    true         
root@NODE1:~# lxc-destroy -n 303 [-f] [-s]
root@NODE1:~# lxc-ls --fancy
NAME STATE   AUTOSTART GROUPS IPV4        IPV6 UNPRIVILEGED
101  RUNNING 0         -      10.10.1.101 -    true         
root@NODE1:~#
 
Code:
root@NODE1:/etc/pve/local# cd qemu-server

root@NODE1:/etc/pve/local/qemu-server# ls

100.conf  400.conf  901.conf  903.conf  905.conf  907.conf

200.conf  900.conf  902.conf  904.conf  906.conf

root@NODE1:/etc/pve/local/qemu-server# rm 100.conf

root@NODE1:/etc/pve/local/qemu-server# rm 200.conf

root@NODE1:/etc/pve/local/qemu-server# rm 400.conf

root@NODE1:/etc/pve/local/qemu-server# rm 900.conf

root@NODE1:/etc/pve/local/qemu-server# rm 901.conf

root@NODE1:/etc/pve/local/qemu-server# rm 902.conf

root@NODE1:/etc/pve/local/qemu-server# rm 903.conf

root@NODE1:/etc/pve/local/qemu-server# rm 904.conf

root@NODE1:/etc/pve/local/qemu-server# rm 905.conf

root@NODE1:/etc/pve/local/qemu-server# rm 906.conf

root@NODE1:/etc/pve/local/qemu-server# rm 907.conf

root@NODE1:/etc/pve/local/qemu-server#
 
  • Like
Reactions: pete.magnusson
I solved this by:

1. edit /etc/pve/lxc/100.conf or whatever number your container is.
2. find the line rootfs: usb_thin:vm-111-disk-0,size=16G.
3. edit usb_thin or whatever the dead drive was called to a storage pool that exists.
4. then pct destroy 100 works or in the Proxmox GUI destroy works too.

I guess just check that the new storage pool doesn't have a disk with the same name, otherwise it may delete that disk.
 
I solved this by:

1. edit /etc/pve/lxc/100.conf or whatever number your container is.
2. find the line rootfs: usb_thin:vm-111-disk-0,size=16G.
3. edit usb_thin or whatever the dead drive was called to a storage pool that exists.
4. then pct destroy 100 works or in the Proxmox GUI destroy works too.

I guess just check that the new storage pool doesn't have a disk with the same name, otherwise it may delete that disk.
Perfect! Resolved my issue of stupidly deleting a (test) LUN off of my Synology NAS holding a few LXC Containers.
 

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!