[dm-crypt] force luksClose

Benjamin Eberhardt eberhab at gmail.com
Thu Feb 21 22:16:34 CET 2013


Hi all,

the aboved mentioned problem happened to me again and this time i made sure
i would try to find every open file and close it first, then unmount the
partition but still luksClose did not work...

The partition is unmounted but still i get this error:

# cryptsetup luksClose sata_p1_2TBa
Device sata_p1_2TBa is busy.

no open files on *sata* davice (both device and mountpoint are called the
same)

# lsof |grep sata
#

blkid doesnt really help me either:

# lsblk
NAME                MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                 7:0    0   512M  1 loop
└─cryptoswap (dm-0) 254:0    0   512M  0 crypt
mmcblk0             179:0    0  14,9G  0 disk
├─mmcblk0p1         179:1    0    72M  0 part
└─mmcblk0p2         179:2    0  14,9G  0 part  /
sdc                   8:32   0   1,8T  0 disk
sdd                   8:48   0   1,8T  0 disk
└─sdd1                8:49   0   1,8T  0 part

dmsetup force close also does not work:

# dmsetup remove -f sata_p1_2TBa
device-mapper: remove ioctl failed: Device or resource busy
Command failed

here you can see how the mapper device lost its physical device:

/dev/mapper/sata_p1_2TBa is active and is in use.
  type:    LUKS1
  cipher:  -
  keysize: 0 bits
  device:  (null)

How can i identify which process still keeps the device open? Why is still
happening allthough the filesystem is already unmounted? And last, would it
not be better to associate the mapper devices with the uuid of the physical
device? Then it could theoretically work again after the usb disk has
reconnected?

Thank you,
Benjamin



On 25 December 2012 13:17, Benjamin Eberhardt <eberhab at gmail.com> wrote:
>
> Hi,
>
> thank you very much for your replies. I tried to reproduce the problem
> which I had once in order to supply more details, but so far the
> procedure you described works very well (identifying the culprit and
> luksClose). Ill get back to you if the problem should occur again.
>
> Merry Christmas :)
> Benjamin
>
>
> On 29 November 2012 15:53, Milan Broz <gmazyland at gmail.com> wrote:
> > On 11/29/2012 02:43 PM, Matthias Schniedermeyer wrote:
> >
> >> IOW. It's a problem of finding the culprit who holds the mountpoint
> >> open.
> >
> > Exactly. You cannot remove open (in-use) device-mapper device.
> >
> > You can it replace with "error" target though (this will detach
> > underlying device from mapping.).
> >
> > Just run "dmsetup remove -f <name>"
> > instead of cryptsetup remove/luksClose <name>"
> >
> > But the dead DM device will still be in system. I can easily add such
> > force option to cryptsetup as well but it will not help much.
> >
> > The correct way is to force unmout fs (or whatever use this device)
> > and then remove crypt mapping (see lsblk, lsof etc).
> >
> > Milan
> >
> > p.s.
> > There is a request to add "auto" removal flag for device-mapper devices
> > (automatic remove after last close, similar to loop auto removal).
> >
> > Once this option will be in kernel cryptsetup will support it too.
> > But this will not help with your situation anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.saout.de/pipermail/dm-crypt/attachments/20130221/e8215d41/attachment.html>


More information about the dm-crypt mailing list