How to enable the trim service to run on LUKS encrypted homepartition on SSD.

Hi Moderators and community forum members,

I seek your support and guidance in solving this issue and look forward
to some replies aimed at a non-technical (though long-term) openSUSE
user like myself.

I recently purchased a 2.5" 1TB Evo 860 SSD and installed it on a
Probook 6570b Notebook. I had a clean install of win7 and win 10 pro OS
(x64) versions in dual boot mode on a 350GB HDD (7.5k rpm) and cloned
same onto the new SSD using ICY BOX Docking and Cloning Station. This
process left all space after 350GB as unallocated free space and I then
partitioned and formatted same into a number of Linux and 1 ntfs data
partitions using Paragon HD Manager on bootable media.

Downloaded and installed the Samsung Magician software in both Win 7 and
Win 10 OSes and checked and optimised the SSD. I have set 20% of SDD for
OP and firmware was also updated to latest.

Thereafter I installed openSUSE Leap 15 Plasma DE (and formatted the
partitions again using the openSUSE partition management software). I
have a / (40GB), swap (approx 10GB), Iso (30GBB mounted /home/iso) and a
LUKS encrypted Home partition (approx 100GB). I installed from a DVD iso
on a usb stick, did a full update and the switch to the Pacman repo for
mmedia stuff and the system is working OK thus far.

Lastly, I did some online reading and was able to check the following:

fstrim -v /home

fstrim: /home: the discard operation is not supported
:~ # cat /etc/crypttab
cr_sdaX UUID=7ceff40c-73f9-49ae-xyzx-1234567abcd1
:~ #

The fstrim -av command ran OK on the / and /home/iso unencrypted partitions.

~ # systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled;
vendor preset: enable>
Active: active (waiting) since Sat 2019-01-26 17:42:47 AEDT; 11min ago
Trigger: Mon 2019-01-28 00:00:00 AEDT; 1 day 6h left
Docs: man:fstrim

Jan 26 17:42:47 Linux-y1na systemd[1]: Started Discard unused blocks
once a week.
lines 1-7/7 (END)

:~ # systemctl cat fstrim.timer

/usr/lib/systemd/system/fstrim.timer

[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target
:~ #

~ # systemctl status fstrim.service
● fstrim.service - Discard unused blocks
Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static;
vendor preset: disabled)
Active: inactive (dead)
:~ #

Cheers,
Peter

man crypttab
Search for “discard” (without quotes).

On 26/1/19 11:26 pm, arvidjaar wrote:
>
> man crypttab
> Search for “discard” (without quotes).
>

Thanks, I managed to get it working by adding none to the 3rd field and
discard as the fourth field in my /etc/crypttab file. I tried discard on
its own yesterday and it did not work but I am not sure if correct
spacing is required and if I had it. I will experiment with discard only
in the line again and see how it goes.

The following line in /etc/crypttab works:
cr_sdaX UUID=7ceff40c-73f9-49ae-xyzx-1234567abcd1 none discard

Thanks again for the short and simple advice.

Cheers,
Peter

On 27/1/19 1:58 pm, Peter_Abc wrote:
> On 26/1/19 11:26 pm, arvidjaar wrote:
>>
>> man crypttab
>> Search for “discard” (without quotes).
>>
>
> Thanks, I managed to get it working by adding none to the 3rd field and
> discard as the fourth field in my /etc/crypttab file. I tried discard on
> its own yesterday and it did not work but I am not sure if correct
> spacing is required and if I had it. I will experiment with discard only
> in the line again and see how it goes.
>
> The following line in /etc/crypttab works:

> cr_sdaX UUID=7ceff40c-73f9-49ae-xyzx-1234567abcd1 none discard

Just to update the forum readers who may read this.

The following line in /etc/crypttab does NOT work:

cr_sdaX UUID=7ceff40c-73f9-49ae-xyzx-1234567abcd1 discard
Cheers,
Peter