Out Here In The Field : Boost


Create Linux user accounts in bulk
July 11, 2011, 17:02
Filed under: *Nix, Red Hat, rhel | Tags: , , , ,

creating 1 or 2 new users on your system is a fairly simple task. But when you need to create 50 or 100 accounts on a system, creating it one by one by hand will surely annoy even the most patient sysadmin.

 

First, create a plain text file that contains all the informations required in a format of standard /etc/passwd file. For example, create a text file newuser.txt

[root@foxbat scripts] vi /root/newuser.txt

that contains:

ambon:afd43:673:673::/home/ambon:/bin/bash
amurang:ixl89:674:674::/home/amurang:/bin/bash
bandungcc:cfr45:675:675::/home/bandungcc:/bin/bash
baubau:ndk73:676:676::/home/baubau:/bin/bash

“ambon” is the account name, “afd43″ is the new password for the account, “636″ refers to the account UID & GID. I skipped on the user info and leave it as blank. Next,  the “/home/ambon” is the path to the home directory of that particular account, and “/bin/bash is the path to the account shell. Please note that since the password on this plain text is not encrypted, make sure that root and only root is the only user that has access to this file. You can chmod 600 this file to prevent access from another account.

Next, create the accounts by simply doing:

[root@foxbat scripts] newusers /root/newuser.txt

..And we’re done!

 



Moving Volume Groups between hosts in RHEL
June 1, 2011, 14:39
Filed under: *Nix, Red Hat, rhel, time out | Tags: , , , ,

