Which device is using this logical volume?

21,202

Solution 1

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
  ...

Solution 2

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.

Share:
21,202

Related videos on Youtube

Lorin Hochstein
Author by

Lorin Hochstein

Updated on September 18, 2022

Comments

  • Lorin Hochstein
    Lorin Hochstein over 1 year

    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?

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 12 years
      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).
  • shgnInc
    shgnInc over 9 years
    After pvdisplay, How to release it?
  • Carlos Troncoso
    Carlos Troncoso about 7 years
    @shgnInc: the LV «IS» a PV of other VG. Inception style.