Saturday, 2 July 2016

Rename device file for a tape drive

After the reboot or if the ioscan –fnC tape shows the below output:- 

[server1:/opt/atdd/bin]# ioscan -fnC tape
Class     I  H/W Path        Driver   S/W State   H/W Type     Description
===============================================================
tape      0  0/5/1/0.9.12.0.0.0.1  atdd     CLAIMED     DEVICE       IBM     ULTRIUM-TD2
                            /dev/rmt/0m             /dev/rmt/0mnr           /dev/rmt/c22t0d1BESTnb  /dev/rmt/s0mnb
                            /dev/rmt/0mb            /dev/rmt/c22t0d1BEST    /dev/rmt/s0m
                            /dev/rmt/0mn            /dev/rmt/c22t0d1BESTb   /dev/rmt/s0mb
                            /dev/rmt/0mnb           /dev/rmt/c22t0d1BESTn   /dev/rmt/s0mn
------------------------------------------------------------------------------------------------------------
So to change from 0mn to 1mn check with below commands:-

[server1:/opt/atdd/bin]# /opt/atdd/bin/atdd_mksf –h ---à For Help

[server1:/opt/atdd/bin]# /opt/atdd/bin/atdd_mksf –c -à The command for listing the commands for               creating the special files as shown below.

mknod /dev/rmt/atdd.dbg c 118 0xFFFFFd

mknod /dev/rmt/atdd.cfg c 118 0xFFFFFc

rm -f /dev/rmt/atdd.ctrl
mknod /dev/rmt/atdd.ctrl c 118 0xFFFFFa

mknod /dev/rmt/0m c 118 0x160100

mknod /dev/rmt/0mb c 118 0x160180

mknod /dev/rmt/0mn c 118 0x160140

mknod /dev/rmt/0mnb c 118 0x1601c0

mknod /dev/rmt/0mnr c 118 0x16014b

rm -f /dev/rmt/c22t0d1BEST
mknod /dev/rmt/c22t0d1BEST c 118 0x160100

rm -f /dev/rmt/c22t0d1BESTb
mknod /dev/rmt/c22t0d1BESTb c 118 0x160180

rm -f /dev/rmt/c22t0d1BESTn
mknod /dev/rmt/c22t0d1BESTn c 118 0x160140

rm -f /dev/rmt/c22t0d1BESTnb
mknod /dev/rmt/c22t0d1BESTnb c 118 0x1601c0


chmod 666   /dev/rmt/atdd.dbg /dev/rmt/atdd.cfg /dev/rmt/atdd.ctrl /dev/rmt/0m /dev/rmt/0mb /dev/rmt/0mn /dev/rmt/0mnb /dev/rmt/0mnr /dev/rmt/c22t0d1BEST /dev/rmt/c22t0d1BESTb /dev/rmt/c22t0d1BESTn /dev/rmt/c22t0d1BESTnb

chown bin:bin   /dev/rmt/atdd.dbg /dev/rmt/atdd.cfg /dev/rmt/atdd.ctrl /dev/rmt/0m /dev/rmt/0mb /dev/rmt/0mn /dev/rmt/0mnb /dev/rmt/0mnr /dev/rmt/c22t0d1BEST /dev/rmt/c22t0d1BESTb /dev/rmt/c22t0d1BESTn /dev/rmt/c22t0d1BESTnb

So to change from 0mn to 1mn manually create the device file for the tape drive:-

[server1]#mknod /dev/rmt/atdd.dbg c 118 0xFFFFFd

[server1]#mknod /dev/rmt/atdd.cfg c 118 0xFFFFFc

[server1]#rm -f /dev/rmt/atdd.ctrl

[server1]#mknod /dev/rmt/atdd.ctrl c 118 0xFFFFFa

[server1]#mknod /dev/rmt/1m c 118 0x160100

[server1]#mknod /dev/rmt/1mb c 118 0x160180

[server1]#mknod /dev/rmt/1mn c 118 0x160140

[server1]#mknod /dev/rmt/1mnb c 118 0x1601c0

[server1]#mknod /dev/rmt/1mnr c 118 0x16014b

[server1]#rm -f /dev/rmt/c22t0d1BEST

[server1]#mknod /dev/rmt/c22t0d1BEST c 118 0x160100

[server1]#rm -f /dev/rmt/c22t0d1BESTb

