Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
LUKS LVM XFS doesn't support TRIM with fstrim
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 31, 2024 4:57 pm    Post subject: LUKS LVM XFS doesn't support TRIM with fstrim Reply with quote

I have my root filesystem, /, on an SSD that is whole disk encrypted with LUKS and uses LVM without a partiton table. I am told that XFS supports TRIM, but when I run fstrim on it, I get:
Code:

onesimus ~ # fstrim -v /
fstrim: /: the discard operation is not supported
onesimus ~ #

Why doesn't it work?

Additional informatrion:
Code:

onesimus ~ # fdisk -l
Disk /dev/sda: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: CT2000MX500SSD1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/cryptoroot: 1.82 TiB, 2000396836864 bytes, 3907025072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/gentoo-swap: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/gentoo-rootfs: 1.46 TiB, 1610612736000 bytes, 3145728000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
onesimus ~ #


onesimus ~ # mount
/dev/mapper/gentoo-rootfs on / type xfs (rw,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=6498604k,nr_inodes=819200,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
none on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
dev on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=10240k,nr_inodes=4060561,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /var/tmp/portage type tmpfs (rw,noatime,size=16777216k,mode=777)
onesimus ~ #


onesimus ~ # lvmdiskscan
  /dev/sda               [      <1.82 TiB]
  /dev/mapper/cryptoroot [      <1.82 TiB] LVM physical volume
  1 disk
  0 partitions
  1 LVM physical volume whole disk
  0 LVM physical volumes
onesimus ~ #


onesimus ~ # lvdisplay
  --- Logical volume ---
  LV Path                /dev/gentoo/swap
  LV Name                swap
  VG Name                gentoo
  LV UUID                wHaONm-dORA-yBld-NDWz-j5Hi-O100-GxhSMY
  LV Write Access        read/write
  LV Creation host, time livecd, 2024-02-16 21:12:24 -0500
  LV Status              available
  # open                 0
  LV Size                64.00 MiB
  Current LE             16
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/gentoo/rootfs
  LV Name                rootfs
  VG Name                gentoo
  LV UUID                iAbg1z-mDWx-1HZV-rfAo-aRT2-w3Lz-z6DDlv
  LV Write Access        read/write
  LV Creation host, time livecd, 2024-02-16 21:14:24 -0500
  LV Status              available
  # open                 1
  LV Size                1.46 TiB
  Current LE             384000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
onesimus ~ #

_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.


Last edited by Moriah on Sun Mar 31, 2024 5:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
sdauth
Guru
Guru


Joined: 19 Sep 2018
Posts: 569
Location: Ásgarðr

PostPosted: Sun Mar 31, 2024 5:02 pm    Post subject: Reply with quote

Probably not the case but I remember having this issue when my SSD (fde with luks, lvm) was connected to my SAS HBA adapter, the only way to make trim work was to connect it directly to a SATA3 port on the motherboard instead. The SAS HBA (my model!) doesn't handle trim command.

Last edited by sdauth on Sun Mar 31, 2024 5:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54270
Location: 56N 3W

PostPosted: Sun Mar 31, 2024 5:03 pm    Post subject: Reply with quote

Moriah,

The default on LUKS is notrim. If you use trim, unallocated regions will be erased and no longer filled with random data.
This gives away the location of your encrypted data.

If you are aware of the security implications, its possible to enable trim on LUKS.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 31, 2024 5:12 pm    Post subject: Reply with quote

@sdauth: The SSD is connected directly to a SATA3 port.

@neddy: Thanks, that makes good sense. I have been running SSDs without TRIM for years on this laptop. I recently decided to try using TRIM, and when it didn't work, I posted this question. I will continue to run without TRIM, as security is more important.

When I do a major upgrade, I usually bulk erase the SSD using its data security erase function, then copy the files I need to restore from my backup server. That does the equivalent of a TRIM, but I only do this maybe every couple of years.

I just replaced the SSD with a brand new drive and thought TRIM would be a good idea, but now I understand that TRIM is not a good idea combined with LUKS.

Thanks! :D
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21650

PostPosted: Sun Mar 31, 2024 5:43 pm    Post subject: Reply with quote

TRIM can be safe with LUKS, if your security model can tolerate the implications. As Neddy says, once a TRIM has run, anyone with read access to the drive can tell the difference between a sector containing nothing (TRIM erased it) versus a sector containing data (which, due to LUKS, will be encrypted data). If your security model calls for all the data sectors on the drive to appear to be completely random, then yes, TRIM is bad for your security model. If your security model allows an attacker to know how much data is on the drive, and you only care about preventing the attacker from understanding the contents, then TRIM making the empty sectors appear empty can be fine. A common corporate security use-case of LUKS has the goal that a lost/stolen drive does not allow the attacker to retrieve any company data. Such a policy holds that it is fine if the attacker knows your laptop holds 100GiB of company proprietary data, as long as the attacker cannot read even 1 byte of that proprietary data.

On the other end, you have the use case where even admitting the data is LUKS-encrypted could expose you to physical or legal consequences, and absolute deniability is necessary. For that case, you definitely want to disable TRIM. (Though personally, I find it hard to envision a plausible scenario where admitting to LUKS has consequences of that severity and the adversary will find it completely acceptable and believable that you are carrying a drive of purely random data. Adversaries that hate LUKS that much will likely assume that "random" data is just a LUKS container they have not yet broken, and penalize you as if you had admitted to it being LUKS.)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54270
Location: 56N 3W

PostPosted: Sun Mar 31, 2024 6:24 pm    Post subject: Reply with quote

Moriah,

If your SSD is over provisioned, not doing trim may not be the speed penalty it once was.

The over provisioned space is known to the drive but hidden from the user. It takes part in wear levelling though.

The drive can do a 'quick erase' by swapping an erased block from the already erased over provisioned space into the user space. Then erasing that block later.
If the drive can do this or not depends on the firmware and that's a trade secret :)

Think of the over provisioned space being like spare sectors and tracks on a conventional HDD.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 31, 2024 7:31 pm    Post subject: Reply with quote

Put me in that paranoid category of not wanting the attacker to make any sense of the drive at all. Since the drive is in a laptop, the possibility or a lost or stolen laptop must always be considered.

BTW I treat my large spinner backup server drives the same way. They are members of a 3-way RAID-1 mirror. I periodically (typially once per week) pull a drive from the array and air gap it for extra security. Less frequently, when the RAID get nearly full, I pull a drive and take it to the safe deposit box at the bank for long term archival. By having triple redundancy, I have double redundancy even when I pull and replace a drive while it is catching up.

Nobody but me (or maybe the NSA) can make any use of the data on these drives, either from the backup server, or from the laptop. You could say I do it that way because "I can", but I keep sensitive client files on my laptop, and it gets backed up to the backup server, so I need to protect their data in the best way that I can.

I have been running this way for about 16 years.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Mon Apr 01, 2024 7:54 am    Post subject: Reply with quote

Moriah wrote:
I keep sensitive client files on my laptop, and it gets backed up to the backup server, so I need to protect their data in the best way that I can.
I don't think that's too paranoid. If you store your client's data an promise to keep it safe, then being extra cautious is justified.

I don't use encryption almost at all. My reasoning is that the files are mine and thus I decide their "level of security".
Also, especially, all my pictures and videos I've personally taken are not encrypted and the reasoning is same as with one of my customer's:
a rough quote wrote:
If something were to happen to me, I want my relatives have an easy access to all the photos I have. So please can you copy all the photos from my Google account to this external hard drive?
... and so I did. It took few days (Thanks to Google for making it pretty complicated).

But, like in your case, if I had some data on my computer that's not mine, I'd sure keep them in an encrypted partition, container or whatnot. Having a large portion of your hard drive encrypted makes it ever harder for (physical) attacker to try to retrieve any sensible data from it.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum