Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Update lvm-cache.md
Browse files Browse the repository at this point in the history
  • Loading branch information
krishjainx authored Jul 5, 2023
1 parent a1dfe63 commit 8cc1e4a
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions docs/setup/storage/lvm-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,10 @@ From lvmcache(7):

> The cache logical volume type uses a small and fast LV to improve the performance of a large and slow LV. It does this by storing the frequently used blocks on the faster LV. LVM refers to the small fast LV as a cache pool LV. The large slow LV is called the origin LV. D
You can create the LVM setup with [pvcreate](https://linux.die.net/man/8/pvcreate), [vgcreate](https://linux.die.net/man/8/vgcreate), [lvcreate](https://linux.die.net/man/8/lvcreate), and [lvconvert]([https://linux.die.net/man/8/pvcreate](https://linux.die.net/man/8/lvconvert)) traditionally. See below:

**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
```
You can create the LVM setup with [pvcreate](https://linux.die.net/man/8/pvcreate), [vgcreate](https://linux.die.net/man/8/vgcreate), [lvcreate](https://linux.die.net/man/8/lvcreate), and [lvconvert]([https://linux.die.net/man/8/pvcreate](https://linux.die.net/man/8/lvconvert)) traditionally. See below:

For Flatcar you could use a butane configuration file for the same that would be transpiled to ignition for the same purpose (upload a script for your setup based on above somewhere):

Expand Down

0 comments on commit 8cc1e4a

Please sign in to comment.