Operating System - HP-UX
1834163 Members
2724 Online
110064 Solutions
New Discussion

seeking scripts to create filesystem

 
Hanry Zhou
Super Advisor

seeking scripts to create filesystem

I need to create multiple filesystems at same time, including lvcreate, newfs, mount,..
anybody has the script I can use?

Thanks,
none
6 REPLIES 6
Bill Hassell
Honored Contributor

Re: seeking scripts to create filesystem

These tasks are very customized (vg name, lvname, lvsize, lv options, mount point name, etc) so other than a general script that reads all the parameters from a data file, you'll just need to write each command into a script.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: seeking scripts to create filesystem

The time it takes to set up your data file is probably equal to the time it would take to write the script yourself.

There are so many options and different things you can do that this isn't going to be something you can take from something else.

The general structure would be this:

while read -r aa bb cc dd
do
# lvcreate
# lvextend
# mkdir
# newfs
# mount
done < youffile


aa bb cc dd are speace delimited varibales in your file.

lvm is a do it once and use for a long time task. In general iets best to do it by hand.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Geoff Wild
Honored Contributor

Re: seeking scripts to create filesystem

As Bill says - you'll have to do 1 of's - sort of like this:

# cat vgcreate.vg31iqa
mkdir /dev/vg31iqa
mknod /dev/vg31iqa/group c 64 0x1f0000
vgcreate -s 8 -p 128 /dev/vg31iqa `cat vg31iqa.devs`

# cat lvcreate.vg31iqa
lvcreate -L 512 -n lvlogA /dev/vg31iqa
mkfs -F vxfs -o version=3 /dev/vg31iqa/rlvlogA
lvcreate -L 512 -n lvmirrlogB /dev/vg31iqa
mkfs -F vxfs -o version=3 /dev/vg31iqa/rlvmirrlogB
lvcreate -L 7680 -n lvtemp /dev/vg31iqa
lvcreate -L 512 -n lvlogB /dev/vg31iqa
mkfs -F vxfs -o version=3 /dev/vg31iqa/rlvlogB
lvcreate -L 512 -n lvmirrlogA /dev/vg31iqa
mkfs -F vxfs -o version=3 /dev/vg31iqa/rlvmirrlogA


The vg31iqa.devs is just a list of devices:

/dev/dsk/c52t6d4
/dev/dsk/c54t6d4
/dev/dsk/c56t6d4
/dev/dsk/c58t6d4
/dev/dsk/c52t6d5
/dev/dsk/c54t6d5
/dev/dsk/c56t6d5
/dev/dsk/c58t6d5

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Sanjay_6
Honored Contributor

Re: seeking scripts to create filesystem

Hi,

Even if we have a script, you'll have to customize it to suit your needs. It is best to prepare your own script with all the commands pvcreate / vgcreate / vgextend / lvcreate / lvextend in the script. It will be much more easy.

Hope this helps.

Regds
Sridhar Bhaskarla
Honored Contributor

Re: seeking scripts to create filesystem

Hi,

I normally create the volume groups first and then make a config.file and use it as an input to my script. For ex., my config file is

This is only an example script I just wrote on the fly. It may or may not work. You will need to verify or improve on it.

#cat config.txt

vg01:lv1:2048:/mount1
vg02:lv2:4096:/mount2
vg03:lv3:1024:/mount3

#cat create_lvs.sh

while read line
do
VG=$(echo $line|awk '{FS=":";print $1}')
LV=$(echo $line|awk '{FS=":";print $2}'
SZ=$(echo $line|awk '{FS=":";print $3}'
MOUNT=$(echo $line|awk '{FS=":";print $4}'
echo Working on $LV in $VG
lvcreate -n $LV -L $SZ -r N $VG
newfs -F vxfs /dev/${VG}/r${LV}
mkdir -p $MOUNT
mount /dev/${VG}/${LV}$MOUNT
echo "/dev/${VG}/${LV} $MOUNT vxfs delaylog 0 2" >> /tmp/fstab.delta
done < config.txt

Once you are done, verify /tmp/fstab.delta file and append it to /etc/fstab.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Marvin Strong
Honored Contributor

Re: seeking scripts to create filesystem

you can do multis pretty easy with some easy loops.

Another thing to keep in mind, is doing the lvm commands manually keeps you sharp!

My scripts for lvm commands are mostly for DR recollect, and to recreate my vg's in a DR scenerio.