Skip to main content

LVM

Create new physical volume, volume group and logical group. Mount it to freshly created directory. Add to fstab for automatic mount during boot process.

apt install lvm2 -y

hostname
export host="$(hostname)"
lsblk
export dev="/dev/xvdb"
export size="99.9G"
# ext4 or xfs ?
export fs="xfs"

pvcreate ${dev}
vgcreate vg-${host}-data ${dev}
lvcreate -L ${size} -n lv-${host}-data vg-${host}-data
lvscan

mkfs.${fs} /dev/vg-${host}-data/lv-${host}-data
mkdir -p /mnt/${host}-data
mount /dev/vg-${host}-data/lv-${host}-data /mnt/${host}-data
df -h

#TODO: add into /fstab with oneliner
echo "add me to fstab"
mount | grep ${host}
nano /etc/fstab
systemctl daemon-reload