flatcar / Flatcar

Flatcar project repository for issue tracking, project documentation, etc.
https://www.flatcar.org/
Apache License 2.0
677 stars 28 forks source link

[RFE] docs for lvm support #700

Open lizelive opened 2 years ago

lizelive commented 2 years ago

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

pothos commented 2 years ago

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.

tormath1 commented 11 months ago

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