LVM - Creation of first physical volume, volume group and logical group.
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
dnf install
lvm2
Define variable
hostname
export host="$(hostname)"
lsblk
export dev="/dev/sdc"
export size="9.9G"
Understand which is filesystem type mainly used on the system
df -hT
In my case it is 'ext4', I shall continue in similarity to this. Redhat family distros might want to use 'xfs'
export fs="ext4"
# 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
/dev/mapper/vg--host--data-lv--host--data /mnt/host-data ext4 defaults 0 1
Reload fstab and remount all drives. New drive must be mounted.
systemctl daemon-reload
mount -a
When possible, test VM restart to ensure disk will be mounted
shutdown -r now





No Comments