New Partition for LVM Cache
lsblk
fdisk -l
blkid -o list
fdisk /dev/vda
partprobe
blkid -o list
mkdir /cache
mkfs.ext4 /dev/vda3
mount /dev/vda3 /cache
blkid -o list
nano /etc/fstab
e2label /dev/vda3 "LVM Cache"
blkid -o list
systemctl daemon-reload
reboot
lvs
blkid -o list
device fs_type label mount point UUID
---------------------------------------------------------------------------------------------------
/dev/mapper/centos7-root
xfs / f3b05d5e-eaa1-4fb1-ba8e-dc7b52aa3509
/dev/vda2 LVM2_member (in use) su80uZ-L3qP-4br0-zM7U-SkUl-I7hB-XPuQrg
/dev/vda1 ext4 /boot 443dd8ca-b901-4947-a61d-df258f7f2958
/dev/mapper/centos7-swap
swap <swap> 9db3c009-809e-4028-9577-0b2203103010
/dev/vda3 ext4 LVM Cache /cache 827c2730-9d16-4c0b-add4-f89c9c22e832
/dev/mapper/centos7-home
xfs /home 7de649f7-03aa-46a0-8838-45a6bd23ae6a
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 50G 0 disk
├─vda1 252:1 0 953M 0 part /boot
├─vda2 252:2 0 35.4G 0 part
│ ├─centos7-root 253:0 0 31.7G 0 lvm /
│ ├─centos7-swap 253:1 0 2.8G 0 lvm [SWAP]
│ └─centos7-home 253:2 0 956M 0 lvm /home
└─vda3 252:3 0 13.7G 0 part
umount /dev/vda3
pvcreate /dev/vda3
WARNING: ext4 signature detected on /dev/vda3 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/vda3.
Physical volume "/dev/vda3" successfully created.
pvscan
PV /dev/vda2 VG centos7 lvm2 [35.40 GiB / 4.00 MiB free]
PV /dev/vda3 lvm2 [13.67 GiB]
Total: 2 [49.06 GiB] / in use: 1 [35.40 GiB] / in no VG: 1 [13.67 GiB]
vgextend centos7 /dev/vda3
Volume group "centos7" successfully extended
lvcreate --type cache-pool -L 13.6G -n cpool centos7 /dev/vda3
Using default stripesize 64.00 KiB.
Rounding up size to full physical extent 13.60 GiB
Logical volume "cpool" created.
lvchange -a n /dev/centos7/cpool
lvchange -a y /dev/centos7/cpool
nano /etc/fstab
-> {to comment-out previously added physical volume dev/vda3}
lvs -a -o name,size,attr,devices centos7
LV LSize Attr Devices
cpool 13.60g Cwi---C--- cpool_cdata(0)
[cpool_cdata] 13.60g Cwi------- /dev/vda3(12)
[cpool_cmeta] 16.00m ewi------- /dev/vda3(8)
home 956.00m -wi-ao---- /dev/vda2(8106)
lvol0 16.00m -wi------- /dev/vda3(0)
[lvol1_pmspare] 16.00m ewi------- /dev/vda3(4)
root 31.66g -wi-ao---- /dev/vda2(0)
swap 2.80g -wi-ao---- /dev/vda2(8345)# lvconvert --type cache --cachepool cpool centos7/root
Do you want wipe existing metadata of cache pool volume centos7/cpool? [y/n]: y
Logical volume centos7/root is now cached.# lvs -a -o name,size,attr,devices centos7
LV LSize Attr Devices
[cpool] 13.60g Cwi---C--- cpool_cdata(0)
[cpool_cdata] 13.60g Cwi-ao---- /dev/vda3(12)
[cpool_cmeta] 16.00m ewi-ao---- /dev/vda3(8)
home 956.00m -wi-ao---- /dev/vda2(8106)
lvol0 16.00m -wi------- /dev/vda3(0)
[lvol1_pmspare] 16.00m ewi------- /dev/vda3(4)
root 31.66g Cwi-aoC--- root_corig(0)
[root_corig] 31.66g owi-aoC--- /dev/vda2(0)
swap 2.80g -wi-ao---- /dev/vda2(8345)