HP-UX Interview Questions and Answers- Basic and Advanced
For more questions and answers and practical examples of HP-UX activities please refer to
https://unixtalksandfun.blogspot.in
New posts on the above for HP-UX LVM Cheat Sheet and Kernel configuration backups
New posts on the above for HP-UX LVM Cheat Sheet and Kernel configuration backups
-
How to see without use of Glance the top 20 Processes in sorted order of CPU Utilization?
Answer: Use the command
UNIX95= ps -e -o "user,pcpu,cpu,args,comm" |sort -rn -k2 |head -n 20
-
How to see without use of Glance the top 20 Processes in sorted order of Memory Utilization?
Answer: Use the command
UNIX95= ps -ef -o "user,vsz,pid,args,comm" | sort -rn –k2 | head -n 20
-
How to see the Size of a disk or a LUN in HPUX?
Answer: Command diskinfo can be used for the same with the RAW device special file of the Disk device to see the size of the disk /LUN as shown below.
#diskinfo –b /dev/rdsk/cXtYdZ – Shows Size in KB
#diskinfo –b /dev/rdisk/disk14 | awk ‘{print $1/1024/1024}’ – Shows Disk Size in GB
-
How to Mirror the root disk on Integrity Itanium Platform?
Answer:
#ioscan – to scan the new disk say new disk is /dev/rdsk/c0t0d0
#diskinfo –b /dev/rdsk/c0t0d0 | awk ‘{print $1/1024/1024}’ – shows the new disk size in GB
The new disk should be equal to or greater than in Size than existing root disk that is to be mirrored. The existing root disk is say /dev/dsk/c1t1td1
See the sizes of the 3 partitions on the existing disk c1t1d1 in MB
#diskinfo –b /dev/rdsk/ct1t1d1s1 | awk ‘{print $1/1024}’
#diskinfo –b /dev/rdsk/ct1t1d1s2 | awk ‘{print $1/1024}’
#diskinfo –b /dev/rdsk/ct1t1d1s3 | awk ‘{print $1/1024}’
Let s1 size be 400MB and s3 Size be 500MB
Create the /tmp/pdf file like this
3
EFI 400MB
HPUX 100%
HPSP 500MB
Write the partition information to the new disk
#idisk –wf /tmp/pdf /dev/rdsk/c0t0d0 – to create the partitions on the new disk
#insf –e –H< hardware_path_of_new_disk> : install DSF for the new partitions
#ioscan –H< hardware_path_of_new_disk> -- confirm that all the 3 partitions are created as /dev/[r]dsk/c1t1d1s1(EFI), /dev/[r]dsk/c1t1d1s2 (HPUX), /dev/[r]dsk/c1t1d1s3 (HPSP)
#mkboot –e –l /dev/rdsk/c1t1td1 : This formats the EFI partition and populates with the EFI Utilities on it
Create a temp file called /tmp/auto with the contents in a single line such that
#cat /tmp/auto – shows “boot vmunix –lq”
Put the /tmp/auto file to new disk in EFI partition
#efi_cp –d /dev/rdsk/c1t1d1s1 /tmp/auto /efi/hpux/auto
Pvcreate on the S2 to assign that as bootable LVM PV
#pvcreate –B /dev/rdsk/c1t1d1s2
Extend the root VG to include the /dev/dsk/c1t1d1s2
#vgextend /dev/vg00 /dev/dsk/c1t1d1s2
Mirror all the LVs on existing root disk to the new disk s2 partition
#for i in 0 1 2 3 4 5 6 7 8 9
>do
>lvextend –m 1 $i /dev/dsk/c1t1d1s2
>done
Edit the /stand/bootconf file to include the definition of new Boot LV: append a line like below to the file and save and exit
“l /dev/dsk/c1t1d1s2”
The above statement has first character as small L and not number 1 (one)
Update the LVM Boot information
#lvlnboot –vR
Confirm the LVM boot information is updated
#lvlnboot –v
Confirm that there are no stale extents in the rootvg
#for i in 1 2 3 4 5 6 7 8 9
>do
>lvdisplay –v $i | grep –I stale | wc –l
>done
All Reading should be zero.
-
How to boot an Integrity System to Single user mode
Answer:
At the time of reboot of the server, attach to the console of the server and go to EFI Menu. Enter the choice EFI built in shell to go to EFI shell.
From the EFI Shell type the command'
EFI Shell> fs0:
Fs0:> cd /efi/hpux
Fs0:> hpux
Interrupt autoboot here by pressing any key and you will come to HPUX> Prompt
From HPUX prompt give the below command
HPUX> boot vmunix –is
-
How to boot an Integrity System to LVM Maintenance Mode?
Answer:
The approach is the same as booting in Single user mode but the option instead “-is” would be “-lm”
-
How to make syslog send logs to a remote syslog server?
Answer:
The syslog configuration file in HPUX is /etc/syslog.conf and has the keywords and values separated by a< TAB> space. To see the TAB spaces do cat –t /etc/syslog.conf
To enable a system to send all system related logs by syslog to a remote server whose IP is A.B.C.D edit the /etc/syslog.conf to put an entry like this
*.* @A.B.C.D
Please note that there is a TAB between *.* and @A.B.C.D
After this restart syslog or refresh syslogd.
Restart of syslogd is done using /sbin/init.d/syslog stop; /sbin/init.d/syslog start
Refresh of syslogd is done using kill –HUP `cat /var/run/syslog.pid`
-
How can you test if the Syslog is logging messages to /var/adm/syslog/syslog.log?
Answer: This can be tested using sending a small logger message to syslogd using the command shown as below.
#logger –t hi hello
Logger sends a message to syslogd and if syslog is working properly a line should get added to /var/adm/syslog/syslog.log as showing “hi: hello”
-
If PRM is enabled and configured, how to display in PS command which PSET group a process belongs to?
This can be seen using the option –z of the ps command, which with other things being displayed would also show the PSET (processor SET) group in which the process is executing.
# ps -fzu haydes
UID PSET PID PPID C STIME TTY TIME COMMAND
haydes 0 20320 1 220 19:28:33 ? 6:23 itDB
haydes 1 20321 1 255 19:28:33 ? 6:45
quarryDB haydes 0 20319 1 0 19:28:33 ? 0:05 comp-it3
haydes 1 20323 1 255 19:28:33 ? 6:43 rdr_quarry
-
How to start a process in a particular PRM group and how to make the process move to a different PRM group?
A user can start his process or move his started process to a PRM group to which he belongs to as per the PRM configuration file.
If the user has an access to a PRM group, he can start his process in that PRM group using the command prmrun as shown
$prmrun –g< PRM_Group> <Application name>< Application Options>
If he is a member of the other PRM group, then he can also move his running or started process to another PRM group with prmmove command as below.
$prmmove –g< PRM_Group> -p <Process_ID> | -g< Process Group ID> | -u< User ID>
-
How to quickly form a WLM configuration file when a PRM configuration is already present?
The default PRM configuration file is /etc/prmconf. Once a fully configured PRM file is already present on the system, the WLM configuration file can be generated using
#wlmprmconf /etc/prmconf /etc/wlmconf
This generates the corresponding WLM configuration file as per the PRM definitions in PRM configuration file /etc/prmconf. Only to have an instantly usable WLM configuration file, the /etc/prmconf needs to be got rid of PRM_SYS group before running the conversion using wlmprmconf.
-
How do you differentiate the files /etc/lvmtab and /etc/lvmtab_p? And how to read lvmtab files?
Answer:
/etc/lvmtab and /etc/lvmtab_p in HP-UX are binary files and they can be read using the strings command like
strings /etc/lvmtab
strings /etc/lvmtab_p
the above show the Volume groups by name and the member PVs (physical volumes) of that VG.
While /etc/lvmtab keeps the entries for VG version 1.0 Volume Groups, /etc/lvmtab_p contains the entries for Version 2.x Volume Groups. Version 2.X volume groups had been introduced in HP-UX 11.31 that is 11iv3.
-
Question: Which are the RAID Levels supported by LVM?
Answer: LVM makes use of software RAIDs, RAID levels supported are
RAID 0 (Striping) | lvcreate using -I and -i options
RAID 1 (Mirroring) | lvcreate or lvextend using -m options
RAID 10 (Distributed Extent Based Striping) | using lvcreate /lvextend with -D y -s g and with use of /etc/lvmpvg
RAID 01 (Mirror of Stripes) | Using lvcreate -m with -I and -i options ( 0n 11.23 this requires the presence of the 16TB LV + Stripe mirror patch )
Creation of RAID 01 on HP-UX which requires the above said patch on HP-UX 11iv2 and is supported by Default on HP-UX 11iv3 with the new generation mass storage stack is as follows.
lvcreate -m 1 -I <Stripe_UNIT_Size> -i <number_of_stripes> -L <LV_SIZE_in_MB> /dev/<VG_Name>
-
Question: What are the Commands to configure RAID 1 in LVM?
lvcreate -m 1 -n <LV_name> -L <LV Size in MB> <VG _Name> [ PV_names ]
If there is an existing LV which you need to mirror then you can use the LVEXTEND Command as follows
lvextend -m 1 /dev/<VG_NAME>/<LV_NAME> [PV_NAME]
If you specify the PV name, the mirrored extents will go to the specified PV or the VG will choose the Best PV as per the Strict policy of the existing LV.
-
Question: What are the various types of strict mirroring in HP-UX?
Answer: There are 2 types of strict mirroring in HP-UX LVM which are PV Strict mirroring and the PVG Strict mirroring.
PV Strict mirroring is specified using the -s y flag of lvcreate and lvextend.
PVG Strict mirroring requires the -D y -s g options and also uses the /etc/lvmpvg definitions.
-
Question: What is the LVMPVG files used for? How is this used for Extent based Striping and mirroring? What is DEBS (Distributed Extent Based Striping)
Answer: LVMPVG file /etc/lvmpvg is a text file which can be created anytime on a system and specifies that for a given VG which are the PVs which are part of the Physical Volume groups.
A sample /etc/lvmpvg can be like this.
/etc/lvmpvg
VG /dev/vg01
PVG pvg01
/dev/dsk/c0t0d0
/dev/dsk/c0t0d1
PVG pvg02
/dev/dsk/c1t0d0
/dev/dsk/c1t0d0
The above file shows that the pvg0 in the VG vg01 come from controller c0 whereas the PVG pvg02 comes from the disks at the controller c1.
We will create an LV using the pvg01 disks and then will mirror the same with the disks in the PVG pvg02. The below is also known as distributed extent based striping.
lvcreate -n my_lvol -L 5000 -D y -s g -g pvg01 /dev/vg01
The above creates an LV of size 5000MB with name my_lvol in the VG vg01 and in the PVG pvg01 which means the disks /dev/vg01/c0t0d0 and /dev/vg01/c0t0d1 with the (-D y) which is the Round Robin distribution of the accross the PVs in the PVG pvg01. Also -s g tells LVM that the LV has mirroring policy as PVG-Strict.
In the next step we mirror the LV
lvextend -m 1 /dev/vg01/my_lvol -g pvg01 /dev/vg01
Which creates the mirror of the LV to the disks in pvg01 that is the mirror goes to the disks /dev/dsk/c1t0d0 and /dev/dsk/c1t0d1 because of the PVG-strict policy which ensures that the mirrors of the PEs cannot remain in the same PVG.
The above is also called Distributed extent based striping and mirror which is an example of RAID 10. Also in case of DEBS the Stripe size as evident is equal to the size of the Physical extent.
-
Question: How to create a striped LV on HP-UX?
Answer: The creation of striped LV can be done as below.
lvcreate -L <LV_SIZE_IN_MB> -I <Stripe_UNIT_SIZE> -i <number_of_stripes> -n <LV_NAME> /dev/<VG_NAME>
-
Question : How to create a spanned Logical Volume?
Answer: The Spanned logical volume gets the Physical Extents from the multiple PVs in a VG. This can also be called to be similar as implementation of the Concatenated volume.
The creation can be done as follows.
lvcreate -n my_spanned_lv /dev/vg01
This creates an LV of 0 size in the VG vg01 with the LV Name as my_spanned_lv.
Extend this LV to the disks of the VGs as shown.
Assuming that the VG contains three PVs as /dev/dsk/c6t0d0 /dev/dsk/c6t0d1 and /dev/dsk/c6t0d2 and I want 333 MB coming from each disk, we can do the following.
lvextend -L 333 /dev/vg01/my_spanned_lv /dev/dsk/c6t0d0
lvextend -L 333 /dev/vg01/my_spanned_lv /dev/dsk/c6t0d1
lvextend -L 333 /dev/vg01/my_spanned_lv /dev/dsk/c6t0d2
-
Question: How does LVM decide which disk (PV) to use to allocate extents of the LVs being created when no specific PVs are specified.
Answer: When a VG is created, the PV instances get an order or sequence number in the order the PVs are added to the VG. This sequence number is known to the LVM for each VG. So in a VG when an LV is created or extended without any specific device reservations, the order in which the Physical extents are allocated is the same as the sequence number as kept by LVM for the VG.
The extent start getting allocated from the first PV first. When the free PEs on the first PV are exhausted that goes to the second PV and so on.
In case you have made an LV as PV strict that will mean that the PEs which are mirrored for that LVs will strictly reside in the different PVs and LVM ensures to maintain that.
So if you are creating the LV, the first sequenced PVs is used to create the LV. Then when the mirror is created, the extents come from the next PV even if PV1 has free PEs. This happens as a combined result of the PV strict mirror policy and the Sequence of the PVs (the order in which the PVs had been added to the VG) information which LVM maintains and for the fact that there has been no device reservation specified either for the original PEs of the LV or for the mirror PEs forthe original PEs.
-
How to identify if a Logical Volume is mirrored or not?
You can you lvdisplay command for the LV like
lvdisplay <LV_Name>
See for Mirror Copies value, if it is 1 : this is a 1 way mirror if 0 the LV is not mirrored.
For a 1 way mirrored LV, the value of the Physical extents is just twice the number of the Logical Extents as each LE maps to 2 PEs which are in mirror relation.
In case there is no mirror for the LV you can see the counts of PE and LE to be equal meaning that 1 LE corresponds to 1 and only 1 PE.
How to check if the mirroring has an issue? How to check the health of an LV which has mirror?
In case there are issues with the mirroring you can see the Stale PEs on the LV.
To see this you can use
lvdisplay -v <LV_Name> | grep -i stale
If mirror copies in lvdisplay is 1 and there are no stale extents you are good, your 1 way mirror is healthy.
How to break the mirror and change root disk?
Breaking mirror.
Need to make sure first that we know which mirror to break.
I have root disks mirrored in which /dev/dsk/c0t0d0 is mirrored to the disk /dev/dsk/c1t1d1 and I want to replace the disk /dev/dsk/c1t1td1 by the disk /dev/dsk/c2t2d2 which is a free disk ann not being used and is same or bigger in size than /dev/dsk/c1t1d1
To remove the Mirror Extents from the disk /dev/dsk/c1t1d1,
for i in /dev/vg00/lv*
do
lvreduce -m 0 $i /dev/dsk/c1t1d1
done
lvlnboot -vR : update the LVLNBOOT information.
vgreduce /dev/vg00 /dev/dsk/c1t1d1
The above removes the disk from the VG roovg vg00
Add the new disk and mirror the LVs to the new disk.
The below is for a PA-RISC system, for Itanium Systems there is an EFI partition to be present on the root disk and the process is slightly different.
ioscan -fnC disk
diskinfo -b /dev/rdsk/c2t2d2 : verify the size of the new disk to which mirroring will go.
pvcreate -B /dev/rdsk/c2t2d2
mkboot -l /dev/rdsk/c2t2d2
mkboot -a "hpux -lq" /dev/rdsk/c2t2d2
vgextend /dev/vg00 /dev/dsk/c2t2d2
for i in /dev/vg00/lv*
do
lvextend -m 1 $i /dev/dsk/c2t2d2
done
The above may take substantial time.
Once the mirror completes update the lvlnboot and /stand/bootconf
lvlnboot -vR
Edit the line pertaining to older /dev/dsk/c1t1d1 and replace that with /dev/dsk/c2t2d2
How to see the default route in HP-UX? How to add default route in HP-UX ?
You can make the use of the command netstat -rn and look out for the line having "default" and the Routing Flags as UG.
To add the default route you can do as below.
Assuming that the LAN interfaces are configured with IP address and the Subnet mask as suggested by the Network team as per the design of network at your place ..
To add the Route temporarily you can
1) First ping the gateway ( I assume the default GW to be set is 10.1.1.1)
ping 10.1.1.1
2) If the ping is successful ( Assuming that ICMP is not blocked from your server to the router interface) you can perform below to add the default route (gateway) temporarily.
route add net default 10.1.1.1 1
The last 1 is called the metric and is 1 for immediately connected route of the network.
To add the default gateway permanently you can make use of SAM and also that of set_parms where in you can configure the network parameters for your system.
How to see all the LAN interfaces in HP-UX? How to see MAC addresses of all the LAN interfaces?
To see all the LAN interfaces in HP-UX inclusive of all those are configured as well as those which are not configured use the commands as below.
ioscan -fnC lan
or
ioscan -kfnC lan
lanscan
lanscan will show the MAC addresses for all the interfaces also.
How to take OS backup? How to take Ignite backups of the HP-UX system on to a Tape drive?
First identify if your system has a tape drive in place.
ioscan -fnC tape
or
ioscan -kfnC tape
Say the tape device is /dev/rmt/0m and has the no-rewind device file for the same tape as /dev/rmt/0mn
To make the Tape archive of the system use the no rewind device that is /dev/rmt/0mn.
Load the tape media in the tape device.
Confirm that the media is loaded and in case needed rewind the tape to the home position.
mt -t /dev/rmt/0mn status
To rewind to the original tape home position you can do
mt -t /dev/rmt/0mn rewind
or
in short
mt -t /dev/rmt/0mn rew
Confirm the tape is positioned
mt -t /dev/rmt/0mn status
To make a Tape archive backup you can use the command as
make_tape_recovery -Av
This automatically takes backup to the default tape drive configured on the system.
make_tape_recovery -v -a /dev/rmt/0mn -x include_entire=vg00 -x exclude=/var/adm/crash
The above command takes backup of the system into tape drive /dev/rmt/0mn and includes entire VG vg00 (which is included in Ignite backup by default) in -v (verbose mode) and excludes the Directory /var/adm/crash.
To include the other VGs apart from the rootvg vg00, the command becomes like this.
make_tape_recovery -v -a /dev/rmt/0mn -x inc_entire=vg00 -x inc_entire=vg02 -x exclude=/var/adm/crash
The above command additionally takes the vg02 data also in the Ignite tape backup.
How to take the network Ignite-UX image backup for a system? How to take make_net_recovery backup?
Assuming that you have an Ignite-UX server in your environment, you can use the make_net_recovery command.
Some of the invocations of make_net_recovery are as below.
These commands are executed from the HP-UX server which is a client to the Ignite-UX server.
make_net_recovery -v -s <Ignite-UX_server_name> -x inc_entire=vg00
The above takes a verbose mode Ignite-UX make_net_recovery backup to the Ignite sever. It os noteworthy that by default the make_net_recovery archive of the client is put at the /var/opt/ignite/recovery/archives/<hostname> directory on the Ignite-UX server, where <hostname> is the client name for which you are making an archive in make_net_recovery format.
The above also updates the client information for the recent backup being taken for the client on the clients folder of the Ignite-UX server, the location on the Ignite-UX server being /var/opt/ignite/clients/<hostname>. Where hostname is the name of the client which you are creating a network make_net_recovery archive for.
make_net_recovery -v -s <Ignite-UX_server> -a <Archive_server>:<Archive_location> -x inc_entire=vg00 -x exclude=/var/adm/crash
In the above case my Ignite-UX server is different from the Network archive server and I want to exclude /var/adm/crash of the client from being backed up.
To be noted that the Ignite-UX backup takes help of NFS in the background where the Ignite-UX server and the archive server (in case in your environment the Ignite-UX and the archive servers are different) work as NFS server and the client is an NFS client.
This mandates that the folders /var/opt/ignite/recovery/archives and /var/opt/ignite/clients are NFS exported for read/write and access from the client which is being backed up.
To be more specific you can give access to the Ignite-UX clients in a more restrictive manner by exporting the individual /var/opt/ignite/recovery/archives/<hostname> and /var/opt/ignite/clients/<hostname> to the specific client (hostname which is being backed up using make_net_recovery) something like below.
/etc/exports on Ignite-UX server
/var/opt/ignite/clients/host1 -anon=2,access=host1.example.com:host1
/var/opt/ignite/recovery/archives/host1 -anon=2,access=host1.example.com:host1
Please note that if FQDN is used in your environment use of the FQDN as above helps to overcome some permission denied error messages.
-anon=2 above means that during the backup the userid "bin" is being used for NFS mounts to mount and write to the /var/opt/ignite/clients/<hostname> and /var/opt/ignite/recovery/archives/<hostname>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Question
How to take a backup of HP-UX Kernel before patching or modifying the kernel parameters
Answer:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Question
How to take a backup of HP-UX Kernel before patching or modifying the kernel parameters
There are situations wherein at the time of applying the patches, or making tunable changes the kernel parameters we need to have a roll back plan to revert to the older kernel in case things go wrong.
The backup of a the existing running kernel helps in there. Depending on the fact that the system is a pre 11.23 (like 11.00 11.11) or post 11.23 inclusive of 11.23 like 11.23 and 11.31 here is how you can take a backup copy of the existing kernel.
For 11.11, 11.00 etc.
------------------------
cd /stand/build
/usr/lbin/sysadm/system_prep -s system
The above reads the current system and prepares a system file in /stand/build
Once the system file is created , create a kernel out of that (the new system file and kernel will be placed in /stand/build to avoid the confusions)
/usr/sbin/mk_kernel -s system
This creates the kernel vmunix_test
For 11.23 as well as 11.31
===================
kconfig -e /stand/system.test
This exports the configuration of the current running kernel.
Import the same, to be noted that the import creates the a new kernel with the configuration which you have exported. That is the kernel as per the current running configuration which you can use to boot from in case you need to roll back.
Importing the exported config
kconfig -i hpux_test /stand/system.test
Question
How to hold the kernel changes till the next reboot || How to find which changes are held for the next reboot and How to UNDO the changes held till the next reboot?
Question
How to hold the kernel changes till the next reboot || How to find which changes are held for the next reboot and How to UNDO the changes held till the next reboot?
Answer:
There are certain kernel parameters which can be are dynamic and can be done immediately. But in case you need to make the changes which will be effective only after the next reboot, you can make use of the -h option of kctune or kconfig.
-h option of kctune as well as kconfig help you make the changes but helps you hold them from being effective until next reboot.
If you want to see which are the changes which are held for the next reboot, you can make help of the option -d of kctune which shows the changes which are deferred. kconfig -d effectively calls the below commands
kctune -D
kcmodule -D
Where kctune -D shows the kernel config changes pending till next reboot and
kcmodule -D shows the pending module changes until the next reboot
In case you change your mind after making the changes and do not want that the kernel parameters or the configuration held for the next reboot apply at the reboot, you can get rid of the pending changes.
To do so you can use
kconfig -H
This cleans up the pending changes to be applied at the next reboot.