Using MirrorDisk/UX to mirror vg00 on an HP-UX 11.31 Itanium server

Where PRIMARY is the current OS disk and SECONDARY is the disk on which you want to create the mirror:

# idisk -Rw /dev/rdisk/SECONDARY

# echo "3" > /tmp/pdf
# echo "EFI $(diskinfo /dev/rdisk/PRIMARY_p1 | grep size | while read label size kbytes; do echo ${size}/1024 | bc; done)MB" >> /tmp/pdf
# echo "HPUX $(diskinfo /dev/rdisk/PRIMARY_p2 | grep size | while read label size kbytes; do echo ${size}/1024 | bc; done)MB" >> /tmp/pdf
# echo "HPSP $(diskinfo /dev/rdisk/PRIMARY_p3 | grep size | while read label size kbytes; do echo ${size}/1024 | bc; done)MB" >> /tmp/pdf

# idisk -f /tmp/pdf -w /dev/rdisk/SECONDARY
# idisk /dev/rdisk/SECONDARY

# ioscan; insf -e -C disk; ioscan -fnNC disk

# efi_fsinit -d /dev/rdisk/SECONDARY_p1
# pvcreate -B /dev/rdisk/SECONDARY_p2
# vgextend vg00 /dev/disk/SECONDARY_p2
# mkboot -e -l /dev/rdisk/SECONDARY

# efi_ls -d /dev/rdisk/PRIMARY_p1
# efi_ls -d /dev/rdisk/SECONDARY_p1

# lifls -l /dev/rdisk/PRIMARY_p2
# lifls -l /dev/rdisk/SECONDARY_p2

# mkboot -a "boot vmunix -lq" /dev/rdisk/PRIMARY
# mkboot -a "boot vmunix -lq" /dev/rdisk/SECONDARY

# efi_cp -d /dev/rdisk/PRIMARY_p1 -u /EFI/HPUX/AUTO /tmp/prim
# cat /tmp/prim

# efi_cp -d /dev/rdisk/SECONDARY_p1 -u /EFI/HPUX/AUTO /tmp/mir
# cat /tmp/mir

# for i in `pvdisplay -v /dev/disk/PRIMARY_p2 | grep 'current.*0000 $' | awk 'BEGIN{ ORS=" " }{ print $3 }'`; do echo lvextend -m 1 $i /dev/disk/SECONDARY_p2; done | sh -x

# lvlnboot -R /dev/vg00
# lvlnboot -v

# setboot -a SECONDARY_DISK_HW_PATH

# echo "1 /dev/disk/SECONDARY_p2" >> /stand/bootconf

# dd if=/dev/rdisk/PRIMARY_p3 of=/dev/rdisk/SECONDARY_p3 bs=1024k

Reply to “Why I’ve finally had it with my Linux server and I’m moving back to Windows”

This is a counter-rant in reply to David Gewirtz’s article on ZDnet “Why I’ve finally had it with my Linux server and I’m moving back to Windows“.

Allow me to use people moving as an analogy to computing.  On one end of the spectrum you have desktop computers.  These are like cars.  There is a range from Honda Civic to Chevrolet Corvette; from the Apple iMac to the Alienware Area-51; from the simple, no nonsense, no frills consumer-grade to the over-the-top, extreme performance toy.  For the most part people operating these types of products care less about the tool they are using, but the job for which it is being used.  My grandmother doesn’t need anything more complicated than her Buick Century to go to church and the grocery store, just like she doesn’t need anything more complicated than the Windows 7 HP desktop she got from Wal-Mart.

Next you have workstations, which are analogous to vans and small busses.  People who need vans generally have a bit more work they need their vehicle to do than the car drivers, but essentially vans are just cars scaled up a bit.  But still, the products that fall into this category are tools used mainly by normal people whose focuses aren’t on the tools themselves, but what they are trying to accomplish with the tools: getting the kids to basketball practice or getting to work.

Finally we have servers.  In terms of the transportation analogy servers range from the city bus all the way up through 747s.  Being such a big category, we can break it down even further.

At the low end we have busses and Windows servers.  Both are very functionally similar to the consumer-grade products, but on a scale that generally requires operators with some only basic training.

Next we have small aircraft and Linux servers.  These tools bear very little resemblance to previous categories making the need for advanced training necessary.  While any car driver could probably sit down at the wheel of a bus and figure it out, the same could not be said for a car driver in an airplane.  In return for the complication, however, airplanes are much faster and more powerful.

Next are airliners and big iron; somewhat similar to their smaller brethren, but even more complicated and capable.  These machines are designed to handle large loads quickly and safely, but only when controlled by extremely well trained and knowledgeable people.

The thing that really differentiates the last category from the first two is that normal people generally don’t own these things.  Owners of things in this category are generally companies or governments and the people operating them are generally doing it as a career, not casually.  The focus of the operators of this equipment is actually operating the equipment, in contrast to the focus of people operating in other categories.  So, yes, Linux/Unix servers and airplanes are more complicated than alternatives.  People running them do need to know what they are doing.  Thinking that because you can drive a car you should be able to jump in a Gulf Stream is ludicrous.  Thinking that people who can drive cars /should/ be able to jump in a Gulf Stream is insane.  So, Mr. Gewirtz, please stay away from the servers and let the professionals take care of it.  We don’t need you in front of a console just like we don’t need you in a cockpit.

Change Process List sorting in GlancePlus

The process list in glance is sorted by CPU usage by default. You can also sort by process name and memory usage (RSS). To do this, from the process list screen hit “o”. You will be presented with a prompt:

Go to 1) Process; 2) Transaction; 3) Thread option screen(1) :

Select 1.

You’ll now be taken to a screen that looks like this:

                      INTERESTING PROCESS THRESHOLD OPTIONS

Display processes with resource usage:              Current Thresholds:

      CPU Utilization             >                 (0.0                %      )
      Disk I/O Rate               >                 (1.0                IOs/sec)
      Resident Set Size           >                 (20                 Mbytes )
      Virtual Set Size            >                 (500                Mbytes )
      User name                   =                 (all                       )
      Program name                =                 (all                       )
      TTY path name               =                 (all                       )
      Use match logic (and/or)    :                 (or                        )
      Sort key (name/cpu/rss)     :                 (cpu                       )

      Glance started or last reset: 08/18/2011  12:54:21
      Current refresh interval        : 5 seconds

Move the cursor down to the “sort key” field and type the name of key by which you want to sort. In parenthesis to the right is the current value. You’ll be prompted:

Set your user defaults to these values  (y/n/c)?

Press “y”.

 

http://deryaoktay.wordpress.com/2011/02/07/how-to-sort-processes-by-rss-memory-utilization-in-glance-in-hpux/

Display script output on screen and log it to a file at the same time

I’ve written plenty of scripts in the past where I’ve had to choose, do I want to script to output to stdout or do I want it to log to a file? Sure, if I’m outputting to stdout I could always call the script and pipe to tee to generate a log, but if I’m writing a script for others to use maybe I don’t want to have to depend on them to do that. Or maybe I just want to be lazy and not have to remember to pipe to tee every time I run the script.

Well, I just found the greatest trick that lets you do both from within the script.

#!/bin/bash

LOGFILE=${0##*/}.out
exec > >(tee ${LOGFILE})
exec 2>&1

( do stuff that generates output to stdout or stderr )

First, the ${0##*/} is some magic that works similarly to basename $0, but is way cooler looking. It works in bash, and I’ve read it works in ksh but I haven’t tested that.

Second is the exec > >(tee ${LOGFILE}) bit. I don’t know much about it, but apparently > >( ) is functionally similar to a pipe. It takes the script’s stdout and sends it to tee. Combine that with the exec 2>&1 and you’ve got both stderr and stdout getting piped to tee. Like I said, I don’t fully understand this technique, but it sure does work pretty well.

Thanks, Naked Ape!

Update – August 19, 2011 at 10:45:
I’ve been doing research on this. The ${0##*/} bit uses a shell feature called parameter expansion in bash or parameter substitution in ksh. According to the bash manpage:

${parameter##word}
The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of the value of parameter, then the result of the expansion is the expanded value of parameter with the longest matching pattern deleted. If parameter is @ or *, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with @ or *, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.

The exec > >(some_command) bit is called process substitution. It is supported in bash on machines that support /dev/fd or named pipes. It’s supported in ksh93 on machines that support /dev/fd.

Using Agile View in ioscan

With HP-UX 11.31 comes “agile” disk naming. Tips for using agile view in ioscan:

The -N flag turns on agile view

Before:

# ioscan -fnC disk | head -n 15
Class     I  H/W Path     Driver S/W State   H/W Type     Description
=====================================================================
disk      1  0/1/1/0.0.0.0.0                     sdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                         /dev/dsk/c3t0d0     /dev/dsk/c3t0d0s2   /dev/rdsk/c3t0d0    /dev/rdsk/c3t0d0s2
                         /dev/dsk/c3t0d0s1   /dev/dsk/c3t0d0s3   /dev/rdsk/c3t0d0s1  /dev/rdsk/c3t0d0s3
disk      2  0/1/1/0.0.0.1.0                     sdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                         /dev/dsk/c3t1d0     /dev/dsk/c3t1d0s2   /dev/rdsk/c3t1d0    /dev/rdsk/c3t1d0s2
                         /dev/dsk/c3t1d0s1   /dev/dsk/c3t1d0s3   /dev/rdsk/c3t1d0s1  /dev/rdsk/c3t1d0s3
disk      3  0/1/1/0.0.0.2.0                     sdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                         /dev/dsk/c3t2d0     /dev/dsk/c3t2d0s2   /dev/rdsk/c3t2d0    /dev/rdsk/c3t2d0s2
                         /dev/dsk/c3t2d0s1   /dev/dsk/c3t2d0s3   /dev/rdsk/c3t2d0s1  /dev/rdsk/c3t2d0s3
disk     10  0/2/0/0/0/0/4/0/0/0.4.41.0.0.0.0    sdisk   CLAIMED     DEVICE       HP      OPEN-V
                         /dev/dsk/c6t0d0   /dev/rdsk/c6t0d0
disk     11  0/2/0/0/0/0/4/0/0/0.4.41.0.0.0.1    sdisk   CLAIMED     DEVICE       HP      OPEN-V
                         /dev/dsk/c6t0d1   /dev/rdsk/c6t0d1

After:

# ioscan -fnNC disk | head -n 15
Class     I  H/W Path  Driver S/W State   H/W Type     Description
===================================================================
disk      5  64000/0xfa00/0x0   esdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                      /dev/disk/disk5      /dev/disk/disk5_p2   /dev/rdisk/disk5     /dev/rdisk/disk5_p2
                      /dev/disk/disk5_p1   /dev/disk/disk5_p3   /dev/rdisk/disk5_p1  /dev/rdisk/disk5_p3
disk      6  64000/0xfa00/0x1   esdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                      /dev/disk/disk6      /dev/disk/disk6_p2   /dev/rdisk/disk6     /dev/rdisk/disk6_p2
                      /dev/disk/disk6_p1   /dev/disk/disk6_p3   /dev/rdisk/disk6_p1  /dev/rdisk/disk6_p3
disk      7  64000/0xfa00/0x2   esdisk   CLAIMED     DEVICE       HP      EH0146FARWD
                      /dev/disk/disk7      /dev/disk/disk7_p2   /dev/rdisk/disk7     /dev/rdisk/disk7_p2
                      /dev/disk/disk7_p1   /dev/disk/disk7_p3   /dev/rdisk/disk7_p1  /dev/rdisk/disk7_p3
disk      9  64000/0xfa00/0x4   esdisk   CLAIMED     DEVICE       Optiarc DVD RW AD-5590A
                      /dev/disk/disk9   /dev/rdisk/disk9
disk     68  64000/0xfa00/0xe   esdisk   CLAIMED     DEVICE       HP      OPEN-V
                      /dev/disk/disk68   /dev/rdisk/disk68

Use -m dsf to translate between old-school and agile device special files

Old to new:

# ioscan -m dsf /dev/dsk/c6t0d1
Persistent DSF           Legacy DSF(s)
========================================
/dev/disk/disk69         /dev/dsk/c6t0d1

New to old (a great way to list multiple paths!):

# ioscan -m dsf /dev/disk/disk69
Persistent DSF           Legacy DSF(s)
========================================
/dev/disk/disk69         /dev/dsk/c6t0d1
                         /dev/dsk/c10t0d1

Turn off the monitor in command line mode (runlevel 3) in RHEL

In runlevel 3, RHEL (most Linuxes, probably) only blanks the monitor after so much inactivity, it doesn’t tell the monitor to actually turn off. This has annoyed me for years, but I just found a command to turn off and on the monitor:

# /usr/sbin/vbetool dpms [off|on]

I’ve haven’t rigged it to be triggered by console activity yet, but at least I can manually turn off and on the monitor through software now.

Find server model and serial number in Linux/RHEL

Ever needed to know the exact model or serial number of a Linux machine but only have access to the command line?

# dmidecode | egrep -i "product name|serial number"
        Product Name: ProLiant DL360 G7
        Serial Number: USE000A11M
        Serial Number: USE000A11M
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: Not Specified
        Serial Number: 57QXF00000D9D1
        Serial Number: 57QXF00000D9B2

A lot of the individual hardware components have serial numbers (or, could have serial numbers), but the first two identical ones are the actual system serial number. On this particular machine the two serial numbers listed at the end seem to be for the power supplies.

Update – September 09, 2011 at 09:31:
Even better:

# dmidecode -t system
# dmidecode 2.9
SMBIOS 2.6 present.

Handle 0x0100, DMI type 1, 27 bytes
System Information
        Manufacturer: HP
        Product Name: ProLiant DL360 G7
        Version: Not Specified
        Serial Number: USE000A11M
        UUID: 30000000-3000-5000-4000-300000000000
        Wake-up Type: Power Switch
        SKU Number: 579237-B21
        Family: ProLiant

Handle 0x2000, DMI type 32, 11 bytes
System Boot Information
        Status: No errors detected