Flatcar icon indicating copy to clipboard operation
Flatcar copied to clipboard

[RFE] docs for lvm support

Open lizelive opened this issue 3 years ago • 1 comments

Current situation

i want to use lvm to setup caching

Impact

improve filesytem performance

Ideal future situation

be able to enable lvm by enabling some systemd service

i think systemctl start lvm2-monitor.service works but idk much about lvm

lizelive avatar Apr 01 '22 11:04 lizelive

You can create the LVM setup with pvcreate, vgcreate, lvcreate, and lvconvert as usual.

Here is some copy paste snippet:

Setting up the LVM cache

First, we create physical volumes for our devices, and check that it worked correctly:

sudo pvcreate ${VOLUME} ${DEVA} ${DEVB}
sudo pvs

Then, we create a volume group with our three physical devices. In that volume group, we create three logical volumes: one for the data, another for the cache and the last one for the cache's metadata. Then we check that everything worked as expected.

sudo vgcreate cache-layer-vg ${VOLUME} ${DEVA} ${DEVB}
sudo lvcreate -l 100%FREE -n data cache-layer-vg ${VOLUME}
sudo lvcreate -L 700G -n cachedisk cache-layer-vg
sudo lvcreate -L 16G -n metadisk cache-layer-vg
sudo lvs

Now we need to turn those logical volumes into the actual cache. First we attach the metadata to the cache and then the cache to the data.

sudo lvconvert --type=cache-pool /dev/cache-layer-vg/cachedisk --poolmetadata  /dev/cache-layer-vg/metadisk
sudo lvconvert --type cache /dev/cache-layer-vg/data --cachepool /dev/cache-layer-vg/cachedisk
sudo lvs

With that, we've set up the data volume to be cached with our SSD disks. We can now format it and mount it:

sudo mkfs.ext4 /dev/cache-layer-vg/data
sudo mkdir /var/www
sudo mount /dev/cache-layer-vg/data /var/www

Would be nice to have a docs PR.

pothos avatar Apr 01 '22 11:04 pothos

PR: https://github.com/flatcar/flatcar-docs/pull/315

tormath1 avatar Sep 08 '23 14:09 tormath1