Remove special (device) files in HP-UX

You can use the command rmsf to remove special (device) files in HP-UX, example:
# rmsf -H 6/0/8/1/0.0.0

Where 6/0/8/1/0.0.0 is the HW PATH of the device.

, ,

No Comments

Remove files with odd name

Sometimes an user create a file or directory with a odd filename, for example:
server@root:/root # touch /tmp/test/^Easasasasa.txt

This “^E” is the result of a CTRL+E. With “ls”, we have the following:
server@root:/tmp/test # ls -ltr
total 0
-rw-r----- 1 root sys 0 Nov 30 15:34 asasasasa.txt

Note that you cannot see the ^E in filename, so the system will not recognize it as “asasasasa.txt”:
server@root:/tmp/test # rm asasasasa.txt
rm: asasasasa.txt non-existent

The solution is work with the file’s inode:
server@root:/tmp/test # ls -lia
total 96
11 -rw-r----- 1 root sys 0 Nov 30 15:34 asasasasa.txt
5 drwxr-x--- 2 root sys 96 Nov 30 15:34 .
2 drwxrwxrwt 8 root root 49152 Nov 30 15:33 ..

The number “11” is the inode of the odd file. Now we can remove it using the find command:
server@root:/tmp/test # find . -inum 11
./asasasasa.txt
server@root:/tmp/test # find . -inum 11 -exec rm -rf {} \;

, , ,

No Comments

Identify PV device in HP-UX 11.31

In HP-UX 11.31, LVM doesn’t use “ctd’ (ie: /dev/rdsk/c2t1d0), but DSF to balance the throughput between many device paths., so if you need identify what physical device represent that logical device, you can use ioscan, for example:

server@root:/root # vgdisplay -v vg00
--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      12
Open LV                     12
Max PV                      16
Cur PV                      1
Act PV                      1
Max PE per PV               4385
VGDA                        2
PE Size (Mbytes)            16
Total PE                    4375
Alloc PE                    3998
Free PE                     377
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0
VG Version                  1.0
VG Max Size                 1122560m
VG Max Extents              70160


--- Logical volumes ---
LV Name                     /dev/vg00/lvol1
LV Status                   available/syncd
LV Size (Mbytes)            2000
Current LE                  125
Allocated PE                125
Used PV                     1


LV Name                     /dev/vg00/lvol2
LV Status                   available/syncd
LV Size (Mbytes)            16384
Current LE                  1024
Allocated PE                1024
Used PV                     1

(...)

LV Name                     /dev/vg00/lvol12
LV Status                   available/syncd
LV Size (Mbytes)            5120
Current LE                  320
Allocated PE                320
Used PV                     1

--- Physical volumes ---
PV Name                     /dev/disk/disk4
PV Status                   available
Total PE                    4375
Free PE                     377
Autoswitch                  On
Proactive Polling           On

Note that the pv name is “disk4”, not c2t1d3.

With ioscan you can reverse map it:

server@root:/root # ioscan -m dsf
Persistent DSF           Legacy DSF(s)
========================================
/dev/rdisk/disk3         /dev/rdsk/c2t1d0
/dev/rdisk/disk4         /dev/rdsk/c2t0d0
/dev/rdisk/disk5         /dev/rdsk/c0t0d0

Now we know that the “disk4″ is the physical disk located in 12/0/1/1/0.0.0

root@brux0044:/root # ioscan -fnC disk
Class I H/W Path Driver S/W State H/W Type Description
========================================================================
disk 1298 12/0/1/1/0.0.0 sdisk CLAIMED DEVICE HP 73.4GMAP3735NC
                         /dev/dsk/c2t0d0 /dev/rdsk/c2t0d0

, , ,

No Comments

Solaris HBA information

On a Solaris system, you can use the command fcinfo to get HBA related information:


# fcinfo hba-port
HBA Port WWN: 210000144fe71480
    OS Device Name: /dev/cfg/c1
    Manufacturer: QLogic Corp.
    Model: 2200
    Type: L-port
    State: online
    Supported Speeds: 1Gb
    Current Speed: 1Gb
    Node WWN: 200000144fe71480
HBA Port WWN: 10000000c950c6a2
    OS Device Name: /dev/cfg/c5
    Manufacturer: Emulex
    Model: LP10000-S
    Type: N-port
    State: online
    Supported Speeds: 1Gb 2Gb
    Current Speed: 2Gb
    Node WWN: 20000000c950c6a2
HBA Port WWN: 10000000c950c6b7
    OS Device Name: /dev/cfg/c4
    Manufacturer: Emulex
    Model: LP10000-S
    Type: N-port
    State: online
    Supported Speeds: 1Gb 2Gb
    Current Speed: 2Gb
    Node WWN: 20000000c950c6b7

In the example above, you can see that the server has three HBAs (one QLogic and two Emulex).

, , ,

No Comments

Memory disposition in HP-UX

