Need to create an for loop for adding an disk in veritas volume group.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to create an for loop for adding an disk in veritas volume group.
# 1  
Old 07-31-2012
Need to create an for loop for adding an disk in veritas volume group.

Hi Experts

I need an script to add an disk in to the veritas volume manager disk group.

For example:
Code:
# cd /tmp
# view disk
c6t5d2
c6t2d1
c6t3d7
c6t11d2
c7t11d2
c6t11d6

Normally we add the disk like this:
Code:
# vxdg -g freedg freedisk01=c6t5d2
# vxdg -g freedg freedisk02=c6t2d1
# vxdg -g freedg freedisk03=c6t3d7 and so on..

I am looking for for forloop where i could use freedisk(n+1) till all the disk get added.

Code:
# for i in `cat /tmp/disk`
do
vxdg -g freedg freedisk(n+1)=$i
done

I am not sure about the correct syntax used in above script for freedisk(n+1) appreciate if any one could suggest me.

Regards
Indrajit Bhagat

Last edited by Scott; 07-31-2012 at 09:14 AM.. Reason: Code tags
# 2  
Old 07-31-2012
Hi


Code:
$ awk '{printf "vxdg -g freedg freedisk%02d=%s\n",++i,$0;}' /tmp/disk
vxdg -g freedg freedisk01=c6t5d2
vxdg -g freedg freedisk02=c6t2d1
vxdg -g freedg freedisk03=c6t3d7
vxdg -g freedg freedisk04=c6t11d2
vxdg -g freedg freedisk05=c7t11d2
vxdg -g freedg freedisk06=c6t11d6

If this is the output you expected, you can redirect the above output to a file and run it.


Guru.
# 3  
Old 07-31-2012
In ksh you could also use:
Code:
#!/bin/ksh
typeset -Z2 n=1
for i in $(cat /tmp/disk)
do
    vxdg -g freedg freedisk$n=$i
    ((n++))
done

# 4  
Old 08-06-2012
Created a Following Script

Code:
#!/bin/sh 
disknum=14
for i in `cat /tmp/disk` 
do 
  if [ $disknum -lt 18 ]; then 
    vxdg -g freedg adddisk disk$disknum=$i 
  else 
    echo "All the disk is added to the diskgroup" 
  fi 
  disknum=$(( disknum +1 ))
done


Which is working fine now

Last edited by Franklin52; 08-06-2012 at 03:45 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to extend a disk in veritas volume manager in veritas cluster?

Hi Experts, I wanted to extend a veritas file system which is running on veritas cluster and mounted on node2 system. #hastatus -sum -- System State Frozen A node1 running 0 A node2 running 0 -- Group State -- Group System Probed ... (1 Reply)
Discussion started by: Skmanojkum
1 Replies

2. Red Hat

No space in volume group. How to create a file system using existing logical volume

Hello Guys, I want to create a file system dedicated for an application installation. But there is no space in volume group to create a new logical volume. There is enough space in other logical volume which is being mounted on /var. I know we can use that logical volume and create a virtual... (2 Replies)
Discussion started by: vamshigvk475
2 Replies

3. UNIX for Dummies Questions & Answers

How to create a volume group, logical volume group and file system?

hi, I want to create a volume group of 200 GB and then create different file systems on that. please help me out. Its becomes confusing when the PP calculating PP. I don't understand this concept. (2 Replies)
Discussion started by: kamaldev
2 Replies

4. Solaris

Veritas disk group not the same on each cluster node.

Need help getting all disk devices back on node 2 the same as node 1. Recently Veritas and/or Sun cluster got wrecked on my 2 node Sun cluster after installing the latest patch cluster. I backed out the patches and then node 2 could see only half of the devices and Veritas drives (though format... (0 Replies)
Discussion started by: buggin
0 Replies

5. AIX

Create new Volume Group

Good afternoon all, I'll probably confuse everyone as I'm a Windows guy dealing with AIX 6.1 and can't quite figure out how to do something. I have a P520 server running 2 LPARs and we have an IVM (not HMC).Within the IVM under Virtual Storage Management, when I check the Physical Volumes, I have... (4 Replies)
Discussion started by: Spellbound
4 Replies

6. AIX

Adding a Volume Group to an HACMP Resource Group?

Hi, I have a 2 node Cluster. Which is working in active/passive mode (i.e Node#1 is running and when it goes down the Node#2 takes over) Now there's this requirement that we need a mount point say /test that should be available in active node #1 and when node #1 goes down and node#2 takes... (6 Replies)
Discussion started by: aixromeo
6 Replies

7. UNIX for Dummies Questions & Answers

VERITAS Volume Manager - mirror a disk/volume

I have a machine (5.10 Generic_142900-03 sun4u sparc SUNW,Sun-Fire-V210) that we are upgrading the storage and my task is to mirror what is already on the machine to the new disk. I have the disk, it is labeled and ready but I am not sure of the next steps to mirror the existing diskgroup and... (1 Reply)
Discussion started by: rookieuxixsa
1 Replies

8. UNIX for Dummies Questions & Answers

Configure disk group with veritas

People i have an a storage i create two virtual disk 1 y 2. In the virtual disk 1 i configure 8 volumes and in the Vd2 configure 5 volumes. Now i want to create a disk group called Prod2 y Dev2 but when i go to vxdiskadm and i choose add disk o encapusalte when i press list to list the disk... (0 Replies)
Discussion started by: enkei17
0 Replies

9. UNIX for Advanced & Expert Users

Veritas Volume Manager question (Disk layout with 4 plexes)

I am trying to build a veritas volume similar to an existing volume on another server. The output on source server is: usbtor12# vxprint -hrtg appdg v anvil_sqlVOL - ENABLED ACTIVE 629145600 SELECT - fsgen pl anvil_sqlVOL-01 anvil_sqlVOL ENABLED ACTIVE 629145600... (3 Replies)
Discussion started by: momin313
3 Replies

10. UNIX and Linux Applications

Veritas silent disk group creation

I am trying to write a kornshell script that will automatically create veritas disk groups. However, the only utility that I can find that will create the diskgroup is vxdiskadd, which prompts with interactive questions. I've tried to pass the answers through to vxdiskadd, but I receive the... (0 Replies)
Discussion started by: jm6601
0 Replies
Login or Register to Ask a Question