LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   The "device is busy" but I can not find out why (https://www.linuxquestions.org/questions/linux-newbie-8/the-device-is-busy-but-i-can-not-find-out-why-4175506634/)

taylorkh 05-31-2014 06:22 PM

The "device is busy" but I can not find out why
 
Here is the situation...

I have established an encypted partition on a drive in my server (Ubuntu 12.04 server) using cryptsetup. It seems to work OK. When I wish to access the partition I invoke the following script on the server via ssh from my PC
Code:

#!/bin/bash

sudo cryptsetup luksOpen /dev/sdb1 sdb1
sudo mount /dev/mapper/sdb1 /crypt

echo Partition Attached - press enter
read nothing

and provided I enter the correct passphrase the contents of the encryped partition appear under /crypt

I have the mount point /crypt exported to my PC, and my PC only with nfs. The line in /etc/exports reads
Quote:

/crypt 192.168.0.112(rw,async,no_root_squash)
This also works fine. I can mount the exported /crypt on my PC (CentOS 6) and see the contents of the encrypted partition on the server.

However, the problem comes when I attempt to umount the mount point on the server.

If I do thus:

mount the encrypted partition on the server
mount the exported directory on the PC
umount the exported directory on the PC

I can umount the mount on the server.

If I do thus:

mount the encrypted partition on the server
mount the exported directory on the PC
access - even to read - the exported directory (using the PC)
umount the exported directory on the PC
Attempt to umount the mount point on the server

I get the following error
Quote:

ken@taylor14:~$ sudo umount /crypt
umount: /crypt: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
I have tried lsof and fuse and studied their man pages and examples on-line but I cannot find any guilt suspects holding files in /crypt.

I am at a loss as to what to try next. Can anyone make any suggestions?

TIA,

Ken

potato_farmer 05-31-2014 07:42 PM

After unmounting from the PC, try the following command on both the server and the PC and see if you get any results.

Code:

lsof | grep "/crypt"

taylorkh 05-31-2014 08:33 PM

Thanks potato_farmer,

I mounted the encrypted drive on the server and issued the command on the server - no results.

I mounted the nfs exported directory on the server from the PC - no results on the server nor the PC.

I accessed the mounted directory with gnome-commander on the PC - again, nothing on either machine.

I opened a file in directory - from on the PC - nothing on the server but I do see the file in the results on the PC

I closed the file on the PC and it disappeared from the lsof results on the PC. It is still NOT in the results on the server.

A sound approach but unfortunately no hit of what is still open. I suspect I need to stop/start or restart the nfs service but I have not figured out how to do that.

Thanks again,

Ken

haertig 05-31-2014 08:41 PM

Did you try the "lazy" option to umount?

i.e.,
Code:

umount -l /crypt
(that's a lower case letter ell option)

Also, make sure you do not have some directory under /crypt as your current working directory.

Try this:
Code:

cd /
umount -l /crypt


taylorkh 06-01-2014 05:09 AM

Thanks haertig,

I have tried the lazy option with umount on the server. It "works" except that the underlying device /dev/mapper/sdb (the encrypted partition) is then still busy and I cannot shut it off with "sudo cryptsetup remove sdb1".

You make a good point about not being in the /crypt tree. pwd shows me to still be in my home directory. Truly a puzzler.

Thanks again,

Ken

Shadow_7 06-01-2014 07:56 AM

It could be that some kernel modules are in play with regards to the device and filesystem. And of course that does not show up in the lsof or fuser results.

selfprogrammed 06-02-2014 07:24 PM

Check /var for locks.

taylorkh 06-02-2014 08:23 PM

Thanks selfprogrammed,

A good suggestion but no luck. I examined /var and found
Quote:

lrwxrwxrwx 1 root root 9 Apr 26 18:45 lock -> /run/lock/
I then looked at /run/lock and found
Quote:

drwxr-xr-x 2 whoopsie whoopsie 60 Jun 2 21:08 whoopsie
I mounted the encryted partiton, accessed it with gnome-commander on the server and observed no locks. But it is now busy if I try to umount.

Ken

selfprogrammed 06-03-2014 01:18 PM

I assume you have tried
>> fuser -m /dev/sdb1


Someone else solved a similar problem:
http://ubuntuforums.org/showthread.php?t=1775679


Try issuing the command from 'root'. That bypasses all permissions problems.
If no program has it open, it is usually a permission problem.


If you get desperate there are two approaches.

1. When it comes time to shutdown the system. Try killing off processes manually one at a time until the umount command works.

2. Install print stmts in umount and the kernel to track exactly what is making it busy.
(The kernel should have had this years ago).

taylorkh 06-04-2014 08:29 PM

Thanks again selfprogrammed. fuser -m returns a lot of process numbers. Interestingly the same process numbers are returned regardless if the partition is mapped or not.

I generally bring this server up only if I need to backup something to it or recover something which has been backed up. I may pick at the issue a little more. However, it is not a show stopper. I can shut down the server successfully and that umounts /crypt and closes the encrypted file system without apparent error.

Thanks again,

Ken


All times are GMT -5. The time now is 04:18 PM.