[server1]#mknod /dev/rmt/c22t0d1BESTb c 118 0x160180

[server1]#rm -f /dev/rmt/c22t0d1BESTn

[server1]#mknod /dev/rmt/c22t0d1BESTn c 118 0x160140

[server1]#rm -f /dev/rmt/c22t0d1BESTnb

[server1]#mknod /dev/rmt/c22t0d1BESTnb c 118 0x1601c0

Then Change the permission and owership of the newly created device files as mentioned below.

[server1]#chmod 666   /dev/rmt/atdd.dbg /dev/rmt/atdd.cfg /dev/rmt/atdd.ctrl /dev/rmt/1m /dev/rmt/1mb /dev/rmt/1mn /dev/rmt/1mnb /dev/rmt/1mnr /dev/rmt/c22t0d1BEST /dev/rmt/c22t0d1BESTb /dev/rmt/c22t0d1BESTn /dev/rmt/c22t0d1BESTnb

[server1]#chown bin:bin   /dev/rmt/atdd.dbg /dev/rmt/atdd.cfg /dev/rmt/atdd.ctrl /dev/rmt/1m /dev/rmt/1mb /dev/rmt/1mn /dev/rmt/1mnb /dev/rmt/1mnr /dev/rmt/c22t0d1BEST /dev/rmt/c22t0d1BESTb /dev/rmt/c22t0d1BESTn /dev/rmt/c22t0d1BESTnb

Then Check with ioscan as shown below after the changes:-

[server1:/opt/atdd/bin]# ioscan -fnC tape

Class     I  H/W Path        Driver   S/W State   H/W Type     Description
===========================================================================
tape      0  0/5/1/0.9.12.0.0.0.1  atdd     CLAIMED     DEVICE       IBM     ULTRIUM-TD2
                            /dev/rmt/1m             /dev/rmt/1mnr           /dev/rmt/c22t0d1BESTnb  /dev/rmt/s0mnb
                            /dev/rmt/1mb            /dev/rmt/c22t0d1BEST    /dev/rmt/s0m
                            /dev/rmt/1mn            /dev/rmt/c22t0d1BESTb   /dev/rmt/s0mb
                            /dev/rmt/1mnb           /dev/rmt/c22t0d1BESTn   /dev/rmt/s0mn

[server1:/root]#

Move resources between vpars

Change Description:
   
Shift 2 CPU’s from the partition in server1 to server2

1. Collect the configuration for your reference.

#server1:/#vparstatus -vp server1
[Virtual Partition Details]
Name:         server1
State:        Up
Attributes:   Dynamic,Autoboot
Kernel Path:  /stand/vmunix
Boot Opts:    -lq

[CPU Details]
Min/Max:  2/16
Bound by User [Path]:
Bound by Monitor [Path]:  0.12
                          0.13
Unbound [Path]:  1.10
                            1.11
                            1.12
                            2.10

[IO Details]
          1.0.0
                        1.0.2
                        1.0.4
                        1.0.8
                        1.0.10
                        1.0.12
                        1.0.0.2.0.6.0.0.0.0.0  BOOT
                        1.0.0.3.0.6.0, ALTBOOT

[Memory Details]
Specified [Base  /Range]:
          (bytes) (MB)
Total Memory (MB):  28288


2. server2:/#vparstatus -vp server2
[Virtual Partition Details]
Name:         server2
State:        Up
Attributes:   Dynamic,Autoboot
Kernel Path:  /stand/vmunix
Boot Opts:    -lq

[CPU Details]
Min/Max:  2/16
Bound by User [Path]:
Bound by Monitor [Path]:           0.10
                                                                        0.11
Unbound [Path]:                                                1.13
                                                                                    2.11
                                                                                    2.12
                                                                                    2.13
                                                                                    3.10
                                                                                    3.11
                                                                                    3.12
                                                                                    3.13

[IO Details]
   0.0.0
   0.0.2
   0.0.4
   0.0.6
   0.0.8
   0.0.10
   0.0.12
   0.0.14
   0.0.0.2.0.6.0.0.0.0.0  BOOT
   1.0.1
   0.0.1
   0.0.0.3.0.6.0, ALTBOOT

[Memory Details]
Specified [Base  /Range]:
          (bytes) (MB)
Total Memory (MB):  20224



***************************************************************************************************************

3. Check the vPar status:

#server1:/#vparstatus
[Virtual Partition]
                                                                                     Boot
