LVM Raid 1 + SSD Caching

cachelvmraidraid1

I have three disks:

  • /dev/sda slow hdd
  • /dev/sdb slow hdd
  • /dev/sdc fast ssd
  • /dev/vg0 volume group consisting /dev/sd{a,b,c}

Each logical volume (lv) should be raid1 mirrored and ssd cached.

With the following command, I can create a mirrored raid1 lv named test on vg0.

lvcreate --type raid1 -m 1 -L 1G -n test vg0
  • What do I need to change in the previous command so that it will only use the slow hdds for the raid1 mirror? Can I use LVMs tag system (@hdd, @ssd) for this?
  • I found some tutorials which explained how to use the LVM cache feature. But it looks like I need to create for each lv an own cache-pool. Is it possible to create one big cache-pool for the whole vg0 so that all lvs in vg0 will be cached? Or can I safely reuse an existing cache-pool for other lvs?

Best Answer

Based on the lvmcache man page it really seems like caching is entirely a logical volume thing and not something you can implement on the volume group level. It does seem annoying to not be able to cache an entire VG but this seems to be an architectural limitation.

Regarding forcing an LV to be created using only specific PVs, you can specify the PVs at the end of the lvcreate command.

Here's the synopsis from the man page with the extraneous options removed:

lvcreate  <...> [VolumeGroup{Name|Path} [/ExternalOrigin  |  Origin  |  Pool}LogicalVolumeName]  [PhysicalVolumePath[:PE[-PE]]...]

I think a lot of people miss this since that synopsis is pretty "involved." But this feature is actually necessary when creating your cache since you need to be able to force the cache LVs to be on the SSD PVs.

Sidenote: a quick search reveals that LVM mirroring is generally considered to be much slower than Linux software RAID. But I think you can reclaim some of that lost performance with some tuning.

Related Topic