5

I'm running an Ubuntu 13.04 server with an encrypted home directory (encryptfs). I keep a tmux session open which holds my development environment (vim, etc). When I disconnect, I'll detach the tmux session and then disconnect the ssh connection. Later, when I reconnect, and reattach the tmux session, I'll get errors such as:

fatal: Could not change back to '(unreachable)/*****': No such file or directory

This will often mean that vim (which was still open while detached) saves to the wrong spot, and won't actually write the file to the disk, only to the "unreachable" directory, which seems temporary.

If I run 'pwd' from bash (not doing anything else since reattaching) I get the proper directory /home/***/***. If I run 'git status', I get the message above (no such file), and if I ':pwd' from within vim, I get "(unreachable)/***".

The temporary fix for this is to run 'cd .' before running any other commands, which allows git/vim/etc to actually see the directory. This is quite inconvenient, since I often have many panels/screens open in tmux and I'd have to run 'cd .' on each of them every time I reconnect. And on top of that, I'd have to make sure vim or anything else, is closed before I disconnect, or I'll likely lose data if I'm not careful.

I saw another thread somewhere that attributed this to encryptfs dismounting $HOME upon logout, but there were no replies. This seems like a possible cause, but I have no idea where to begin. Any help?

zhimsel
  • 53
  • 4

1 Answers1

6

If it is sufficient that your ecryptfs protected home directory is not unmounted when you log out, you can remove ~/.ecryptfs/auto-umount and it will stop unmounting when you logout (which is what I do, debian wheezy). I found this thread on askubuntu about the same thing, however the script presented doesn't work. Here is a modified version that does.

#!/bin/bash

if tmux ls 2>&1 >/dev/null; then
  # tmux is still running, do not auto-unmount
  rm $HOME/.ecryptfs/auto-umount
else
  # no tmux server, auto-unmount is OK.
  touch $HOME/.ecryptfs/auto-umount
fi

As mentioned in that thread, you can have it execute as part of your logout script.

Unfortunately, there isn't a good way to allow it to unmount and have all of your applications automatically cd on tmux attach. If that is required, you might consider a tmux key macro to issue a command to each window and panel if you keep your applications in regular locations or have a sane way to accurately detect what app is running in that window or panel; I personally never figured that out.

Andrew Domaszek
  • 5,103
  • 1
  • 14
  • 26