Loading howto/lvm.md +64 −2 Original line number Diff line number Diff line Loading @@ -6,11 +6,17 @@ title: LVM cheat sheet # Caching WARNING: those instructions are deprecated. There's a newer, simpler way of setting up the cache that doesn't require two logical volumes, see the [rebuild instructions](#rebuilding-the-cache-after-removal) for instructions that need to be adapted here. See also the [lvmcache(7) manual page](https://manpages.debian.org/lvmcache.7) for further instructions. Create the VG consisting of 2 block devices (a slow and a fast) apt install lvm2 && vg="vg_$(hostname)" && cat /proc/partitions && vg="vg_$(hostname)_cache" && lsblk && echo -n 'slow disk: ' && read slow && echo -n 'fast disk: ' && read fast && vgcreate "$vg" "$slow" "$fast" Loading Loading @@ -41,6 +47,62 @@ functionality with: lvconvert --uncache vg_colchicifolium/srv ## Rebuilding the cache after removal If you've just `--uncached` a volume, for example to resize it, you might want to re-establish the cache. For this, you can't follow the same procedure above, as that requires recreating a VG from scratch. Instead, you need to extend the VG and then create new volumes for the cache. It should look something like this: 1. extend the VG with the fast storage: VG=vg_$(hostname) FAST=/dev/sdc vgextend $VG $FAST 2. create a LV for the cache: lvcreate -n cache -l '100%FREE' $VG $FAST 3. add the cache to the existing LV to be cached: lvconvert --type cache --cachevol cache $VG Example run: root@colchicifolium:~# vgextend vg_colchicifolium /dev/sdc Volume group "vg_colchicifolium" successfully extended root@colchicifolium:~# lvcreate -n cache -l '100%FREE' vg_colchicifolium /dev/sdc Logical volume "cache" created. root@colchicifolium:~# lvconvert --type cache --cachevol cache vg_colchicifolium Erase all existing data on vg_colchicifolium/cache? [y/n]: y Logical volume vg_colchicifolium/srv is now cached. Command on LV vg_colchicifolium/cache_cvol requires LV with properties: lv_is_visible . You can see the cache in action with the `lvs` command: root@colchicifolium:~# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert srv vg_colchicifolium Cwi-aoC--- <1.68t [cache_cvol] [srv_corig] 0.01 13.03 0.00 You might get a `modprobe` error on the last command: root@colchicifolium:~# lvconvert --type cache --cachevol cache vg_colchicifolium Erase all existing data on vg_colchicifolium/cache? [y/n]: y modprobe: ERROR: could not insert 'dm_cache_smq': Operation not permitted /sbin/modprobe failed: 1 modprobe: ERROR: could not insert 'dm_cache_smq': Operation not permitted /sbin/modprobe failed: 1 device-mapper: reload ioctl on (254:0) failed: Invalid argument Failed to suspend logical volume vg_colchicifolium/srv. Command on LV vg_colchicifolium/cache_cvol requires LV with properties: lv_is_visible . That's because the kernel module can't be loaded. Reboot and try again. See also the [lvmcache(7) manual page](https://manpages.debian.org/lvmcache.7) for further instructions. # Resizing Assume we want to grow this partition to take the available free space Loading Loading
howto/lvm.md +64 −2 Original line number Diff line number Diff line Loading @@ -6,11 +6,17 @@ title: LVM cheat sheet # Caching WARNING: those instructions are deprecated. There's a newer, simpler way of setting up the cache that doesn't require two logical volumes, see the [rebuild instructions](#rebuilding-the-cache-after-removal) for instructions that need to be adapted here. See also the [lvmcache(7) manual page](https://manpages.debian.org/lvmcache.7) for further instructions. Create the VG consisting of 2 block devices (a slow and a fast) apt install lvm2 && vg="vg_$(hostname)" && cat /proc/partitions && vg="vg_$(hostname)_cache" && lsblk && echo -n 'slow disk: ' && read slow && echo -n 'fast disk: ' && read fast && vgcreate "$vg" "$slow" "$fast" Loading Loading @@ -41,6 +47,62 @@ functionality with: lvconvert --uncache vg_colchicifolium/srv ## Rebuilding the cache after removal If you've just `--uncached` a volume, for example to resize it, you might want to re-establish the cache. For this, you can't follow the same procedure above, as that requires recreating a VG from scratch. Instead, you need to extend the VG and then create new volumes for the cache. It should look something like this: 1. extend the VG with the fast storage: VG=vg_$(hostname) FAST=/dev/sdc vgextend $VG $FAST 2. create a LV for the cache: lvcreate -n cache -l '100%FREE' $VG $FAST 3. add the cache to the existing LV to be cached: lvconvert --type cache --cachevol cache $VG Example run: root@colchicifolium:~# vgextend vg_colchicifolium /dev/sdc Volume group "vg_colchicifolium" successfully extended root@colchicifolium:~# lvcreate -n cache -l '100%FREE' vg_colchicifolium /dev/sdc Logical volume "cache" created. root@colchicifolium:~# lvconvert --type cache --cachevol cache vg_colchicifolium Erase all existing data on vg_colchicifolium/cache? [y/n]: y Logical volume vg_colchicifolium/srv is now cached. Command on LV vg_colchicifolium/cache_cvol requires LV with properties: lv_is_visible . You can see the cache in action with the `lvs` command: root@colchicifolium:~# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert srv vg_colchicifolium Cwi-aoC--- <1.68t [cache_cvol] [srv_corig] 0.01 13.03 0.00 You might get a `modprobe` error on the last command: root@colchicifolium:~# lvconvert --type cache --cachevol cache vg_colchicifolium Erase all existing data on vg_colchicifolium/cache? [y/n]: y modprobe: ERROR: could not insert 'dm_cache_smq': Operation not permitted /sbin/modprobe failed: 1 modprobe: ERROR: could not insert 'dm_cache_smq': Operation not permitted /sbin/modprobe failed: 1 device-mapper: reload ioctl on (254:0) failed: Invalid argument Failed to suspend logical volume vg_colchicifolium/srv. Command on LV vg_colchicifolium/cache_cvol requires LV with properties: lv_is_visible . That's because the kernel module can't be loaded. Reboot and try again. See also the [lvmcache(7) manual page](https://manpages.debian.org/lvmcache.7) for further instructions. # Resizing Assume we want to grow this partition to take the available free space Loading