Ubuntu – How to completely remove ecryptfs from the system and delete .Private

ecryptfs

Few days back I have installed ecryptfs, created a private directory using it. Now my Ubuntu login became super slow. I have tried removing ecryptfs from Synaptic. I found It, it can not be deleted that way. Somewhere I have read about this command

ecryptfs-setup-private --undo

But this command displays a rather confusing list of commands on terminal. I don't want to mess up my installation, neither want to loose my administrator account.

Now my question is, how can I safely remove /home/user/Private (.Private) and remove ecryptfs encryption ?

Best Answer

Actually ecryptfs tells you very specifically what to do when you run ecryptfs-setup-private --undo, just follow its instructions.

Obtain your Private directory mountpoint

$ PRIVATE=`cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private`

This command populates the $PRIVATE variable with the path to your private directory. Either the path is stored in ~/.ecryptfs/Private.mnt file (where ~ is your home directory) or if the file doesn't exist, it will fall back to ~/Private path. You can then run echo $PRIVATE command to verify content of the PRIVATE variable. When you see $PRIVATE in the following commands, it will be substituted with the contents of the variable, ~/Private in your case.

Ensure that you have moved all relevant data out of your $PRIVATE directory

This is important.

Unmount your encrypted private directory

$ ecryptfs-umount-private

eCryptFS is kind of a filesystem which is mounted in user space (Wikipedia explains what's mounting about. That's also the reason why the Private folder cannot be removed so easily. Think of it as kind of proxy which transparently encrypts and decrypts your files. This command un-mounts the folder which effectively disables the encryption.

Make your Private directory writable again

$ chmod 700 $PRIVATE

chmod sets file permissions. In this case, you say: "make file/directory stored in $PRIVATE readable, writable and executable for me (700)" – you can't otherwise delete the directory since you don't have write access.

Remove $PRIVATE, ~/.Private, ~/.ecryptfs

Note: THIS IS VERY PERMANENT, BE VERY CAREFUL

$ rm -rf $PRIVATE ~/.Private ~/.ecryptfs

This does exactly what it says. rm command means ReMove, -r means recursive (to recursively remove directories), and f means Force ("stop nagging me, just delete it"). This will remove all these three directories: $PRIVATE, ~/.Private, ~/.ecryptfs

If you want to, you can remove these directories manually from Nautilus (just check "View > Show hidden files" to see .Private and .ecryptfs directories in your home dir).

Uninstall the utilities (this is specific to your Linux distribution)

$ sudo apt-get remove ecryptfs-utils libecryptfs0

This will remove ecryptfs-utils and libecryptfs0. You can do this from Synaptic instead or just ignore it if you want to keep eCryptFS around (e.g. for other users).

If you follow these instructions, there's no risk of wrecking your system or losing your files – unless, of course, you don't backup your files from ~/Private directory.