Sponsored Content
Top Forums Shell Programming and Scripting File system creation script on AIX 6.1 using while loop Post 302861111 by rbatte1 on Tuesday 8th of October 2013 06:27:41 AM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
All times are GMT -4. The time now is 11:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy