Friday, July 6, 2018

12.04 - Unmount fuse mountpoints on logout?

I have a couple of folders containing compressed data.
I have one application which needs to access the uncompressed version of the same data.



A simple way to solve that for me has been to run a script upon login looking something like this:



#!/bin/bash
rar2fs -o allow_other /home/user/source1 /home/user/target1
rar2fs -o allow_other /home/user/source2 /home/user/target2

rar2fs -o allow_other /home/user/source3 /home/user/target3
rar2fs -o allow_other /home/user/source4 /home/user/target4


To get the script to run when I login was simple, I just added it using 'Startup Applications'.



I just now realized however that my approach comes up short when I log out then back in again.



My guess is it works badly since the rar2fs/fuse mounts happen within my encrypted home folder. When I log out I think ubuntu locks the encryption, but my mount probably stick around even though both source and target are inaccessible.




Then when I login again, adding insult to injury, I try to do the mount again. Leaving me with mountpoints that spit out errors like when I try to access them:



Error: Error when getting information for file '/home/user/target1':Transport endpoint is not connected


My guess is this could be prevented if I could just get the system to unmount properly on logout, but I don't know how to get a script to run upon logout.



How does one properly shut down a fuse mount before logout?



EDIT: I'm using unity.




EDIT:



Running fusermount -u using session-cleanup-script I get the following error:



fusermount: bad mount point /home/user/target1: No such file or directory


I've also tried adding the umount loop to my mount script so that it should umount the folders before mounting them if they are already mounted, but those umounts fail as well:




fusermount: failed to unmount /home/user/target1: Invalid argument


My guess is that the first solution fails because the encrypted home locks before the cleanup-script is run. Perhaps there is some way to hook into the encryption routine and have a script run before the home folder locks?



If I run the umount-script manually before logging out the mountpoints work as expected when I login again.

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...