Can't terminate or remove container

sahostking

Renowned Member
Hi

I'm not sure what has changed but all that was done last on this server was updates.

I am getting this now on new containers it seems:

TASK ERROR: lvremove 'pve/vm-150-disk-1' error: Logical volume pve/vm-150-disk-1 contains a filesystem in use.

How does one sort this out?
 
  • Like
Reactions: bizzarrone
Somehow processes from this container are still running, even if it shows as stopped.

My very RAW solution:
Code:
<?php
$lxc_id=917;
$z=shell_exec("ps aux|awk '{print $2}'");
$f=explode("\n",$z);
foreach($f as $k){
$k=trim($k);
if($k<1) continue;
$a=shell_exec("grep lxc\/".$lxc_id."/ /proc/$k/cgroup");
if(!empty($a)) { echo "$k\n"; system("kill -9 $k"); }
}
?>

After that, lvchange -an -v /dev/pve/vm-917-disk-1

There's probably a much better and efficient solution out there, but i didn't know it. There's a need for an efficient way to find processes of a container, from the host.
 
Last edited:
You should add another slash after `".$lxc_id."` so killing ct 100 doesn't include 1000 and 10000 ;-).
You can iterate through `/sys/fs/cgroup/pids/lxc/$ctid/**/cgroup.procs` entries as an alternative to go through only the processes of that container, but there's no single collective file for this, you have to walk the cgroup subdirectory tree.
 
  • Like
Reactions: BelCloud

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!