7

I'm trying to remove an LVM logical volume, which I believe is not currently in use.

However, when I attempted to remove it, I get an error:

# lvremove /dev/vg_service1/lv_home Logical volume vg_service1/lv_home is used by another device. 

It's definitely not mounted, as this returns nothing:

# mount | grep lv_home 

Is there any way to tell what is using this logical volume?

1
  • 1
    mount | grep … queries /etc/mtab, and can be unreliable in odd circumstances (filesystem mounted while the root filesystem was read-only, or from within a chroot). Double-check with grep lv_home /proc/mounts (/proc/mounts gives a direct view to the kernel, if you don't do it from a virtual environment). Commented Oct 11, 2011 at 23:38

4 Answers 4

5

Use lsof(8):

# lsof /dev/vg_service1/lv_home 

I don't have access to a Linux box at this very moment to verify its output, but here's what it looks like on my Mac:

# lsof /dev/disk1 | head COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME launchd 1 root cwd DIR 14,4 1564 2 / launchd 1 root txt REG 14,4 415248 7402611 /sbin/launchd launchd 1 root txt REG 14,4 59504 7399166 /usr/lib/libauditd.0.dylib launchd 1 root txt REG 14,4 599232 7402371 /usr/lib/dyld launchd 1 root txt REG 14,4 289054720 8865364 /private/var/db/dyld/dyld_shared_cache_x86_64 launchd 1 root 20r DIR 14,4 170 7402529 /private/var/tmp launchd 1 root 24r REG 14,4 0 9885226 /private/var/run/socketfilterfw.launchd launchd 1 root 25r DIR 14,4 2040 7393527 /private/var/db 

You should see something similar on your system.

4

It turned out that the logical volume was itself part of a volume group. It didn't show up in /proc/mounts or in the output of lsof. The only way I was able to discover this was through the "pvdisplay" command, where it appeared as a physical volume:

# pvdisplay ... --- Physical volume --- PV Name /dev/vg_service1/lv_home VG Name nova-volumes PV Size 179.91 GiB / not usable 4.00 MiB ... 
2
  • 11
    After pvdisplay, How to release it? Commented Oct 18, 2014 at 5:13
  • @shgnInc: the LV «IS» a PV of other VG. Inception style. Commented Feb 23, 2017 at 9:38
1

there is yet another obscure reason why your LVM snapshot may be busy

when running grub-update, it will use grub-mount to mount devices and check if they contain a O.S. and possibly add them to the boot menu; but then grub-update will sometimes fail to unmount them, and in this case it will be impossible to remove the snapshot.

Note that grub-update will be ran automatically when a new kernel is installed, and this may happen because of an automatic security update.

The best option so far is to add GRUB_DISABLE_OS_PROBER=true to /etc/default/grub so that grub-update will not mount anything. I recommend it in any case.

Coming back to the original question: if you cannot unmount your snapshot, try umount /var/lib/os-prober/mount/

Note that, when/if the snapshot is completely full, the snapshot will be invalid, and the above command may fail, in this case your only chance will be a reboot.

0

In my case, I have the same problem. After some searching, someone talk about the nfs service which for file sharing.

so in This case just need to restart the nfs service and then try to remove the logical volume disk:

service nfs-kernel-server restart lvremove -f /dev/vg_service1/lv_home 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.