lvcreator… Interactive :)

I know a while back I wrote a lvextendr doohickey that was part of a vgextendr thought process and I thought maybe I would need a creator as well.  I did… yesterday.  If you are looking for that other one it is here vgextendr.  This is another semi-interactive utility and of course is a “20 lines or less” script … 🙂

# Interactive lvcreate
cd /
echo “Type the name of your new filesystem, then press [ENTER]”
read fsname
mkdir $fsname
echo “Let’s see what we have to work with…”
echo “Please select a number less than `vgdisplay|grep Free|awk ‘{print $5}’`”
read freePE
echo “Multiply your number by `vgdisplay|grep “PE Size”|awk ‘{print $3}’` to see your new size”
PEsize=”`vgdisplay|grep “PE Size”|awk ‘{print $3}’|awk -F “.” ‘{print $1}’`”
let “total = (($freePE * $PEsize))”
echo “Now let’s create the new filesystem @ $total MB”
echo “Type a name for your new logical volume, then press [ENTER]”
read lvname
vgroup=”`vgdisplay|grep “VG Name”|awk ‘{print $3}’`”
lvcreate -l +$freePE /dev/mapper/$vgroup -n $lvname
mkfs.ext3 /dev/$vgroup/$lvname
tune2fs -c 0 -i 0 -O dir_index -L /$fsname /dev/$vgroup/$lvname
tune2fs -l /dev/$vgroup/$lvname
echo “/dev/$vgroup/$lvname /$fsname                  ext3   defaults        1 2” >> /etc/fstab
mount -a


, , , , , ,

  1. #1 by David Bruce on June 21, 2010 - 11:06 am

    Very nice – it’s one of those things we should have a script for, but I don’t have to fool with it enough to have done it.

  2. #2 by gmconklin on June 11, 2010 - 9:43 am

    OK, OK… I know it is 23 lines… It is < 20 lines without the interaction though 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: