I have just created 15 luns on a san for use by HP-UX to create a new filesystem. Now, I need to have those luns recognized by the operating system and to be made into a single filesystem. Because there are 15 luns, it is likely I will have to repeat the same step 15 times. To better utilize my time, and to eliminate mistakes, here are the steps required to script much of the process.
1. Make the luns visible to the server as disk devices. The steps for this are:
Determine what the server sees now - the "before" picture"
ioscan -fnkC disk
Scan for new disk devices - this should be the luns allocated from the san (the will be just a hardware path and will not have a device file yet)
ioscan -fnC disk
Create the device files
insf
Check to make sure the the luns now have device files associated with them
ioscan -fnC disk
Use the xpinfo command from HP to list the device to lun association (available with the HP "XP" series of sans).
xpinfo -il
2. Verify that none of the luns are already being used
This should not be the case, but I am paranoid and this is a very easy to do sanity check.
Redirect the xpinfo -il command to a file and with vi save just the devices for the new luns - use awk '{print N$}' to print out just the device. Save the file (/tmp/wte_devices.txt). The file should look something like this:/tmp/wte_devices.txt:/dev/rdsk/c5t0d1/dev/rdsk/c5t9d0/dev/rdsk/c5t9d1/dev/rdsk/c5t9d2/dev/rdsk/c5t0d2/dev/rdsk/c5t1d7/dev/rdsk/c5t2d0/dev/rdsk/c5t2d1/dev/rdsk/c5t3d0/dev/rdsk/c5t3d6/dev/rdsk/c5t8d3/dev/rdsk/c5t8d4/dev/rdsk/c5t8d5/dev/rdsk/c5t8d6/dev/rdsk/c5t8d7For each device in the file check to see if there is an existing device in an existing volume group. Use the command vgdisplay -vgrep
for disk in `cat wte_devices.txt sed 's/\/dev\/rdsk\///g'` do echo "Disk device /dev/rdsk/$disk: " vgdisplay -vgrep $disk echo " " done
3. Initialized the luns for use by LVMFirst create the script to do this by issuing the following command:cat wte_devices.txt sed 's/\/dev/pvcreate -f \/dev/g' > wte_pvcreate.shThis should result in a script that contains the following lines:server: /tmp # cat wte_pvcreate.shpvcreate -f /dev/rdsk/c5t0d1pvcreate -f /dev/rdsk/c5t9d0pvcreate -f /dev/rdsk/c5t9d1pvcreate -f /dev/rdsk/c5t9d2pvcreate -f /dev/rdsk/c5t0d2pvcreate -f /dev/rdsk/c5t1d7pvcreate -f /dev/rdsk/c5t2d0pvcreate -f /dev/rdsk/c5t2d1pvcreate -f /dev/rdsk/c5t3d0pvcreate -f /dev/rdsk/c5t3d6pvcreate -f /dev/rdsk/c5t8d3pvcreate -f /dev/rdsk/c5t8d4pvcreate -f /dev/rdsk/c5t8d5pvcreate -f /dev/rdsk/c5t8d6pvcreate -f /dev/rdsk/c5t8d7chmod +x and running the script:server: /tmp # ./wte_pvcreate.shPhysical volume "/dev/rdsk/c5t0d1" has been successfully created.Physical volume "/dev/rdsk/c5t9d0" has been successfully created.Physical volume "/dev/rdsk/c5t9d1" has been successfully created.Physical volume "/dev/rdsk/c5t9d2" has been successfully created.Physical volume "/dev/rdsk/c5t0d2" has been successfully created.Physical volume "/dev/rdsk/c5t1d7" has been successfully created.Physical volume "/dev/rdsk/c5t2d0" has been successfully created.Physical volume "/dev/rdsk/c5t2d1" has been successfully created.Physical volume "/dev/rdsk/c5t3d0" has been successfully created.Physical volume "/dev/rdsk/c5t3d6" has been successfully created.Physical volume "/dev/rdsk/c5t8d3" has been successfully created.Physical volume "/dev/rdsk/c5t8d4" has been successfully created.Physical volume "/dev/rdsk/c5t8d5" has been successfully created.Physical volume "/dev/rdsk/c5t8d6" has been successfully created.Physical volume "/dev/rdsk/c5t8d7" has been successfully created.
4. Extend an existing volume group.For this example I was able to extend an existing volume group - if this is not possible then a new volume group would have to be created.vgextend /dev/vgdata11 /dev/dsk/diskidserver: /tmp # cp wte_pvcreate.sh wte_vgextend.shserver: /tmp # chmod +x wte_vgextend.shusing the vi substitution command, change the "pvcreate -f" to "vgextend /dev/vgdata11" and change rdsk to dsk%s/pvcreate -f/vgextend \/dev\/vgdata11/gserver: /tmp # cat wte_vgextend.shvgextend /dev/vgdata11 /dev/rdsk/c5t0d1vgextend /dev/vgdata11 /dev/rdsk/c5t9d0vgextend /dev/vgdata11 /dev/rdsk/c5t9d1vgextend /dev/vgdata11 /dev/rdsk/c5t9d2vgextend /dev/vgdata11 /dev/rdsk/c5t0d2vgextend /dev/vgdata11 /dev/rdsk/c5t1d7vgextend /dev/vgdata11 /dev/rdsk/c5t2d0vgextend /dev/vgdata11 /dev/rdsk/c5t2d1vgextend /dev/vgdata11 /dev/rdsk/c5t3d0vgextend /dev/vgdata11 /dev/rdsk/c5t3d6vgextend /dev/vgdata11 /dev/rdsk/c5t8d3vgextend /dev/vgdata11 /dev/rdsk/c5t8d4vgextend /dev/vgdata11 /dev/rdsk/c5t8d5vgextend /dev/vgdata11 /dev/rdsk/c5t8d6vgextend /dev/vgdata11 /dev/rdsk/c5t8d7Run the script:server: /tmp # ./wte_vgextend.shVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.confVolume group "/dev/vgdata11" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.conf
5. Create the logical volume
server: /tmp # lvcreate -L 100000 -n lvol_u20 /dev/vgdata11
Logical volume "/dev/vgdata11/lvol_u20" has been successfully created withcharacter device "/dev/vgdata11/rlvol_u20".Logical volume "/dev/vgdata11/lvol_u20" has been successfully extended.Volume Group configuration for /dev/vgdata11 has been saved in /etc/lvmconf/vgdata11.conf
6. Make the new filesystem
server: /tmp # mkfs -F vxfs -o bsize=8192,largefiles /dev/vgdata11/lvol_u20 version 3 layout 102400000 sectors, 12800000 blocks of size 8192, log size 256 blocks unlimited inodes, 12800000 data blocks, 12799232 free data blocks 391 allocation units of 32768 blocks, 32768 data blocks last allocation unit has 20480 data blocks first allocation unit starts at block 0 overhead per allocation unit is 0 blocks
7. Mount the new filesystem
Make the mountpoint:
server: /tmp # mkdir -p
Edit /etc/fstab
/dev/vgdata11/lvol_u20
Mount the filesystem
server: /tmp # mount
Change ownership of the filesystemserver: /tmp # chown oracle:dba
8. Verify the size and permissions
bdfls -ld
thanks to http://networktechnologist.com/tips-hpux-lvm-script.html
No comments:
Post a Comment