Virtual Partition Name         State                       Attributes Kernel Path               Opts
============================== ===== ========== =========================
server2                                     Up                    Dyn,Auto   /stand/vmunix             -lq
server1                                     Up                    Dyn,Auto   /stand/vmunix             -lq

[Virtual Partition Resource Summary]
                                                                                                CPU                 Num       Memory (MB)
                                                            CPU                 Bound/                         IO                     # Ranges/
Virtual Partition Name          Min/Max                  Unbound           devs                 Total MB           Total MB
==============================  ================  ====  ====================
server2                                                 2/ 16                 2   8                  12                     0/  0                              20224
server1                                                 2/ 16                 2   4                  8                      0/  0                              28288

From the above output we see:

vpar server2 has 8 Unbound CPU's.
vpar server1 has 4 Unbound CPU's.





4. Delete 2 Unbound CPU's from vPar server1 (for moving it to vPar server2)

#vparmodify –p server1 –d cpu::2


5. Check the new configuration status of the vPar, server1 it should show 2 less Unbound CPU's. i.e it will show only 2 Unbound CPU's.


# vparstatus
[Virtual Partition]
                                                                                                Boot
Virtual Partition Name         State                       Attributes          Kernel Path               Opts
============================== ===== ========== ========================= server2                                               Up                    Dyn,Auto          /stand/vmunix             -lq
server1                                     Up                    Dyn,Auto          /stand/vmunix             -lq

[Virtual Partition Resource Summary]
                                                                                                                        CPU                 Num                    Memory (MB)
                                                                        CPU                             Bound/                         IO                                 # Ranges/
Virtual Partition Name                            Min/Max                        Unbound           devs                             Total MB    Total MB
==============================  ================  ====  ====================
server2                                                             2/ 16                             2   8                  12                                 0/  0                                20224
server1                                                             2/ 16                             2   2                   8                                 0/  0                                28288



6. View the available resources that are not assigned to any vPar.

server1:/#vparstatus -A
[Unbound CPUs (path)]: 
[Available CPUs]: 

[Available I/O devices (path)]:   

[Unbound memory (Base  /Range)]:  0x0/64
                                                (bytes) (MB)      0xc000000/448
[Available memory (MB)]:  512


7. Add 2 more Unboud CPU's to the vPar server2

#vparmodify -p server2 -m cpu::12


8. Check the new configuration status of the vPar, server2 should show 10 Unbound CPU's.

#vparstatus 
[Virtual Partition]
      
                                                                                                           
                                                                                                                                                                                                            Boot
Virtual Partition Name         State                                   Attributes          Kernel Path               Opts
============================== ===== ========== ========================= server2                                               Up                                Dyn,Auto          /stand/vmunix             -lq
server1                                     Up                                Dyn,Auto          /stand/vmunix             -lq

[Virtual Partition Resource Summary]
                                                                                                CPU                 Num        Memory (MB)
                                                            CPU                 Bound/                         IO                     # Ranges/
Virtual Partition Name          Min/Max                  Unbound           devs                 Total MB                        Total MB
==============================  ================  ====  ====================
server2                                                 2/ 16                 2   10                            12                     0/  0                                          20224
server1                                                 2/ 16                 2   2                  8                      0/  0                                          28288


All Interfaces of are down

Login to the system and execute lanscan to check the number of lan interfaces on the system


# lanscan
Hardware          Station        Crd  Hdw   Net-Interface    NM   MAC       HP-DLPI DLPI
Path                 Address      In#  State NamePPA          ID   Type      Support Mjr#
0/0/0/1/0 0x00306E28284E   0    UP    lan0 snap0       1    ETHER       Yes   119
1/0/0/1/0 0x00306E0AD090   3    UP    lan3 snap3       2    ETHER       Yes   119
1/0/10/0/0 0x00306E271FB0 4    UP    lan4 snap4       3    ETHER       Yes   119
0/0/10/0/0 0x00306E271FB9 1    UP    lan1 snap1       4    ETHER       Yes   119
0/0/12/0/0 0x00306E271FB7 2    UP    lan2 snap2       5    ETHER       Yes   119

Note the “Hdw State” (Hardware State) of the lan cards. Should be “UP”

Lan cards that are assigned an ip-address:
# grep -i interface_name netconf
# INTERFACE_NAME:     Network interface name (see lanscan(1m))
INTERFACE_NAME[0]="lan1"
INTERFACE_NAME[1]="lan2"

