Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LVM mount point creating
#!/bin/bash
# https://kerneltalks.com/scripts/script-to-create-mount-points-in-lvm/
# My version is better IMHO :)
failed()
{
err=$?
echo "Check error above\! Halting..."
exit $err
}
while IFS=, read kt_mountname kt_lvsize kt_vgname
do
kt_lvname=${kt_mountname//\//_}
kt_lvname=${kt_lvname:1:9999}
lvcreate -n $kt_lvname -L $kt_lvsize $kt_vgname >/dev/null || failed
mkfs.ext4 /dev/$kt_vgname/$kt_lvname >/dev/null || failed
mkdir -p $kt_mountname >/dev/null || failed
mount /dev/$kt_vgname/$kt_lvname $kt_mountname>/dev/null || failed
echo "/dev/$kt_vgname/$kt_lvname $kt_mountname ext4 defaults 0 0">>/etc/fstab || failed
done <list.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.