TASK ERROR: lvremove 'pve/vm-111-disk-0' error: Logical volume pve/vm-111-disk-0 contains a filesystem in use

gusto

Well-Known Member
Feb 10, 2018
78
0
46
24
I use Proxmox 5.4-13, just one node. Today I installed LXC Centos 7. I want to use NFS server in LXC. I did this:
I installed NFS on the node
Code:
apt-get install nfs-kernel-server
Then I installed LXC centos 7 (ID 111)
Code:
nano /etc/pve/lxc/111.conf
Code:
lxc.apparmor.profile = unconfined
I Now start the LXC Centos 7 and install NFS.

Code:
yum -y install nfs-utils
systemctl enable nfs-server.service
systemctl start nfs-server.service

Code:
mkdir -p /nfs/abc
chown nfsnobody:nfsnobody /nfs/abc
chmod 755 /nfs/abc

Code:
nano /etc/exports

Code:
/nfs/abc  *(ro,sync,no_wdelay,insecure_locks,no_root_squash,insecure,no_subtree_check)

Code:
exportfs -a

Everything seems to be all right. I want now to destroy the LXC. I can't destroy the LXC because

Code:
TASK ERROR: lvremove 'pve/vm-111-disk-0' error:   Logical volume pve/vm-111-disk-0 contains a filesystem in use.

Can anyone advise me how to destroy the LXC?
 
I guess there is still something running related to your container.
 
probably rebooting your host is enough
 
After restart I can destroy the LXC. How to do without restarting of the host.
 
You need to find out what is accessing the filesystem with lsof for example. If i would have to take a guess whats accessing the filesystem: you did not stop the nfs server.
 
When I run a command on a host
Code:
lsof | grep vm-111-disk
the output is
Code:
....
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
lsof: no pwd entry for UID 48
....
 
I've run into the same problem. AFAICS it happens if the NFS server is not stopped in a clean way.

To be more specific I was able to reproduce the problem with running 'pct stop' on the host. The container in question was configured with nesting=1 and was running a NFS server. At least one NFS client had mounted and unmounted a share from the NFS server. (At the time of executing 'pct stop' no client had mounted a NFS share.)

Code:
$ pct stop 1234
$ pct destroy 1234
lvremove 'pve/vm-1234-disk-0' error:   Logical volume pve/vm-1234-disk-0 contains a filesystem in use.
$ dmsetup info -c pve-vm--1234--disk--0
Name                  Maj Min Stat Open Targ Event  UUID
pve-vm--1234--disk--0 253  16 L--w    1    1      0 LVM-Y0SVlL0hWY0OuYzBUXgqzXOSz3aWxvyJ3WpypGMaJPjnSC0B4S3veeS1CfvTugx8

I tried a lot of things but was unable to find any process that still referenced the logical volume:
* searching through the output of 'lsof'
* looking in /proc and /sys for a reference to the container/volume
* dropping caches of the OS
* uninstall nfs-kernel-server on the host

So I guess it's the kernel that holds the reference. (Which isn't surprising since if I'm not mistaken the main functionality comes from the nfsd kernel module.)

If there is an alternative to rebooting the host to recover from such a situation, I'd be very interested to learn about it.
 

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!