1

I've installed Ubuntu 16.04 LTS. During the installation, I've checked 'encrypted home' but home folder is in the same partition as the root (i.e in '/'). I know that the usage of TRIM on LUKS devices is different but I could not find anything about how to use it in my case. I also know that the installer uses ecryptfs for home folder encryption. The only thing I could found is this link TRIM and encrypted home folders, but it does not provide an answer. So the question is: How can I use TRIM on my encrypted home folder (not partition)? Several info you might need:

SSD: Corsair Force LS SSD

~$ lsblk
NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda              8:0    0 223.6G  0 disk  
├─sda1           8:1    0   512M  0 part  /boot/efi
├─sda2           8:2    0 215.2G  0 part  /
└─sda3           8:3    0   7.9G  0 part  
  └─cryptswap1 252:0    0   7.9G  0 crypt [SWAP]

~$ uname -r
4.4.0-21-generic
2
  • Why do you want to use trim ? Ubuntu > 14.04 trims the disk automatically. (See: /etc/cron.weekly/fstrim) – pLumo Jun 14 '17 at 9:39
  • /home/username doesn't support trim. It's enough to trim root which contains /home encrypted files – LeonidMew Feb 20 '18 at 5:52
0

Encrypted home folder are virtualy mounted unencrypted.

All your files in your encrypted /home/username folder exist real in:/home/.ecryptfs/username in encrypted format.

So if you use "fstrim -av" you are trimming the complete disk unneeded.

~$ fstrim -av
/home/username: 271.1 GiB (291104260096 bytes) trimmed
/: 0 B (0 bytes) trimmed

After every reboot it will do the same.

So it is better to trimm only the real files written on disk:

fstrim -v /

Add a weekly scheduler:

sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system
sudo systemctl enable fstrim.timer

and edit /etc/systemd/system/fstrim.service

[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -v /

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.