File system creation script on AIX 6.1 using while loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File system creation script on AIX 6.1 using while loop
# 1  
Old 09-23-2013
File system creation script on AIX 6.1 using while loop

Code:
#!/bin/sh

echo "VG: "
read VG
echo "LP: "
read LP
echo "SAP: "
read SAP
echo "NUM: "
read NUM
echo "SID: "
read SID


while [[ $NUM -lt 2 ]]; read VG LP SAP NUM SID ; do

mklv   -y   $SAP$NUM   -t   jfs2   -e   x   $VG   $LP;

crfs   -v   jfs2   -d   /dev/$SAP$NUM   -m   /oracle/$SID/$SAP$NUM  -A   yes   -p   rw -a   log=INLINE    -a   options=cio;

NUM=$((NUM+1)) OR (( NUM++ ))

done

I want to create file system on AIX as priyank1, priyank2 and so on...

VG is the volume group name, LP is the logical partition/size of FS, SAP is the name "priyank" and SID is the Directory under /oracle..

Please let me know if any further details needed.
Please help the above script is not working...not reading the variable properly while executing the commands.

also i have placed 2 variable together $SAP$NUM , will this be a problem ?

Error is unable to find the vg name...while the vg is already available.

Regards,
Priyank
# 2  
Old 09-23-2013
Is this a valid use of the -e option of mklv?:
Code:
... -e   x ...

You should also test for the success of mklv before proceeding to the next (crfs) command. That would save on unnecessary output and more errors.

Not sure what this read statement is doing here:
Code:
while [[ $NUM -lt 2 ]]; read VG LP SAP NUM SID ; do

Perhaps you should remove that?

I presume you're trying to increment NUM here?:
Code:
NUM=$((NUM+1)) OR (( NUM++ ))

Try:
Code:
NUM=$((NUM + 1))

But I guess you want to go from 1 up to NUM?
Code:
...
printf "NUM: "
read NUM
CUR=1
...
...
while [ $CUR -lt $NUM ]; do
  ...
  CUR=$((CUR + 1))
  ...
done

This User Gave Thanks to Scott For This Post:
# 3  
Old 09-26-2013
Hi Scott,

thanks a lot, that worked.

i think the only problem now is...it is still giving below Error:

" crfs: /oracle/E6P/sapdata1 file system already exists "

when the file system doesnt exist at all...and i am creating a new one.
Code:
#!/bin/bash
echo "VG: "
+ echo VG:
VG:
read VG
+ read VG
utilvg
echo "LP: "
+ echo LP:
LP:
read LP
+ read LP
1
echo "SAP: "
+ echo SAP:
SAP:
read SAP
+ read SAP
sapdata
echo "NUM: "
+ echo NUM:
NUM:
read NUM
+ read NUM
3
echo "SID: "
+ echo SID:
SID:
read SID
+ read SID
E6P
echo "CUR: "
+ echo CUR:
CUR:
read CUR
+ read CUR
1
while [ $CUR -lt $NUM ]; do
  (mklv -y $SAP$CUR -t jfs2 -e x $VG $LP)
  crfs -v jfs2 -d /dev/$SAP$CUR -m /oracle/$SID/$SAP$CUR -A yes -p rw -a log=INLINE -a options=cio;
  mount /oracle/$SID/$SAP$CUR
  CUR=$((CUR + 1))
done
+ [ 1 -lt 3 ]
+ mklv -y sapdata1 -t jfs2 -e x utilvg 1
sapdata1
+ crfs -v jfs2 -d /dev/sapdata1 -m /oracle/E6P/sapdata1 -A yes -p rw -a log=INLINE -a options=cio
crfs: /oracle/E6P/sapdata1 file system already exists
+ mount /oracle/E6P/sapdata1
+ CUR=2
+ [ 2 -lt 3 ]
+ mklv -y sapdata2 -t jfs2 -e x utilvg 1
sapdata2
+ crfs -v jfs2 -d /dev/sapdata2 -m /oracle/E6P/sapdata2 -A yes -p rw -a log=INLINE -a options=cio
crfs: /oracle/E6P/sapdata2 file system already exists
+ mount /oracle/E6P/sapdata2
Replaying log for /dev/sapdata2.
mount: /dev/sapdata2 on /oracle/E6P/sapdata2: Unformatted or incompatible media
+ CUR=3
+ [ 3 -lt 3 ]


Last edited by Scott; 09-26-2013 at 08:36 AM.. Reason: Removed hideous green from text
# 4  
Old 09-26-2013
I don't think it would be telling you that if it weren't true.

What does lsvg -l utilvg and lsfs show?

(also make sure the filesystem is not already in /etc/filesystems)
# 5  
Old 09-26-2013
Is this for rebuilding your non-rootvg volume groups for DR?

If so, there is a better way. If not, I will keep out of it.



Robin
# 6  
Old 09-26-2013
@Scott: sorry for bothering on this...it was actually my mistake.

the script works fine now. i need to merge several such scripts for FS creation on AIX.

i am going to need some more help on this for sure.

@rbatte1 : yes this is for new LPAR builds as well as rebuliding non-rootvg's for DR.

please let me know if there is any better way Smilie
# 7  
Old 09-26-2013
If you have an existing volume group that you want to recover the structure for before restoring the content, then your can use savevg and restvg

In our site, we have created an exclude file for each volume group so that the files/directories are not backed up, just the Logical Volumes and Filesystem information. For a volume group datavg we have a file called /etc/exclude.datavg that just contains one line:-
Code:
^\./

This can then be used with the following command:-
Code:
savevg -ef /disaster/datavg.structure datavg

What this is doing is saving the volume group, but excluding everything it finds that matches the pattern in the file. The pattern we have picked means it excludes everything, so you just get the structure, for which the definitions are a few small files. The directory /disaster needs to be in the root volume group, but not necessarily in the root filesystem. It just needs to be somewhere that will be included on your mksysb media.

Be sure to remove the directory /tmp/vgdata before you start and create your mksysb afterwards. Of course you can use whatever file name you like to save the information. You can copy that to another server that is already running and use it if you wish. You may need to be aware of conflicting logical volumes or filesystems in this case.

After restoring your mksysb elsewhere, you can use the following to build your volume group:-
Code:
restvg -q -f /disaster/datavg.structure hdiskx hdisky hdiskz

You need to give it enough disks to build what you had before.

I used to script this up with a mklv then a crfs using the LV I'd just built and on some servers it could take 90 minutes to run the script. When we got wise and used restvg it was about 10 minutes and the filesystems were all prepared, added to /etc/filesystems and mounted ready for data restore.


It is such a joy to recover with such ease and it emphasises to me why AIX is an excellent OS choice.



I hope that this helps. Let me know if I've not made anything clear.

Robin
Liverpool/Blackburn
UK
These 2 Users Gave Thanks to rbatte1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read file input in while loop does not work on AIX system

I'm working on Aix 6.1 and using ksh shell. The below works fine on Linux bash or ksh shell . while IFS= read -r dirpath ; do echo "Hi" done <<<"$var" However, any such while loop that reads the input from file or variable using <<< fails on Aix system with the below error: Below... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Solaris

Solaris 10 luupgrade flash archive file system creation failed

Hey guys, I'm attempting to migrate us to a new box. First problem I had was the change in architecture going from sun4u to sun4v, we have a Sun M5000 and are moving to a Fujitsu M10-4. I figured out how to make the flash archive work between architectures. Now I appear to be running into an... (2 Replies)
Discussion started by: kaledragule
2 Replies

3. Shell Programming and Scripting

CSV File Creation Within Shell Script

Hi All, I am trying to create a CSV file within a shell script test.ksh and the code snippet is something like below: #!/usr/bin/ksh # Set required variables. . $HOME/.prof # Output file path Group1=/tmp/G1.csv Group2=/tmp/G2.csv Group3=/tmp/G3.csv $ORACLE_HOME/bin/sqlplus -s... (2 Replies)
Discussion started by: swasid
2 Replies

4. Solaris

Creation of zone based on zfs root file system

Hi all I want to know if suppose my global zone has UFS root file system & now I want to create non global zone with ZFS root file system. Is it possible.....If this is possible then how will I able to create zone based on ZFS root file system in global zone having UFS based root file system (5 Replies)
Discussion started by: sb200
5 Replies

5. Shell Programming and Scripting

Aix .ksh for loop script.

Hi, I'm trying to write a for loop to run through a list of servers and for each server copy a file to a backup file. But I can't seem to get it to run through my server list. It work for individual servers, please see below. #!/bin/ksh SSH_USERID=khcuser webservers="server1 server2" ... (2 Replies)
Discussion started by: elmesy
2 Replies

6. AIX

AIX Bunch of printers queue creation script - HELP

I'd seek for help on how to create a bunch of printers in AIX 6.x or equal or above in one go – say like I have 35 printers to create in 4 different AIX Nodes every month – I currently create it manually like below:- How can I automatic this creation on all the 4-5 Nodes – not actually automatic... (3 Replies)
Discussion started by: shiv2001in
3 Replies

7. Shell Programming and Scripting

file creation inside loop

i=1 while do touch TC$i.txt i=`expr $1 + 1` done echo "files created successfully" What is wrong with code...its running continuosly... (4 Replies)
Discussion started by: villain41
4 Replies

8. AIX

how to loop through non-empty files with shell script on AIX

I have av script that loops through some statistic files to create a report. We would like to only loop through non-empty files as these files create an empty report-line. I have figured out how to find the non-empty files, but not how to loop through only those files. Here is the code that finds... (4 Replies)
Discussion started by: Tessa
4 Replies

9. Shell Programming and Scripting

Creation of script,if the data file have more than one entry!!!

1.Daily there will be 14 files in the data directory 2.someday's the 14 files receive more than once r twice with different time stamps....we need to chk the count of the file and if the count of the file is two.we need to combine the both the files. 3. if any duplicate data is there just... (1 Reply)
Discussion started by: bobprabhu
1 Replies

10. HP-UX

file system creation

I won't to remove a filesystem /dev/vg01/lvo1 and copy the same to different vg ex:- /dev/vg02. Pls give the required step to be followed to complete the said process (3 Replies)
Discussion started by: kamlesh_k
3 Replies
Login or Register to Ask a Question