1. Is there a "defrag" on UNIX?
For HFS filesystem:
HP-UX experts say that HFS filesystem was designed for optimum
performance. It's sort of auto-defragmenting filesystem.
But, if you still insist on defragmentation, you have some
possibilities:
| Backup entire filesystem |
| Erase all files from that filesystem |
| Restore entire filesystem (it's rather funny, but works good & requires a lot of time) |
For VxFS (JFS) filesystem:
You need to buy additional AdvancedJFS (Online JFS) product from
Hewlett-Packard. According to some people it is really worth the
money; it allows you to get the full functionality of JFS (VXFS)
- files/dirs stats, on-line backup, on-line extend/shrink file
system (make sure you install the patches !), online (background)
defrag.
If you already have this product check man page for 'fsadm'
command.
2. Starting/Stopping DTC's / DDFA in HP-UX 10
| FILE | CHANGE |
|---|---|
| /etc/rc.config.d/dtcmgr | START_DTCMGR=1 |
| /etc/rc.config.d/netdaemons | START_RBOOTD=1 |
| RBOOTD_DEVICES="/dev/lan0" | |
| DDFA=1 |
To check that the correct daemons are running when the system comes up, you can check the end of the following log files:
...which should say "INITIALIZATION COMPLETE".
The following daemons should be running when DTC's are up:
To disable DTC's, simply flag /etc/rc.config.d/dtcmgr:
...This stops them from coming up when you reboot. Simply change
it back to 1 then reboot to restart the DTC daemon.You can also
stop the daemons while the system is up (instead of booting) by
running:
3. HP-UX 10.x System Info Script
Here is a script to gather system information on HP-UX 10.x systems: dumpsys.hp10
4. Setting up routing
These are the steps for setting up routing on HP-UX.
I will give the IP address 192.9.200.2 to the router for this example.
Run the command: route add default 192.9.200.2 1 to initially add the router for all systems.
To keep this information after a reboot edit the file /etc/rc.config.d/netconf
5. Patch Cleanup From HP
There is a utility under /usr/sbin and it is called 'cleanup'. It provides the following functionality for 10.X patch management:
/usr/sbin/cleanup
Remove superseded patches from the system to reclaim space in /var. Queries the user re trimming SD logfiles as well.
/usr/sbin/cleanup -F
Forces the removal of ALL Patch backups to reclaim space in /var (you cannot back out a patch out after this).
/usr/sbin/cleanup -t
Trim SD logfiles /var/adm/sw*.log to the most recent 5 entries.
/usr/sbin/cleanup -i
Remove overwritten patch entries from the SDUX IPD.
/usr/sbin/cleanup -d [absolute path to software depot]
Removes superseded patches from a software depot.
6. Patch Frequently Asked Questions From HP
Q: Instead of following this procedure, can I use swremove(1M) to remove all patches prior to performing the software update?
A: Yes.
You can do this but it is not recommended. First of all, patches that have been applied may deal with sensitive issues like data corruption, security, and system panics. By removing the patches prior to performing the update you may be exposed to the problems addressed by the patches. It is best to leave the patches installed.
Second, removing patches with swremove(1M) can be a labor-intensive process. Not only do many systems have over a hundred patches installed, you must remember that when a patch is removed with swremove(1M), a patch that was superseded by the patch *may* be automatically reinstalled. So, several iterations of invoking swremove(1M) may be required to completely remove all patches from the system.
Q: Can I use swremove(1M) to remove the inappropriate patches after the software update process?
A: NO!
It is critical to remember that removing a patch with swremove(1M) will reinstall software that was present prior to the installation of the patch. So, removing a patch with swremove(1M) after a software update could lead to an undesired mixture of new and old software.
Let's use an example of an HP-UX 10.01 to HP-UX 10.20 update to clarify this situation. Assume you were running HP-UX 10.01 and updated to HP-UX 10.20 without following the procedure listed above.
After the update, the swlist(1M) command will show that HP-UX 10.01 patches are still installed.
What happens if these 10.01 patches are removed via swremove(1M)? The 10.01 files that were resident on the system prior to the installation of the 10.01 patches will be restored. The end result is that the HP-UX 10.20 system will now have HP-UX 10.01 files mixed with the HP-UX 10.20 files. The behavior of such a system is unknown, and most likely, a complete cold install will be required to recover the system.
Q: Can I simply remove all patch references from the IPD prior to performing the software update?
A: Not really.
The problem with this solution is that all software products might not be affected by the software update. If patches for all software are removed from the IPD and some software is not reloaded during the update process, then information will be lost about some patches that are still present after the update.
An example of where this may cause a problem is if an operating system update was performed, but some application software products were not updated. This situation arises when the same version of an application runs on multiple versions of the operating system.
If patches had been applied to these application products and the patches removed from the IPD but the products not updated, then there would be no record that the patches were installed. This could lead to problems with the application software.
7. Fbackup/Frecover
To backup use: /usr/sbin/fbackup -0v -f /dev/rmt/0m -i /
Recover command (absolute): /usr/sbin/frecover -xv -f /dev/rmt/0m -i /path[/file]
To do a relative restore using frecover you need BOTH -x and -X, ie -xvX
8. HP-UX telnet / pty users
To increase the number of telnet users a system can have, the npty kernel parameter needs to be altered. However, HP-UX requires "slave" and "master" pty devices for each telnet user. These devices are used logically as two ends of a pipe - they need to be there so HP-UX can allocate a tty device to a new telnet user.
To create the required master and slave device files, executed the command:
insf -d pty -n 120
9. HP-UX 11.x info
This is intended as a quick summary of the new features and functions incorporated into HP-UX 11.
10. Setting up a remote console
This is intended to describe the procedure for setting up a remote console for the S800.
The remote console allows Hewlett-Packard to perform remote support for your machine by enabling a remote or parallel console.
In order to configure a remote console, you will need an HP support modem that is connected on port 7 of the MUX or MDP. Alternatively, the modem can be connected to the back of the box on the Access Port.
In addition, please ensure that a 40233A cable is being used.
If you choose N, you will see the following information:
current remote support modem port configuration :
Bit rate : 9600 bits/sec
Protocol : Bell
System Identification : 'hostname'
do you wish to change configuration ? (Y/[N]) : _
Make sure that your settings accurately reflect:
the same speed as your modem (eg. 9600)
that the protocol is set to Bell
that the system name refers to the hostname of the system that you're working on
If these settings are not correct, modify them
The password option allows you to set passwords to provide additional security by prompting a user for a password prior to gaining access.
If all these fields are appropriately set, do not change the configuration.
You will now see the following message displayed :
Remote console is now enabled.
The status bar at the bottom of the screen should now indicate that remote access is enabled but still inactive:
RUN F01F REMOTE : enabled inactive multiple ACCESS FAULT : 00
Once you connect to the console via modem, it will change to ACTIVE.
11. Using HP-UX 10.20 as DCHP server for Win95 clients
How do you get the DHCP server to pass the default gateway and DNS information to its clients?
The solution is to use the sample file, located in /usr/newconfig/etc/dhcptab, copy it to /etc/dhcptab, and edit it according to your wants and needs.
12. Extending the root partition
How do I extend (enlarge) the root partition which is located on a logical volume, the problem being that you can't umount the root partition.
Here are 3 solutions to this commonly asked problem.
Solution 1:
Solution 2:
Solution 3:
Boot the system in single user mode and extend the root using the lvextend command and it will extend the root logical volume.
Make sure that the space to extend the root LV is available in the same disk as continuous physical extents because the root volume allocation poicy must be contigous.
If the adjacent physical extents are occupied by any other LV move that logical volume to some other disk using
pvmove command.
#pvmove -n /dev/vg00/lvolx /dev/dsk/c0txd0 /dev/dsk/c0txd0
Shutdown the machine and interrupt the normal boot process by pressing any key if it is a S800 system and if it is S700 use "esc" key.
From the boot admin prompt type boot pri isl you will get the isl prompt
ISL> hpux -lm
This will take you to the logical volume maintanence mode. Don't try to mount any logical volume and don't switch to multiuser mode or a different runlevel.
The root LV will now be mounted on /dev/root instead of /dev/vg00/lvolx
Now you can execute the extendfs command on the root logical volume:
# extendfs -F hfs /dev/vg00/rlvolx
Note down the alternate superblock locations and reboot the macine using
#reboot -n -------------- DONT MISS THIS STEP.
This will cause the system to not sync the old superblock back to the filesystem and damage it.
When you boot the system normally now you will get all the allocated space for the root filesystem.
Now you will notice that the root volume is still mounted on /dev/root rather than /dev/vg00/lvolx. To correct this you remove the /etc/mnttab and you will find bdf now displays the correct logical volume.
13. Retreiving data from an old root disk
Assumption:
We want the system to run with (only) the new disk, but there is data on the first disk that have to be transferred from the original.
Solution:
Breakdown:
A much simpler method is to back up the data you want saved before you replace the old disk!
14. HP Certification help
Here are some tips on studying for HP-UX Certification:
Prepare answers to the following questions:
15. IPD Contains Duplicate Definitions for Products
cleanup or cleanup -i work great if you have an IPD that is not corrupt. However you will have to do the following for a corrupt IPD:
product
tag void
fileset
tag void
16. Determine block size of logical volume
To determine the block size of a logical volume's read/write buffers run:
fstyp -v {disk/lvol}
17. Replacing a boot disk and keeping the old info
The easy way is to use Ignite/UX, but if you don't have that:
Manual procedure:
# ll /dev/*/group
crw-r----- ... 64 0x000000 Oct 8 1996 /dev/vg00/group
crw-rw-rw- ... 64 0x010000 Oct 30 1996 /dev/vg01/group
crw-r--r-- ... 64 0x020000 Oct 30 1996 /dev/vg02/group
crw-r--r-- ... 64 0x020000 Oct 30 1996 /dev/vgtest/group
the two hex digits after the "0x" are the VG number, 00,01,02 in the above listing from my system, so "03" would be the logical choice.
for f in `lifls /dev/rdsk/c0t6d0` ;
do lifcp /dev/rdsk/c0t6d0:$f /dev/rdsk/cItTd0:$f ;
done
(assuming that your current boot disk is /dev/rdsk/c0t6d0)
- mkboot -a "hpux (;0)/stand/vmunix" /dev/rdsk/cItTd0
lvcreate -l 40 -n stand -r n -C y /dev/vgboot
lvcreate -l 300 -n swap -r n -C y /dev/vgboot
lvcreate -l 48 -n root -r n -C y /dev/vgboot
(note the contiguous allocation and no BAD-block-relocate)
lvcreate -l 400 -n usr /dev/vgboot
lvcreate -l 100 -n tmp /dev/vgboot
lvcreate -l 200 -n opt /dev/vgboot
etc.....
You can take this opportunity to adjust the sizes as you wish.
newfs -F hfs /dev/vgboot/rstand
newfs -F vxfs /dev/vgboot/rroot
newfs -F vxfs /dev/vgboot/rusr
newfs -F vxfs /dev/vgboot/rtmp
etc....
Note: here, that you have the opportunity to make root and the other "system" filesystems JFS (Journaled FS), which is highly recommended. /stand must remain HFS
mkdir /tmp_mnt
mkdir /tmp_mnt/root
mkdir /tmp_mnt/usr
mkdir /tmp_mnt/tmp
...
mount /dev/vgboot/root /tmp_mnt/root
mount /dev/vgboot/usr /tmp_mnt/usr
mount /dev/vgboot/usr /tmp_mnt/tmp
...
chmod 755 /tmp_mnt/root ( or whatever
chmod 555 /tmp_mnt/usr you currently have)
*** chmod 777 /tmp_mnt/tmp
...
******************************************
NOTE : You probably will not be copying /tmp,
BUT BE SURE TO MAKE IT WORLD WRITABLE :
# chmod 777 /tmp_mnt/tmp
******************************************
vi /tmp_mnt/root/etc/fstab
/dev/vgboot/stand /stand hfs defaults 0 1
/dev/vgboot/swap ... swap pri=1 0 2
/dev/vgboot/root / vxfs rw,suid,delaylog,datainlog 0 2
/dev/vgboot/usr /usr vxfs rw,suid,delaylog,datainlog 0 2
...
18. Altering the baud rate of a serial interface
PROBLEM:
SOLUTION:
19. HP-UX Mailing List
The HP-UX mailing list can be found at:
majordomo@dutchworks.nl
Place one of the following in the body of the message:
subscribe hpux-admin email-address
subscribe hpux-admin-digest email-address
20. swinstall not finding target
swinstall needs to be able to do a reverse lookup of the hostname. If DNS is not resolving properly try to rename /etc/resolv.conf and ensure that /etc/hosts has a fully qualified domain name. If this still does not work try to restart swagentd:
# /sbin/init.d/swagentd stop
# /sbin/init.d/swagentd start
If you have had to break the install part way through you may need to remove the file in /var/adm/sw/products/swlock.
21. Using both DNS and /etc/hosts
To run both DNS and /etc/hosts you need to set up the /etc/nsswitch.conf file. The easiest way is through SAM, but it can be done by adding the line:
hosts: files [NOTFOUND=continue UNAVAIL=continue TRYAGIAN=continue] dns
to nsswitch.conf.
22. Patch install hangs
If trying to install a patch on HP-UX 10.20 and the system just hangs, check to see if MeasureWare is running.
The MeasureWare Agent often hangs the swinstall process at the Analysis stage.
First you will need to kill the swinstall.
Remember to remove the lock file: /var/adm/sw/products/swlock.
Next disable MeasureWare via "mwa stop".
You should now be able to install the patch.
Finally, restart MeasureWare with "mwa start" to restart.
You may also find that the
23. Adding new devices
When adding new devices, remember to check the kernel subsystem (using SAM) and ensure there is kernel support for the device.
24. swinstall not finding target
swinstall uses an IP lookup to determine the hostname.
For swinstall to work correctly you need to be able to do an nslookup of the IP address.
If you are using /etc/hosts, fix the problem.
If you are using DNS you can either fix the DNS entry or temporarily disable DNS by renaming /etc/resolv.conf.
After the nslookup has been resolved do an /sbin/init.d/swagentd stop/start.
25. Limiting the size of core dumps
To completely suppress core dumps:
Bourne-style shells: "ulimit -c 0"
C-style shells: "limit coredumpsize 0"
If you want to limit dumps to a specific size, specify a number instead of 0, in blocks for Bourne-style shells, or kilobytes for C-style shells.
26. Adding additional interfaces to a LAN
First you need to install patch PHNE_12492 to get a command called ifalias. Once you have that patch installed, do the following to add an additional IP:
ifalias lan0 add <ip address>
However, this doesn't stick after a reboot. There is a script to fix this posted in the HP-UX mailling list archive at:
http://www.dutchworks.nl/htbin/hpsysadmin?h=3&dn=45061&q=ifalias&fh
27. Stop logging of messages in syslog
I had a problem trying to stop ftp messages being logged to /var/adm/syslog/syslog.log. Initially I tried playing with /etc/syslog.conf but was pointed in the right direction by the list. The actual file to edit was /etc/inetd.conf. Check for a -l option. Removing the -l should stop the logging. Use inetd -c to re-read the config file.
28. Finding ports not listed in /etc/services
To find open ports that are not listed in /etc/services try using lsof to find out exactly what it is.
You can get lsof from the HP porting and archive centre at
http://hpux.cae.wisc.edu/.
Try this:
lsof -i TCP|grep ":<port number>"
...to get the image name and PID of the offending process, then just use ps to find out what the heck it is.
Here's a (real) example:
------
root@box> nmap -sT box
...
911 open tcp unknown
...
What the heck is running on port 911?
root@box> ./lsof -i TCP|grep ":911 "
SLSd_daem 1156 root 4u inet 0x02ca2900 0t0 TCP *:911 (LISTEN)
Aha! SLSd_daem, PID 1156 is listen()ing on port 911.
root@box> ps -AHo user,tty,ppid,pid,args|grep 1156
root pts/0 3065 3100 grep 1156
root ? 1 1156 /usr/bin/X11/SLSd_daemon
root@box> I know where you live, SLSd_daemon.
------
Check out the following URL for an authoritative list of port numbers
http://www.isi.edu/in-notes/iana/assignments/port-numbers
29. How to add a jetadmin printer from command line
This is simply done with the command:
/usr/hpnp/bin/addqueue -i TYPE -q QUEUE_NAME -h HOST_ADDRESS
The TYPE option comes from the list of printer types given by jetadmin but is not needed.
To remove a printer you use the related: removequeue
30. Converting /usr to vxfs
General consensus on the HP-UX list is that this will work - and several people have done it.
You can also use Ignite do achieve the same thing.
31. Wiping a hard disk
On HP-UX the best way to wipe a disk is to use: mediainit
Check the man page for details.
32. FTP: Access Denied
This is a little FTP "gotcha". If you are getting the message: FTP: Access Denied, check your /etc/shells. If there is no entry ofr a user's shell in this file they will not be able to remote login.
33. Finding the MAC address
arp -a will tell you
34. Getting rid of stale nfs file handles
Run the command:
#fuser -uck /<filesystem>
35. FTP umask setting
The ftp daemon (ftpd) uses an internal umask setting, the default being 027.
This may be changed by editing the ftpd entry int the /etc/inetd.conf file. For example to change ftpd umask to, say, 022 in /etc/inetd.conf:
ftp stream tcp nowait root /usr/lbin/ftpd ftpd -l -u 22
Restart inetd (inetd -c)
36. Copying printers between servers
To keep consistancy between servers/workstations here is a method to have all servers with the same printer config:
37. Entering username and passwd with CAPS LOCK
This gettydef allows a user to log into a unix user account with caps lock on (password must also be entered with caps lock on), and receive the password prompt as normal: "Password:", not as "\PASSWORD:".
The unix account name and password MUST be truely entered in lower case (in the /etc/passwd file) originally. The key was to eliminate OPOST output processing. This, combined with the user name and password in /etc/passwd in lowcase, and a mod to the .profile file handles it all beautifully!
UCgoofy #B38400 CS8 CLOCAL HUPCL IGNPAR ICRNL IXON OPOST ONLCR CREAD
ISIG ICANON ECHO ECHOK ISTRIP IXANY TAB3
#B38400 CS8 CLOCAL HUPCL IGNPAR BRKINT ICRNL IXON IXOFF CREAD
ISIG ICANON ECHO ECHOK TAB3
#login: # UCgoofy
In order for the user to use the system as a non-caps-locked terminal, they will have to have the following entries in their profile:
stty sane
stty opost onlcr
stty erase "^H" intr "^C"
38. Is a system in trusted mode?
How do you tell if a system is in trusted mode or not? Try looking at these two:
man iscomsec
/usr/lbin/getprdef -r
39. Mounting a filesystem in a recovery shell
You need to use loadfile and get /sbin/fs/hfs/* and /sbin/fs/vxfs/* to be able to mount filesystems in a recovery shell.
40. Clearing the /var/opt/hparray logs
I have had the situation with a Model 12 AutoRAID on a K-class running HP-UX 10.20. /var was getting a little to full for my liking and I have found that /var/opt/harray/log is taking up the most space. There are tools in /opt/bin/hparray, namely logprint and arraylog that are supposed to clear this. What I eneded up doing, however, was to delete all files in that directory and then touch LOGCATLG to recreate it. If you don't do the touch, ARMServer supposedly won't restart correctly. I did the delete and touch and had no problems.