LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-08-2016, 07:21 AM   #1
PasBern
Member
 
Registered: Dec 2009
Location: Rotterdam, Netherlands
Distribution: Hefftor Linux, MacOS
Posts: 111

Rep: Reputation: 2
TRIM on manually mounted encrypted SSD


Hi all,

I have a second PCIe slot in my Lenovo laptop which I use for a second SSD drive in addition to an NVMe where my system is installed. I have encrypted this drive with dmcrypt and mount it manually after boot up. Putting the drive into /etc/fstab makes my Ubuntu 16.10 (upgraded from 16.04) fail to boot or boot so slowly it is not acceptable. I haven't looked into this issue.

To keep the second SSD fast I want have its cells 'cleaned up' via the trim command. It is formatted with the XFS file system.

There is a weekly cron job for all mounted file systems, but the second SSD seems to be getting slower.

When I execute the fstrim command manually on all mounted file systems, the SSD drive is left out:

Code:
# /sbin/fstrim -v --all || true
/media/pascal/YouTubeCard: 14,8 GiB (15920910336 bytes) trimmed
/home/pascal: 0 B (0 bytes) trimmed
/boot: 0 B (0 bytes) trimmed
/: 0 B (0 bytes) trimmed
There are no fstrim erros in the syslog file:

Code:
cat /var/log/syslog | grep fstrim
I would be very grateful for your help and hints where I should look further.

If you need more information, let me know.
 
Old 11-08-2016, 07:28 AM   #2
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 286

Rep: Reputation: 89
The partition is encrypted. You have to allow the trim operation also in the encryption layer, otherwise the operations from the filesystem layer never actually hit the drive controller. From "man cryptsetup":

Quote:
--allow-discards
Allow the use of discard (TRIM) requests for device. This option is only relevant for open action.
WARNING: This command can have a negative security impact because it can make filesystem-level operations visible on the physical device. For example, information leaking filesystem type, used space, etc. may be extractable from the physical device if the discarded blocks can be located later. If in doubt, do not use it.

A kernel version of 3.1 or later is needed. For earlier kernels this option is ignored.
So, for SSD's it is actually "paranoid security" XOR "drive performance".
 
1 members found this post helpful.
Old 11-10-2016, 12:56 AM   #3
Elizine
Member
 
Registered: Aug 2015
Posts: 54
Blog Entries: 1

Rep: Reputation: Disabled
TRIM on manually mounted encrypted SSD

No. Trim is installed by the installer though but the 2 have no correlation. Trim is enabled based on the brand of your SSD. If the SSD is supported and tested prior and deemded working perfectly trim will be enabled. Otherwise it will be installed and disabled and you need to enable it manually. This is independent of the installer.

So, one installation might have you a working trim from the start; another installation might have you needing to enable it manually.

If not, how could I enable it after the installation?
Code:
From fstrim:

5555            if ! contains "$HDPARM" "Intel" && \
5656               ! contains "$HDPARM" "INTEL" && \
5757               ! contains "$HDPARM" "Samsung" && \
58                ! contains "$HDPARM" "SAMSUNG"; then
59                 echo "device $DEV is not an Intel or Samsung drive"
 58               ! contains "$HDPARM" "SAMSUNG" && \
 59               ! contains "$HDPARM" "OCZ" && \
 60               ! contains "$HDPARM" "SanDisk" && \
 61               ! contains "$HDPARM" "Patriot"; then
 62                echo "device $DEV is not a drive that is known-safe for trimming"
6063                continue
6164            fi
6265        fi
 
  


Reply

Tags
fstrim, ssd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Access To Encrypted SSD Partition With Native Password in SSD>SATA Enclosure skidvicious Linux - Hardware 5 12-03-2015 04:40 PM
adding --allow-discards to cryptsetup in initrd to allow TRIM in LVM/encrypted SSD mostlyharmless Slackware 1 12-05-2013 07:51 PM
SSD reset, TRIM? malloc Linux - Hardware 3 01-19-2013 06:13 PM
[SOLVED] Enabling TRIM on ssd jas0n Debian 6 09-08-2012 02:18 PM
[SOLVED] TRIM on SSD mira.mikes Linux - Kernel 8 01-08-2011 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration