Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

ext4 is one of the filesystems recommended for using on SSDs (with a number of built-in techniques and advices how to tune it for better performance and wear-levelling of SSDs).

I want to install a Linux system onto an SSD, and I'm going to use ext4, because it is the better tested FS (I don't want to use the more experimetal btrfs).

But what if I add LVM between ext4 and SSD? Will the performance and wear-levelling tweaks for ext4 loose their effect? (Because LVM would hide the actual disk layout from the FS.) Can LVM be configured so that it will use the SSD features effectively?

(I want to use LVM to able to have snapshots of older states of the system, as well as for more flexibility with the sizes of the partitions.)

share|improve this question
4  
Before you go wasting a lot of effort to ensure that TRIM (that is what the feature youre talking about is called) works, make sure that you even need it. Many SSDs these days dont even use TRIM and instead wear level the entire device whether blocks are in use or not. –  Patrick Apr 29 '12 at 17:48
1  
Such as?! I know OCZ use it (see the drive with the "performance mode" that works when only half the disk is used). I know my Crucial M4s support it, and it takes a non-zero amount of time to return (observable for large discards). It's known to be useful on Sandforce (SF-2000); the concern there is that TRIM isn't as effective as on other drives, not that it doesn't work at all. –  sourcejedi Dec 30 '12 at 16:07
add comment

1 Answer

The main issue here is the alignment. You want the filesystem blocks to be aligned with the SSD erase blocks so that sectors aren't unnecessarily erased. When adding LVM into the mix you just need to ensure that the alignment stays intact. By default LVM will align data on PVs on 64KiB boundaries -- if your SSD's erase block size is bigger than that you want to use the --dataalignment option to pvcreate to specify that. (Note that if you're using an MBR/GPT partition under the PVs you also need to address alignment there.)

According to this ServerFault question, TRIM works correctly through ext4+LVM+mdraid as of Linux 2.6.38.

share|improve this answer
    
How do I check what my SSD's erase block size is? Couldn't pvcreate from LVM check it automatically and adjut, without the user's intervention? –  imz -- Ivan Zakharyaschev Oct 24 '12 at 22:45
2  
@imz Either find the datasheet for your SSD, or try using flashbench. –  mgorven Oct 24 '12 at 22:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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