System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't remove logical volume RHEL5.2

Steven McCoy
Valued Contributor

Can't remove logical volume RHEL5.2

Hey guys,

We're trying to remove a logical volume, but it claims it is in use. Here are the details:

$ grep lvol21 /etc/fstab
/dev/vg01/lvol21 /system_backups ext3 defaults 1 2

$ sudo umount /dev/mapper/vg01-lvol21

$ sudo lvremove /dev/mapper/vg01-lvol21
Can't remove open logical volume "lvol21"

$ sudo lvchange -an /dev/mapper/vg01-lvol21
LV vg01/lvol21 in use: not deactivating

$ sudo dmsetup remove vg01-lvol21
device-mapper: remove ioctl failed: Device or resource busy
Command failed

$ sudo lsof /system_backups/
$

$ sudo fuser /system_backups/
$

9 REPLIES
Ivan Ferreira
Honored Contributor

Re: Can't remove logical volume RHEL5.2

Post the ouput of the mount command, check /proc/mounts, also, run lsof or fuser over the device itself, not the mount point.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Steven E. Protter
Exalted Contributor

Re: Can't remove logical volume RHEL5.2

Shalom,

Try lvremove first

You may need to vgchange -a n vg01

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

Thank you for the replies, guys. That vgchange command makes all logical volumes within the Volume Group (vg01) unavailable, correct? There is a live/production filesystem within vg01, unfortunately.

Here are the command results:

$ sudo lsof /dev/mapper/vg01-lvol21
$ sudo lsof /dev/vg01/lvol21
$ cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/vg00/lvol5 /usr ext3 rw,data=ordered 0 0
/dev/vg00/lvol4 /opt ext3 rw,data=ordered 0 0
/dev/vg00/lvol9 /oarchive ext3 rw,data=ordered 0 0
/dev/vg00/lvol6 /usr/local ext3 rw,data=ordered 0 0
/dev/vg00/lvol3 /tmp ext3 rw,data=ordered 0 0
/dev/vg00/lvol8 /oracle ext3 rw,data=ordered 0 0
/dev/vg00/lvol7 /var ext3 rw,data=ordered 0 0
/dev/vg00/lvol2 /home ext3 rw,data=ordered 0 0
/dev/cciss/c0d0p1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
/dev/vg01/lvol20 /u01 ext3 rw,data=ordered 0 0
/dev/vg01/lvol22 /db_backups ext3 rw,data=ordered 0 0
/dev/vg00/lvol10 /tmp1_mnt ext3 rw,data=ordered 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/etc/auto.misc /misc autofs rw,fd=6,pgrp=4746,timeout=300,minproto=5,maxproto=5,indirect 0 0
-hosts /net autofs rw,fd=12,pgrp=4746,timeout=300,minproto=5,maxproto=5,indirect 0 0
nfsd /proc/fs/nfsd nfsd rw 0 0
aspt5db1:/oarchive_nfs /oarchive_nfs nfs rw,vers=3,rsize=32768,wsize=32768,hard,proto=tcp,timeo=600,retrans=2,sec=sys,addr=aspt5db1 0 0
$ mount
/dev/mapper/vg00-lvol1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/mapper/vg00-lvol5 on /usr type ext3 (rw)
/dev/mapper/vg00-lvol4 on /opt type ext3 (rw)
/dev/mapper/vg00-lvol9 on /oarchive type ext3 (rw)
/dev/mapper/vg00-lvol6 on /usr/local type ext3 (rw)
/dev/mapper/vg00-lvol3 on /tmp type ext3 (rw)
/dev/mapper/vg00-lvol8 on /oracle type ext3 (rw)
/dev/mapper/vg00-lvol7 on /var type ext3 (rw)
/dev/mapper/vg00-lvol2 on /home type ext3 (rw)
/dev/cciss/c0d0p1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/mapper/vg01-lvol20 on /u01 type ext3 (rw)
/dev/mapper/vg01-lvol22 on /db_backups type ext3 (rw)
/dev/mapper/vg00-lvol10 on /tmp1_mnt type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
aspt5db1:/oarchive_nfs on /oarchive_nfs type nfs (rw,rsize=32768,wsize=32768,hard,addr=209.82.230.121)

$ grep -i lvol21 /etc/mtab /proc/mounts
$
Tony Cicone
Honored Contributor

Re: Can't remove logical volume RHEL5.2

How about the "--force" option for lvremove?

Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

Unfortunately, '--force' does not work, either:

$ sudo lvremove --force /dev/mapper/vg01-lvol21
Can't remove open logical volume "lvol21"
$ sudo lvremove /dev/vg01/lvol21
Can't remove open logical volume "lvol21"
Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

Sorry, I meant to paste:

$ sudo lvremove --force /dev/mapper/vg01-lvol21
Can't remove open logical volume "lvol21"
$ sudo lvremove --force /dev/vg01/lvol21
Can't remove open logical volume "lvol21"
Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

Well, we ended up taking the box out of production, rebooting it (with that filesystem commented out in /etc/fstab), and were able to delete the logical volume. Not the solution I was really wanting, but had to do what we could. Thanks everyone for all your replies and help.
Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

Rebooting with the hung filesystem commented out in /etc/fstab.
Steven McCoy
Valued Contributor

Re: Can't remove logical volume RHEL5.2

FYI, this command works very well for situations like that above:

fuser -km /system_backups