You can use the following commando to check me memory disposition in HP-UX:
echo "selclass qualifier memory;info;wait;infolog" | /usr/sbin/cstm

It will return something like this:

Memory Board Inventory

DIMM Slot Size (MB)
--------- ---------
0a        256
2a        1024
1a        256
0b        256
2b        1024
1b        256
--------- ---------
System Total (MB): 3072

No Comments

Create *.db files for sendmail

You can use the following command to create a *.db file to be used, for example, in sendmail:

makemap btree /etc/userdb.db < /etc/userdb

It will create a userdb.db based in the userdb file

, ,

No Comments

Recovery files from a IGNITE HP-UX backup

If you have a backup made using the ignite tool on a HP-UX, you can use the following commands to recovery just a part of it.

For PA-RISC:
-Rewind the tape
mt -t /dev/rmt/0mn rew

-Forward to the sector after the boot
mt -t /dev/rmt/0mn fsf 1

-Use tar to extract the file
tar xvf /dev/rmt/0mn etc/hosts

For Itanium2:
-Rewind the tape
mt -t /dev/rmt/0mn rew

-Forward to the sector after the boot
mt -t /dev/rmt/0mn fsf 22

-Use tar to extract the file
tar xvf /dev/rmt/0mn etc/hosts

NOTE: change “/dev/rmt/0mn” to your tape device. If you don’t know what it is, run the command “ioscan -fnC tape” do find it out.

, ,

No Comments

Convert a text to/from UPPER to/from lower

You can use the following command do convert a file content from upper case do lower case:

cat /tmp/upper_file.txt |tr '[:upper:]' '[:lower:]' > /tmp/lower_file.txt

Or the following command to convert from lower to upper case:

cat /tmp/lower_file.txt |tr '[:lower:]' '[:upper:]' > /tmp/upper_file.txt

, , ,

No Comments

Removing password aging restrictions in HP-UX

To remove all passwords aging restriction in HP-UX, you can use the following command:
/usr/lbin/modprpw -m llog=0,mintm=0,exptm=0,lftm=0,expwarn=0,umaxlntr=0 username

Where:
llog – Set the last login time interval (days);
mintm – Set the minimum time interval between password changes (days). 0 = none;
exptm – Set password expiration time interval (days). 0 = not expired;
lftm – Set password life time interval (days).  0 = infinite;
expwarn – Set password expiration time interval (days). 0 = not expired;
umaxlntr – Set Maximum Unsuccessful Login tries allowed. 0 = infinite.

, ,

No Comments

How to check HBA card settings in HP-UX

First of all, you need if the device exists:

myserver@root:/root # ioscan -fnC fc
Class     I  H/W Path    Driver S/W State   H/W Type     Description
===================================================================
fc        1  0/0/4/1/0   fcd  CLAIMED     INTERFACE    HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
                        /dev/fcd1
fc        2  0/0/10/1/0  fcd  CLAIMED     INTERFACE    HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
                        /dev/fcd2
fc        3  0/0/12/1/0  fcd  CLAIMED     INTERFACE    HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
                        /dev/fcd3
fc        0  0/0/13/1/0  fcd  CLAIMED     INTERFACE    HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
                        /dev/fcd0

