echo "Writer::--Anuj Borah"
echo "Email::--anujborah1@gmail.com"
#!/bin/bash
clear
while true
do
clear
echo "This script will create LVM of Maximum 3 partitions"
echo "Writer::Anuj Borah"
echo "Email::anujborah1@gmail.com"
echo -e "You have Following configuration:\n`sudo fdisk -l | grep /dev `\n\nHow many partitions you wana use for LVM give us the no Ex: 1 or 2 or 3 "
read q
if [ $q -eq 1 ]
then
echo "OK.Enter the name of $q partition"
read r
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo -e "$r present" ; echo "$r is the partition will be used to create LVM ";read -p "Press "Enter" to continue....."; echo "Creating PV...." ;`sudo pvcreate $r 2>/dev/null`;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 1;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg 2>/dev/null`;sleep 3;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb`;echo -e "All done\nyour current LVM:::--- `df -h | grep /media/usb`"
else
echo "$r does not exists"
break
fi
elif [ $q -eq 2 ]
then
echo "OK.Enter the name of $q partition"
read r e
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo "$r present "
else
echo "$r does not exists"
break
fi
sudo fdisk -l | grep $e 1>/dev/null
if [ $? -eq 0 ]
then
echo "$e present "
else
echo "$e does not exists"
break
fi
read -p "$e , $r are two partitions will be used to create LVM. Press "Enter" to proceed...";echo "Creating PV...." ;`sudo pvcreate $r $e 2>/dev/null`;sleep 2;sudo pvs;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 2;sudo vgs ; sleep 2;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg`2>/dev/null;sleep 3;sudo lvs;sleep 2;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb 2>/dev/null `;echo -e "\nAll done\nyour current LVM:::--- `df -h | grep /media/usb`"
break
elif [ $q -eq 3 ]
then
echo "OK.Enter the name of $q partition"
read r e t
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo "$r present "
else
echo "$r does not exists"
break
fi
sudo fdisk -l | grep $e 1>/dev/null
if [ $? -eq 0 ]
then
echo "$e present "
else
echo "$e does not exists"
break
fi
sudo fdisk -l | grep $t 1>/dev/null
if [ $? -eq 0 ]
then
echo "$t present "
else
echo "$t does not exists"
break
read -p "$e , $r , $t are three partitions will be used to create LVM. Press "Enter" to proceed...";echo "Creating PV...." ;`sudo pvcreate $r $e $t 2>/dev/null`;sleep 2;sudo pvs;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 2;sudo vgs ; sleep 2;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg 2>/dev/null`;sleep 3;sudo lvs;sleep 2;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb 2>/dev/null `;echo -e "\nAll done\nyour current LVM:::--- `df -h | grep /media/usb`"
break
fi
fi
done
echo "Email::--anujborah1@gmail.com"
#!/bin/bash
clear
while true
do
clear
echo "This script will create LVM of Maximum 3 partitions"
echo "Writer::Anuj Borah"
echo "Email::anujborah1@gmail.com"
echo -e "You have Following configuration:\n`sudo fdisk -l | grep /dev `\n\nHow many partitions you wana use for LVM give us the no Ex: 1 or 2 or 3 "
read q
if [ $q -eq 1 ]
then
echo "OK.Enter the name of $q partition"
read r
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo -e "$r present" ; echo "$r is the partition will be used to create LVM ";read -p "Press "Enter" to continue....."; echo "Creating PV...." ;`sudo pvcreate $r 2>/dev/null`;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 1;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg 2>/dev/null`;sleep 3;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb`;echo -e "All done\nyour current LVM:::--- `df -h | grep /media/usb`"
else
echo "$r does not exists"
break
fi
elif [ $q -eq 2 ]
then
echo "OK.Enter the name of $q partition"
read r e
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo "$r present "
else
echo "$r does not exists"
break
fi
sudo fdisk -l | grep $e 1>/dev/null
if [ $? -eq 0 ]
then
echo "$e present "
else
echo "$e does not exists"
break
fi
read -p "$e , $r are two partitions will be used to create LVM. Press "Enter" to proceed...";echo "Creating PV...." ;`sudo pvcreate $r $e 2>/dev/null`;sleep 2;sudo pvs;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 2;sudo vgs ; sleep 2;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg`2>/dev/null;sleep 3;sudo lvs;sleep 2;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb 2>/dev/null `;echo -e "\nAll done\nyour current LVM:::--- `df -h | grep /media/usb`"
break
elif [ $q -eq 3 ]
then
echo "OK.Enter the name of $q partition"
read r e t
sudo fdisk -l | grep $r 1>/dev/null
if [ $? -eq 0 ]
then
echo "$r present "
else
echo "$r does not exists"
break
fi
sudo fdisk -l | grep $e 1>/dev/null
if [ $? -eq 0 ]
then
echo "$e present "
else
echo "$e does not exists"
break
fi
sudo fdisk -l | grep $t 1>/dev/null
if [ $? -eq 0 ]
then
echo "$t present "
else
echo "$t does not exists"
break
read -p "$e , $r , $t are three partitions will be used to create LVM. Press "Enter" to proceed...";echo "Creating PV...." ;`sudo pvcreate $r $e $t 2>/dev/null`;sleep 2;sudo pvs;sleep 2;echo "Creating VG..."`sudo vgcreate vg $r 2>/dev/null`;sleep 2;sudo vgs ; sleep 2;echo "Creating LV...";echo "Give us what will be size of LV in MB: ";read q; `sudo lvcreate -L"$q"M vg 2>/dev/null`;sleep 3;sudo lvs;sleep 2;echo "mounting LV at /media/usb";`sudo mkdir /media/usb 2>/dev/null`;`sudo mkfs.ext4 /dev/vg/lvol0 2>/dev/null`;sleep 10;`sudo mount /dev/vg/lvol0 /media/usb 2>/dev/null `;echo -e "\nAll done\nyour current LVM:::--- `df -h | grep /media/usb`"
break
fi
fi
done
No comments:
Post a Comment