In order to make sure one of my current projects gets backed up regularly, I keep the files on a server that I mount using samba so that I can access the files as if they’re on my system. This is easier than finding a way to back up my system because I can force the system to mount the share at boot and never have to think about saving the files out (well, except that I’m paranoid and am also keeping versions in CVS [no, not the drug store — it’s a computer dork thing]). Occasionally, samba mounts go haywire, though, and when this happens, you can often un- and remount them to solve the problem.
When I tried this today, I got a “device is busy” error and couldn’t unmount the share even when I tried to force it. I googled for a minute and found this site, which pointed me in the right direction. Although I had checked all my terminals to verify that my cwd wasn’t on the share in question, I thought it’d be good to check and see if there was somehow somebody (me or someone else) using the share. And it turns out that the fuser command allows you to see this sort of info:
[houston]# fuser -vmu /home/files USER PID ACCESS COMMAND /home/files root 1553 ..c.. su houston 9046 ..c.. bash
The “c” beside these entries means that the file system is in question is the cwd for that process. So in these cases, I was in /home/files when I opened a new session (in one case an su and in another a whole other terminal session) from which I then changed directories (meaning that it wasn’t obvious to me that I was actually using the file system because pwd showed me being elsewhere). Once I killed the processes, I was able to unmount the share, and when I remounted, the flakiness was gone. Nifty.
Thanks for the writeup. Didn’t know fuser showed that info. Came in very handy just now.