Now, you can check the settings:
myserver@root:/root # fcmsutil /dev/fcd1

                           Vendor ID is = 0x001077
                           Device ID is = 0x002422
            PCI Sub-system Vendor ID is = 0x00103c
                   PCI Sub-system ID is = 0x0012d6

                               PCI Mode = PCI-X 133 MHz
                       ISP Code version = 4.0.22
                       ISP Chip version = 3
                               Topology = PTTOPT_FABRIC
                             Link Speed = 4Gb
                     Local N_Port_id is = 0x020300
                  Previous N_Port_id is = None
            N_Port Node World Wide Name = 0x5001438002fdf7c3
            N_Port Port World Wide Name = 0x5001438002fdf7c2
            Switch Port World Wide Name = 0x200300051e365dca
            Switch Node World Wide Name = 0x100000051e365dca
                           Driver state = ONLINE
                       Hardware Path is = 0/0/4/1/0
                     Maximum Frame Size = 2048
         Driver-Firmware Dump Available = NO
         Driver-Firmware Dump Timestamp = N/A
                         Driver Version = @(#) libfcd.a HP Fibre Channel ISP 23xx & 24xx Driver B.11.23.06 /ux/core/isu/FCD/kern/src/common/wsio/fcd_init.c:Jun 23 2006,14:06:46

, , ,

No Comments

How to remove/move/copy/rename file that has a non-printable name

How to remove/move/copy/rename file that has a non-printable name, for example:

backup@root:/home/userhome/test # ls -la
total 2
-rw-rw-rw- 1 root sys 0 Sep 23 15:48
drwxrwxrwx 2 root sys 96 Sep 23 15:50 .
drwxr-xr-x 5 userhome adm 1024 Sep 23 16:20 ..
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 -test

The easiest one is the file named "-test", you can do a "mv -- -test xx" to rename it to test, getting rid of the "-".

The most annoying is the other file, which apparently has the name "blank", but not quite.

There are two ways to find the real file name.,"ls -lq" e "ls -lb":

backup@root:/home/userhome/test # ls -lq
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 ?
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -lb
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 \002
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -li
total 0
17334 -rw-rw-rw- 1 root sys 0 Sep 23 15:48
17332 -rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx

The "ls -lb" shows the non-printable characters with "\ XXX" where XXX is the ASCII representation of the non-printable character.
The "ls -lq" shows the non-printable characters with "???" (quantity of ? is defined by the amount of non-printable caracters).
The "ls -li" shows the file inode.

To handle this file, the best option is to use the "find".

- Using the find based on the inode:
find . -inum 17334 -exec mv {} asd \;

- Using find with "wildcards" (based on the ls-lq returned):
find . -type f -name "?" -exec mv {} asd \;

Be careful when using the find with "meta character"! If a file whose name has only one character, it will enter the result.
 

, ,

No Comments

Change user settings and password attributes in AIX

To change some user and password settings in AIX, you should use the command "chuser". Follow some available parameters:

- loginretries -> number of login failures before lock the account.
- maxage -> maximum age of a password (in weeks)
- gecos -> general information about the user.
- groups
- home
- minlen -> minimum password length
- pgrp -> primary group

Example:
# chuser loginretries='0' maxage='0' gecos='User Foo Bar' groups='group1,group2,group3' home='/home/foobar' minlen='7' pgrp='groupX' <username>

 

, ,

No Comments

Unlock user account in AIX

To unlock an user account in AIX, you should use the following command:

# chuser account_locked='false' <username>

,

2 Comments

Lock user account in AIX

To lock an user account in AIX, you should use the following command:

# chuser account_locked='true' <username>

,

2 Comments

Increase lvol size in HP-UX

Let’s assume that you want to increase 1Gb of the /dev/MyVG /lvol1 device (mounted as /filesystem):
# bdf /filesystem
Filesystem          kbytes    used   avail %used Mounted on
/dev/ MyVG /lvol1
                   573440000 533892407 37080557   94% /filesystem

The actual size is 573440000 Kb (573 Gb) and you will increase it to 574440000 Kb (574 Gb).

- Check if there is available space in the Volume Group:
# vgdisplay MyVG
--- Volume groups ---
VG Name                     /dev/MyVG
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      1
Open LV                     1
Max PV                      100
Cur PV                      17
Act PV                      17
Max PE per PV               15000
VGDA                        34
PE Size (Mbytes)            16
Total PE                    36907
Alloc PE                    35000
Free PE                     1907
Total PVG                   1
Total Spare PVs             0
Total Spare PVs in use      0

Note the “Free PE” and “PE Size (Mbytes)”. It say that you has 30512 Mb (30Gb) available in MyVG (Free PE * PE Size).

- Increase the lvol:
# lvextend -L 574440 /dev/MyVG/lvol1
* the syntax is: lvexten -L <new size in Mb> <lvol path>

- Now, increase the filesystem:
# fsadm -b 574440m /filesystem
* the syntax is: fsadm –b <new size in Mb> <mount point>
 

, , , ,

No Comments

Changing the HP-UX hostname

To change the hostname in HP-UX:

- Edit the file "/etc/rc.config.d/netconf"
# /etc/rc.config.d/netconf

- Look for the line that starts with HOSTNAME and change the hostname, example:
HOSTNAME="mylittleserver"

- Now, apply the change:
# /sbin/init.d/hostname start

,

No Comments

Rename a Super Dome Partition

To rename a Super Dome Partition (for example change the name that is showed in the MP console menu), do the following:

Login into any host of this SD and run:
parmodify -p <partition number> -P <partition name>
Example:
parmodify -p 2 -P WEBSERVER01
 

,

No Comments

Updating partition table in Linux

When you use the "fdisk" to handle the partitions of a disk, depending on the disc, the "fdisk" will bring the following message:

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

No, you do not have to restart the server for the changes are applied, simply use the following command (example):
kpartx -a /dev/sda

This will re-read the partition table on /dev/sda and create the mapping of the system partitions (/dev/sda1, /dev/sda2, etc).

, , ,

1 Comment

Physical memory in AIX

To check the amount of physical RAM that a AIX Server has, you can use the following commands:


# lsattr -El sys0 | grep realmem
realmem 16121856 Amount of usable physical memory in Kbytes


or

# lsattr -El mem0
goodsize 15744 Amount of usable physical memory in Mbytes False
size 15744 Total amount of physical memory in Mbytes False

or

# prtconf|grep "Memory Size"
Memory Size: 15744 MB Good Memory Size: 15744 MB

 

, ,

No Comments