The cards with ip-address assigned should have the interface state UP.
# ifconfig lan1
lan1: flags=843<UP,BROADCAST,RUNNING,MULTICAST>
        inet 194.178.122.10 netmask ffffffc0 broadcast 194.178.122.63

For lan cards that are not assigned a ip-address will report “no such interface”

# ifconfig lan0
ifconfig: no such interface

If the interface state is blank then check the /etc/rc.config.d/netconf file for the INTERFACE_STATE[N]="" parameter value of the interface card.
If value is “down “ then this could be purposefully done.
If the value is “up” or empty “” then the interface has to be UP on a system boot. If so change the interface state of the lan card to UP:


# ifconfig lan1 UP

Adding a Dummy Printer in HP-UX

1      Dummy Printer:

Configuring a dummy printer, on a system that has no printers configured and process lpsched not running, but Tivoli monitoring checks for a running lpsched process, can help avoid false alerts

lpadmin - configure the LP spooling system

syntax: /usr/sbin/lpadmin -pprinter [options]

-p Names a printer to which all of the options below refer.  If printer does not exist, it will be created

[options]
-mmodel           Selects a model interface program for printer P.
-vdevice          Associates a new device with printer P.

1.1        # lpadmin -pdummy -v/dev/null –mdumb


accept - allow LP printer queuing requests.
The accept command permits the lp command to accept printing requests

1.2        # accept dummy

destination "dummy" now accepting requests

The enable command activates the named printers, enabling them to print requests taken by lp.
# enable dummy

printer "dummy" now enabled

Use lpstat to find the status of printers

1.1        #lpstat -t

scheduler is not running
no system default destination
device for dummy: /dev/null
dummy not accepting requests since Nov 21 05:33 -
        new destination
printer dummy disabled since Nov 21 05:33 -
        new printer
        fence priority : 0
no entries

Use lpsched - start the LP request scheduler.

1.2        # lpsched

scheduler is running

# lpstat -t
scheduler is running ß
no system default destination
device for dummy: /dev/null
dummy accepting requests since Nov 21 05:33 ß
printer dummy is idle.  enabled since Nov 21 05:34 ß
        fence priority : 0

Friday, 1 July 2016

Fix for error /etc/profile[30]: /bin/cat: not found

While doing switch user on a server the following error was seen:

$ sudo su - pin
Password:
/etc/profile[30]: /bin/cat:  not found
/etc/profile[33]: /bin/mail:  not found

In the above situation /bin directory was deleted from the server.
The /bin was copied from another server with the same OS & patch version which fixed the error.

Fix for RAMDISK: incomplete write

While patching a virtual machine from RHEL 6.3 to 6.5 the server refused to boot up after reboot & the following error was being displayed:


RAMDISK: incomplete write (26171 !=32768)
write error
Kernel panic - not syncing VFS


The fix for this was to re-install vmware tools & re-create initramfs with the following command:

/sbin/dracut --force /boot/initramfs-2.6.32-431.17.1.el6.x86_64.img 2.6.32-431.17.1.el6.x86_64

Troubleshooting "ssh: connection closed by remote host"

So the error "ssh: connection closed by remote host" is one of the most common & pesky errors I've experienced as a system administrator.

Some of the troubleshooting & diagnostics I've learned over the years are as follows:

Note: You'll need console access to the server you're trying to ssh into.

  • Do an ssh -vvv <hostname> to get more detailed information as to why the connection is not getting established.
  • Check the status of ssh service on the destination server.
  • Check for space utilization of /,/var & /tmp file systems with df. Space constraints in these mount points can prevent logins.
  • Check permissions of /var & /etc & make sure they are not 777. The 'secure' in 'secure shell' kicks in & won't allow logins if permissions of /var & /etc are world readable. Also if the permissions of home directory of login user on destination server is set to 777 that would again cause a 'no login'.
  • Check the status of login user on destination server to make sure its not expired or locked. I know it sounds basic but still a valid check.
  • If you are using ssh keys for authentication make sure the authorized_keys file on destination server is syntactically correct.
  • Finally, check for nproc values on the destination server. Sometimes if the server is under heavy load & has a lot of processes running, the nproc value can inhibit the creation of new shell processes to conserve system resources thereby preventing login.


I hope these tips help save time the next time you see this error.

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...