Resizing root partition by taking space from /home

init 1

umount /dev/mapper/debian-home
e2fsck -f /dev/mapper/debian-home
resize2fs /dev/mapper/debian-home 100G
lvreduce -L 50G /dev/debian/home
lvextend -L 10G /dev/debian/root
resize2fs /dev/mapper/debian-root
mount /dev/mapper/debian-home


By using these steps you can use a SSD drive to cache a regular hard drive. The cache can be dynamically added and removed with no loss of data or interruption of a mounted filesystem. See also man lvmcache.

# Easy way to create - cache metada automatically put somewhere
sudo lvcreate -n home2_cache -l 100%free ramanujan /dev/mapper/r2fluorine_decrypt
sudo lvconvert --type cache --cachepool ramanujan/home2_cache ramanujan/home2

# Full manual control
sudo lvcreate -n root2_cachemeta -L 40M  ramanujan /dev/mapper/fluorine_decrypt
sudo lvcreate -n home2_cachemeta -L 100M ramanujan /dev/mapper/fluorine_decrypt
sudo lvcreate -n root2_cache -L 20G  ramanujan /dev/mapper/fluorine_decrypt
sudo lvcreate -n home2_cache -L 212G ramanujan /dev/mapper/fluorine_decrypt
sudo lvconvert --type=cache-pool --poolmetadata ramanujan/home2_cachemeta ramanujan/home2_cache
sudo lvconvert --type=cache-pool --poolmetadata ramanujan/root2_cachemeta ramanujan/root2_cache

# List info
sudo lvs -o+cache_mode,chunksize
sudo lvs -o name,cache_read_hits,cache_read_misses,cache_total_blocks,cache_used_blocks ramanujan/root2 ramanujan/home2

# Remove stuff
lvconvert --splitcache VG/CacheLV   # split cache
lvconvert --uncache VG/CacheLV      # split cache and delete cache LV.  origin unchanged.

Making it work from initrafms:, Install thin-provisioning-tools, in /etc/initramfs-tools/hooks/lvmcache:


    echo "$PREREQ"

case $1 in
    exit 0

if [ ! -x /usr/sbin/cache_check ]; then
    exit 0

. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/sbin/cache_check

manual_add_modules dm_cache dm_cache_mq

DebianNotes/LVM (last edited 2018-09-06 15:50:22 by RichardDarst)