Linux – How to encrypt Linux (Debian 8) post-installation and what are the consequences

disk-encryptionencryptionlinux

I have certain folders in my Linux partition which I need to make sure no one can access unless the log in with my login password (or root one).

I know that during installation I can encrypt with LUKS and I can encrypt certain folders with encfs / Truecrypt.

However the encryption password is independent from current user and root password and unless I store it (which I guess it'd make it useless), I'd have to insert password manually each time.
Also, if any program on startup is accessing certain files (e.g. Timeshift for boot backups) will fail.

Therefore I'm looking for a solution which allows me to encrypt the whole system (or only certain folders) post OS-installation which is dependent on user or root password and which

  • doesn't impact any application which has the permission to access those folders (at any time after login)
  • doesn't make impossible or nearly impossible to recover the system should it fail (I read that even GRUB has issue if the partition is encrypted)

Best Answer

You will need to use a different user than the account that you are setting up encryption for (this is primarily the 'root' user but could be any user who has access to 'sudo'). Do the following:

  • Install these packages: "apt-get install ecryptfs-utils cryptsetup"
  • Run the following using either root or a user with root privileges: * "ecryptfs-migrate-home -u PutTheUserNameWhoYouAreEncryptingTheirHomeDirHere"
  • Lastly encrypt the swap by running: "ecryptfs-setup-swap"

Good luck :)

Related Question