How to configure a filesystem+LVM for effective usage of SSD?

6,792

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:
6,792

Related videos on Youtube

imz -- Ivan Zakharyaschev
Author by

imz -- Ivan Zakharyaschev

My name is Ivan Zakharyaschev, Иван Захарьящев, imz.

Updated on September 18, 2022

Comments

  • imz -- Ivan Zakharyaschev
    imz -- Ivan Zakharyaschev over 1 year

    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.)

    • phemmer
      phemmer almost 12 years
      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.
    • user2948306
      user2948306 over 11 years
      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.
  • imz -- Ivan Zakharyaschev
    imz -- Ivan Zakharyaschev over 11 years
    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?