This is a fairly straight-forward process.

  1. Exporting the volume group from its current host
    • Unmount any LV residing on that particular VG. In my case, there’s only one LV on VG vg0
      • list all lv in the vg
        [root@hqhcmdev1 ~]# lvdisplay 
        --- Logical volume --- 
        LV Name                /dev/vg0/lvol0 
        VG Name                vg0 
        LV UUID                7HltCU-Elaq-x1pr-S7Wm-xvOt-NGk6-Fwufyd 
        LV Write Access        read/write 
        LV Status              NOT available 
        LV Size                97.47 GB 
        Current LE             6238 
        Segments               1 
        Allocation             inherit 
        Read ahead sectors     0
      • unmount the lv
        [root@hqhcmdev1 ~]# umount /u01
      • if there’s any, remove the fstab entry for that particular partition, so that the booting process will not try to mount the partition
        [root@hqhcmdev1 ~]# vi /etc/fstab

        The /etc/fstab should look like this:

        # This file is edited by fstab-sync - see 'man fstab-sync' for details 
        /dev/VolGroup00/LogVol00 /     ext3     defaults 1 1 
        LABEL=/boot         /boot     ext3     defaults 1 2 none 
        /dev/pts         devpts         gid=5,mode=620 0 0 none 
        /dev/shm             tmpfs     defaults 0 0 none 
        /proc                 proc     defaults 0 0 none 
        /sys                 sysfs     defaults 0 0 
        /dev/VolGroup00/LogVol01 swap     swap     defaults 0 0 
        #LABEL=/u01         /u01     ext3     defaults 1 1
        
    • Deactivate, and export the volume group
      • Deactivating vg0
        [root@hqhcmdev1 ~]# vgchange -an vg0 
        0 logical volume(s) in volume group "vg0" now active
      • exporting vg0
        [root@hqhcmdev1 ~]# vgexport vg0 
        file system Volume group "vg0" successfully exported
  2. Import the volume group to the new server
    • Present the exported partition to the new server
      • Search for the new partition This step depends on what hardware are you using for the storage. Some SANs provide it’s own tool, and others use linux generic command such as:
         [root@hqhcmdev2 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
      • Check whether the partition has been detected by the target server using pvscan
        [root@hqhcmdev2 ~]# pvscan 
        PV /dev/sda2     VG VolGroup00 lvm2     [19.88 GB / 0 free]  
        PV /dev/sdb1 is in exported VG vg0     [99.98 GB / 2.52 GB free] 
        PV /dev/sdd1     VG VolGroup00 lvm2     [3.97 GB / 128.00 MB free] 
        Total: 3 [123.83 GB] / in use: 3 [123.83 GB] / in no VG: 0 [0    ]
        
    • Activate and import the volumegroup
      • Import the VG
        [root@hqhcmdev2 ~]# vgimport vg0 
        Volume group "vg0" successfully imported
      • Activate the VG
         [root@hqhcmdev2 ~]# vgchange -ay vg0
    • Mount the imported partition
      • Create a mountpoint for the imported partition
         [root@hqhcmdev2 ~]# mkdir /t01
      • label the partition First, look for the logical volume residing on the newly imported partition
        [root@hqhcmdev2 ~]# lvdisplay vg0 
        --- Logical volume --- 
        LV Name     /dev/vg0/lvol0 VG Name vg0 
        LV UUID     7HltCU-Elaq-x1pr-S7Wm-xvOt-NGk6-Fwufyd 
        LV Write Access read/write 
        LV Status     available 
        # open         1 
        LV Size     97.47 GB 
        Current LE     6238 
        Segments     1 
        Allocation     inherit 
        Read ahead     sectors 0 
        Block device     253:2

        Next, create a label for that LV

        [root@hqhcmdev2 ~]# e2label /dev/vg0/lvol0 /t01
      • optionally, create a fstab entry for the partition, if you want it to be automatically mounted on reboot
        [root@hqhcmdev2 ~]# vi /etc/fstab

        The /etc/fstab should look like this:

         This file is edited by fstab-sync - see 'man fstab-sync' for details 
        /dev/VolGroup00/LogVol00 /     ext3     defaults 1 1 
        LABEL=/boot         /boot     ext3     defaults 1 2 none 
        /dev/pts             devpts     gid=5,mode=620 0 0 none 
        /dev/shm             tmpfs     defaults 0 0 none 
        /proc                 proc     defaults 0 0 none 
        /sys                 sysfs     defaults 0 0 
        /dev/VolGroup00/LogVol01 swap     swap     defaults 0 0 
        LABEL=/t01         /t01     ext3     defaults 1 1
      • Mount the partition
        [root@hqhcmdev1 ~]# mount /t01
Replacing Emoji...
Replacing Emoji...


IBM Tape drive serial number in Redhat, AIX, and HP-UX
August 21, 2010, 11:16
Filed under: *Nix, AIX, HP-UX, Red Hat, rhel | Tags: , , , , , , , ,

One thing that you need to set up LanFree on TSM (or any kind of SAN Fiber channel backup) is the serial number of the tape drive registered on your server. I happen to be working on a somewhat heterogeneous environment that includes AIX, HP-UX, RHEL, and Windows. Below is my note on how to obtain the tape drive serial number those OSes. I’m using IBM TS3200 as our media library

RHEL

Pretty straight forward . All you have to do is  type the following command:

[root@hqdwhbe1 ~]# cat /proc/scsi/IBMtape
lin_tape version: 1.10.0
lin_tape major number: 250
Attached Tape Devices:
Number  model       SN                HBA                             FO Path   
0       ULT3580-TD4 1310140159        qla2xxx                         NA        
1       ULT3580-TD4 1310039844        qla2xxx                         NA        
2       ULT3580-TD4 1310135990        qla2xxx                         NA        
3       ULT3580-TD4 1310135028        qla2xxx                         NA        
4       ULT3580-TD4 1310136043        qla2xxx                         NA        
5       ULT3580-TD4 1310136063        qla2xxx                         NA        
[root@hqdwhbe1 ~]#

The command above will show you the serial number of all tape drive installed on your RHEL box

AIX

Similar to RHEL, do this on the console:

# lscfg -vpl rmt0
 rmt0             U789D.001.DQD74R5-P1-C2-T2-W2002000E11114398-L0 
 IBM 3580 Ultrium Tape Drive (FCP)
 Manufacturer................IBM     
 Machine Type and Model......ULT3580-TD4     
 Serial Number...............1310140159
 Device Specific.(FW)........89B2
 PLATFORM SPECIFIC
 Name:  tape
 Node:  tape
 Device Type:  byte

HP-UX

IBM provide us with tapeutil, a nice tool operate the IBM tape from console. To start, just type:

# tapeutil

From the menu, press “1″ to open a device. Type down the path to your tape drive. Next press “1″ to choose to open the device for read/write access

..On the next screen, press “3″ to query for the tape drive serial number

There you go

That’s it :)




Follow

Get every new post delivered to your Inbox.

Join 104 other followers