#!/bin/bash

#set lvm type
parted /dev/sda set 1 lvm on
parted /dev/sdb set 1 lvm on
parted /dev/sdc set 1 lvm on
parted /dev/sdd set 1 lvm on

#create physical volume
pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/ram0
pvs
pvdisplay

#create volume group
vgcreate  -s 64K LVM /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/ram0
vgdisplay

#logic volumn
lvcreate -i 4 -l 100%VG  -I 64  -n lvdisk LVM /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
lvdisplay

lvcreate  -L 128M  -n cache LVM /dev/ram0
lvcreate  -L 10M    -n meta  LVM /dev/ram0
lvconvert --type cache-pool --poolmetadata LVM/meta LVM/cache
#lvconvert --type cache --cachepool LVM/cache --cachemode writeback LVM/lvdisk
lvconvert --type cache --cachepool LVM/cache --cachemode writethrough LVM/lvdisk

#mkfs
echo "yes" |mkfs.ext4 /dev/LVM/lvdisk

