I am using pam_mount to mount user home areas as tmpfs on login, and to unmount the area on logout. The line in question in pam_mount.conf.xml is as follows:
<volume options="size=100m,uid=%(USERUID),gid=%(USERGID),mode=0700" mountpoint="~" uid="1000-50000" fstype="tmpfs" />
The mounting part works - the user gets their home area with correct permissions and correct size for them to use. The problem is with unmounting on logout. The home area stays mounted after logout, and looking in auth.log pam_mount says that the device is busy, and thus it was unable to unmount. But the problems don't stop there - trying to unmount the area manually as root also fails due to the device being busy. I have checked with fuser and (at least with the best of my ability) using lsof, and no files are open within the home area. The only way I can get it to 'unmount' is to do a lazy unmount, but even that isn't a real unmount. Forcing unmount has no effect either.
My first thoughts were that tmpfs was somehow bugged, but this was disproven since adding another line to mount a tmpfs somewhere other than the home area works fine. I have tried using the logout kill option in the configuration to kill any processes that might still be running, but also to no avail. And now, at the end of my rope, I come here in the hopes of finding a possible solution.
(X)ubuntu 12.04, heavily customized XFCE desktop, LightDM with KDE greeter, fully updated until a few days ago. Running on an SSD, using open-source graphics drivers.
Alright, I did a bit more testing on this. I disabled the pam_mount tmpfs line, and mounted a tmpfs as my home area (all of this done while logged in as root). I then logged out of root, logged in as myself (everything working OK with regards to the desktop), then logged out again and back in as root. Attempting to umount the home area again gives a device is busy error. I tried deleting everything inside the home area and trying again - still no joy. Yet again, the only thing that can successfully unmount the tmpfs is a lazy unmount.
I used the following specific commands:
mount -t tmpfs -o uid=1000,gid=1000,size=100m,mode=0700 none /home/user
(at this point I logged in as myself)
Now that pam_mount has been ruled out, this thread is a general question of why does a home area mounted as tmpfs not allow itself to be unmounted again properly? Unfortunately I cannot find a way to change the title of this thread - perhaps a mod could do that?
EDIT: I have narrowed it down further - logging in though a virtual terminal does not 'corrupt' the tmpfs, while logging in though an X session does. I uninstalled gvfs just in case it was the culprit (these kinds of things usually are) but it was not. Anything else to try, short of uninstalling all graphical apps?
EDIT2: The mystery deepens. Doing the same thing on my Arch Linux install (again with XFCE) the unmounting worked just fine. I am now struggling to understand what is causing these problems.