LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 02-23-2020, 08:04 PM   #1
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 699
Blog Entries: 160

Rep: Reputation: 228Reputation: 228Reputation: 228
ssd with luks lvm, qustions


So, I have been thinking of SSDs. I don't have one, I'm just thinking about them. My system is a laptop, so naturally it has to be LUKS LVM for all file systems aside from /boot.

I found this thread helpful but it does not answer all of my questions, because of the whole layer cake of file system over LVM over LUKS over physical SSD.

Near as I can tell, when blocks are freed up on the file system, the file system has to somehow pass that down to LVM. LVM somehow recognizes that and then passes this down a level to LUKS, which in turn, finally, passes it down to the actual SSD device so that that freed block is marked as unused and can then later be allocated for new files.

I've done a bit of research and here iss what I have been able to figure out, in bottom up order from LUKS up to the file-system. Please correct me when I've made errors from ignorance, as I am sure I have made some. Thank you.

LUKS

When creating a new LUKS device over a SSD, there are no special commands. One would use cryptsetup as one would normally use it; picking cipher and hash, etc.

The only change for an SSD is when using the luksOpen or open options when running the cryptsetup program. Adding the "--allow-discards" option seems to be all that is needed. The man page says, "Allow the use of discard (TRIM) requests for the device. This option is only relevant for open action."

For a fully encrypted system (like mine) this would somehow have to be included in the init ram disk's scripting?

I wonder, can the LUKS block size be set to the same size as the SSD block size? If so, how would one ascertain the SSD's block size? I have read that some SSDs have a block size as high as 128k and that writing in blocks that are smaller than the underlying SSD block size is less than optimal.

LVM

The only option relevant to SSDs is the "--discards" option for the lvcreate program. The man page for lvcreate states: "Specifies how the device-mapper thin pool layer in the kernel should handle discards."
So "--discards passdown" looks like the actual syntax.

Since this would be specified when creating a logical volume, no additional command-line options would need to be added to the init ram disk to mount that volume later on.

If I understand the lvcreate man page correctly, it means that only a thin-provisioned volume can be used with the "--discards passdown" option.

Syntax for creating a thin provisioned LVM is incomprehensible to me at this time. Looks like a pool LVM has to be made first, and all thin volume groups use the pool? the pool itself may or may not be more than one logical volume? Can the pool use the entire volume group or must some free space be left?

Use of thin provisioned volumes has the unfortunate side effect of fragmentation. On an SSD, however, fragmentation does not matter.

The Top Layer

The topmost layer of this layer cake is the actual file system used in each logical volume, whatever it may be; xfs, ext4 or whatever. Some of my reading recommends that one disable journaling, so as to reduce the amount of writes, to then extend the lifetime of the underlying SSD.

ext4

The mount option "discard", either as an "-o" option, or in the fstab, is needed for efficient use of an SSD. So far, seems simple enough.
Journaling will cause extra writes to the disk. ext2 does not use journaling but ext2 does not have the discard option, so is unsuitable for use on an SSD.

As for disabling journaling, from the mke2fs man page:
"mke2fs -t ext3 -O ^has_journal /dev/hdXX" will create a filesystem that does not have a journal and hence will not be supported by the ext3 filesystem code in the Linux kernel."

That's a problem. It would seem that journaling has to be left on!
How much extra writing does ext4 journaling involve? 100% 15%, 2%. Less would be better. If the percentage is low enough, maybe it is OK to just leave journaling on and use ext4?

F2FS

This file system was designed to be used with flash cards, SD cards and SSD drive. The problem is, this file system is new and is possibly not reliable and table enough for regular use.

btrfs

Does it journal?

If one doesn't use snapshots often, since the copy-on-write operations will perform a lot of writes, the day-to-day average amount of writes to an SSD would not be so bad?

Two More Questions
Does the block size of the SSD, LUKS device, LVM physical volume and the file system in all logical volumes need to be the same?

Should part of the disk remain unpartitioned, to allow more blocks to be replace those that become worn (from writes over time).
 
Old 02-24-2020, 12:57 PM   #2
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I think it works the other way around?
LUKS takes ext4 data and places an encrypted version on the storage, only writing data to the storage. Like simple substitution cypher where an 'a' is typed and a 'h' written. The medium and file system do not need to know what each other are. The "discard" is worth looking into but just generally not because it's encrypted.
SDD makers now (not sure whether they always have) "overprovision" the drives meaning that they build in enough extra storage to make up for that which fails in a huge number of writes over at the very least the warrantied life of the drive but, usually, enough to deal with many years of writes.
 
Old 02-24-2020, 02:12 PM   #3
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 699

Original Poster
Blog Entries: 160

Rep: Reputation: 228Reputation: 228Reputation: 228
I found a thread I had not found before that answers many of my questions. D'oh!

thread here - it is specific to Slackware, and I am running slackware.

I still wonder about the block size thing, though.
 
  


Reply


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
How can I use trim with luks+lvm on ssd? pengStudent Slackware 5 05-16-2013 11:15 AM
The console Qustions! every one wants to know! livecrow Linux - Newbie 2 04-03-2007 01:15 PM
Mandrake 7 - Absouloute beginner qustions jimlg Linux - Newbie 11 10-24-2003 06:26 PM
MPlayer qustions grinder Linux - Software 5 06-22-2003 12:42 AM
A couple of newbie qustions about Mandrake 9.1 javiersf Linux - Software 3 04-09-2003 08:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:17 AM.

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