Created
June 26, 2015 02:28
-
-
Save kzap/7e5994dda6c01b19760a to your computer and use it in GitHub Desktop.
LVM Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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