Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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). –  Gilles Oct 11 '11 at 23:38
add comment

2 Answers

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|improve this answer
add comment
up vote 2 down vote accepted

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
  ...
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.