Skip to content

Instantly share code, notes, and snippets.

@kzap
Created June 26, 2015 02:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzap/7e5994dda6c01b19760a to your computer and use it in GitHub Desktop.
Save kzap/7e5994dda6c01b19760a to your computer and use it in GitHub Desktop.
LVM Script
echo RTFM >&2;
exit -1;
N=1
yum install -y lvm2
D=$(grep "unknown partition table" /var/log/messages | tail -n 1 | perl -pe 's/.*: ([^:]*): unknown.*/$1/g');
D=/dev/$D
pvcreate $D
vgcreate vg_$N $D
S=$(vgdisplay vg_$N | grep Total | perl -pe 's/[^0-9]+//g')
lvcreate -l $S vg_$N -n lv_$N
mke2fs -t ext4 /dev/vg_"$N"/lv_$N
tune2fs -m 0 /dev/vg_"$N"/lv_$N
mkdir /media/Volume-$N
mount /dev/vg_"$N"/lv_$N /media/Volume-$N
echo -e "/dev/vg_"$N"/lv_"$N"\t\t/media/Volume-"$N"\t\text4\tnoatime\t\t0 2" >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment