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
# 8  
Old 09-27-2013
---------- Post updated at 08:50 PM ---------- Previous update was at 08:24 PM ----------

Hi Robin,

Thanks a lot for the information.

however few doubts,

/etc/exclude.datavg - will this file be detected by the save vg command automatically ?

be sure to remove the directory /tmp/vgdata before you start and create your mksysb afterwards. - what data does this directory contain and wnt it affect the online vgs that are in use on the LPAR.

After restoring your mksysb elsewhere - can we take the backup of just this VG structure through mksysb and restore it elsewhere ?

or it has to be taken along with complete mksysb image and new LPAR build has to be done using that image, which will import the vg structure.

Please help on this.

Also, if you have any scripts for FS creation..that would be really helpful Smilie

Regards,
Priyank
# 9  
Old 09-27-2013
Hello arorap,

Thanks for the follow up questions.


The -e flag asks savevg vgname to read /etc/exclude.vgname so that should be the case. Have a look at the man page just to check it is in your version.



The directory /tmp/vgdata contains working information about the volume group as savevg runs. I have found that it is not always overwritten by subsequent savevg commands. I have used it to tweak the definition before saving. We have a server that has local LVM mirrored disk, but there is SAN storage on the DR server, but not enough to create the mirrors too. I got in and change the definition of the LVs to be a single copy only.

The directory is not generally in use, so it's best to clean it up.



For the last part, I'm slightly confused on your question. I think you are wanting to take the file created by savevg and restore it wherever you like. This is fine with two clauses:-
  1. Do you have enough disk (total space on free disk) to restore the VG?
  2. Are all the LVs (including jfslogs) and filesystems unique when comparing to the target server?
If the answer to both is Yes, then you should be okay. The file should really only contain information like "Build be logical volume aaa with these properties and then make a filesystem from it to be mounted as /bbb."

If there are conflicts, then there may be a way to use the content of /tmp/vgdata to adjust the save so you can use it on the target. If not, there are ways to extract the commands from the file and tweak them before executing the lot, but it is slower if you have lots/large filesystems.




Is this what you need?


Robin
# 10  
Old 09-27-2013
Hi Robin,

The directory /tmp/vgdata contains working information about the volume group as savevg runs. I have found that it is not always overwritten by subsequent savevg commands. I have used it to tweak the definition before saving. We have a server that has local LVM mirrored disk, but there is SAN storage on the DR server, but not enough to create the mirrors too. I got in and change the definition of the LVs to be a single copy only.

The directory is not generally in use, so it's best to clean it up.

What i meant was, the /tmp/vgdata contains the outputs from the savevg command only ? Or does it hold any data from the live volume groups that can effect the functionality of the VG's if we empty the directory /tmp/vgdata.

And the other question was...

I understood now, the file that will be created from the command:

Code:
savevg -ef /disaster/datavg.structure datavg

i.e /disaster/datavg.structure

can we copy this file manually (using scp or rcp) to another server and use the restvg command ?

Also can we edit this file and make few changes according the the destination server requirements ?

supposed source has a File systems as below

Code:
/dev/priyank1 100.00 98.41 1.59 99% /priyank/XXX/arora1
/dev/priyank2 100.00 98.41 1.59 99% /priyank/XXX/arora2

now the 'XXX' part here changes in every new LPAR we create.

so i want to edit the file( /disaster/datavg.structure ) and change the XXX and then restore it using restvg on the destination. IS that possible ?

Let me know if i didnt make it clear enough

Note: The above scenario is w.r.t a New Lpar build, in case of Prod-DR copy i know this will work just perfect

Again thanks a lot..i really appreciate you helping me out.

Regards,
PriyanK

Last edited by Scott; 10-18-2013 at 09:37 AM.. Reason: Please ease up on the zany formatting
# 11  
Old 09-30-2013
Hello again,

Q1
The directory /tmp/vgdata is only created by a savevg (or mksysb) and is not in use during normal running. Not a problem to open volume groups, mounted filesystems etc.

Q2
Yes, you can copy the file /disaster/datavg.structure (or whatever you choose to call it) to the target server. It is just a data file, so you could also rename it if you wish. You might need to be careful on how you copy it. Do a cksum on the file on the source and on the target to make sure it transferred without error. Consider it as a binary file.

Q3
You have three choices:-
  1. Update before backup
    Here you would run the savevg, then edit a file in /tmp/vgdata and re-run the savevg command
  2. Update before restore
    Here you would (on the target server) extract the details from the datavg.structure file into a script and edit them before executing - can be a bit slow
  3. Update after restore
    After running the restvg (assuming no LV or FS conflicts) then you rename the filesystems as you wish with a chfs command and remount
Which would you prefer? If you have no preference, then I would suggest we look at option 3.



Robin
This User Gave Thanks to rbatte1 For This Post:
# 12  
Old 10-02-2013
Quote:
You have three choices:-
  1. Update before backup
    Here you would run the savevg, then edit a file in /tmp/vgdata and re-run the savevg command
  2. Update before restore
    Here you would (on the target server) extract the details from the datavg.structure file into a script and edit them before executing - can be a bit slow
  3. Update after restore
    After running the restvg (assuming no LV or FS conflicts) then you rename the filesystems as you wish with a chfs command and remount
Which would you prefer? If you have no preference, then I would suggest we look at option 3.
1. I tried the 1st option, but it didnt workout and got some error. I had modified the <vgname.data> file in the /tmp/vgdata directory.

I had Modified the file as per the destination server File System Requirements and then while running savevg again i got some error saying the "File system doesnt exist"

2. I really dont have any idea about this procedure. Please provide more details if possible.

3.Update After Restore, you mean to say i create the same FS as per the source LPAR, and then edit the FS on the destination ?

One More Thing:

How about copying just modified <vgname.data> from the /tmp/vgdata to new LPAR and then creating the File systems using savevg ?

Regards,
Priyank
# 13  
Old 10-08-2013
Option 1 was untested. Presumably, the savevg reads the file on finding it and expects to search the filesystems listed. Maybe creating dummy directories of the required name might get this through, maybe not.


Option 2 requires you to use a few commands:-
Code:
cd /
restore –x –f /disaster/datavg.structure

You can then read the files in /tmp/vgdata/datavg to build the structures you need based on the original. A bit of scripting to read in a loop will do it.


Option 3 is perhaps the easiest.
Code:
restvg -q -f /disaster/datavg.structure hdisk2 hdisk3

....or whatever disks are appropriate. This will restore the structure of your volume group along with a format and mount of the filesystems assuming that there are no conflicts.

You can then:-
Code:
lsvg -l datavg | egrep -v "MOUNT|N\/A|:" | tr -s " " | cut -f7 -d " " | sort -r | xargs -tn 1 umount

For each filesystem you need to change you simply
Code:
chfs -m  newfs  origfs

Then to remount them (first time only)
Code:
lsvg -l datavg | egrep -v "MOUNT|N\/A|:" | tr -s " " | cut -f7 -d " " | sort | while read fs
do
   if [ ! -d $fs ]         # If the mount point does not exist....
   then
      mkdir $fs            # .....create it
   fi
   mount $fs
done

The loop is done in this way to ensure that all the mount points exist and if there are filesystems mounted under other filesystems that they are all in the right place. There has been many occasions where people would create filesystems such as:-
Code:
/a
/a/b
/a/c
/a/d

... creating the mount points and then mount /a which works and then they get confused why /a/b does not exist when they just created it. Of course they will have created /a/b in the root filesystem and then mounted /a which is empty.

You may find some mount-points for re-named filesystems get left behind by this as chfs will not delete them.

If you want to rename the logical volumes too, you need to add a step:-
Code:
chlv -n  newlv   oldlv

You may need to edit /etc/filesystems afterwards and verify that each logical volume update has been applied. I have had occasions where this didn't happen, but I think that has now been fixed, so it depends on the patches applied.



Robin
# 14  
Old 10-18-2013
Robin,

Code:
 
# restvg -r -d /tmp/appvg.data hdisk15 hdisk16
Will create the Volume Group: appvg
Target Disks: hdisk15 hdisk16
Allocation Policy:
Shrink Filesystems: no
Preserve Physical Partitions for each Logical Volume: no
 
Enter y to continue: y
appvg
oracle_XX
oracle_XX
oracle_XX
oracle_XX
ora_XX
sap_XXX
st_XXX
saXXX
saXX
usr_XXX
usr_XXX
usr_XXX
usr_XXX
XXXXXX
XXXXXX
XXXXXX
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems
grep: can't open /tmp/vgdata/appvg/filesystems

As you can see above...the file systems were created and mounted. i dont know why i am getting this error ??

Thanks
Priyank
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