Search This Blog

Tuesday, 19 April 2011

Extending VMWARE guest linux OS Filesystem

1.Rescan SCSI Bus to detect newly added disk using below command.

[root@RHEL ~]# echo "- - -">/sys/class/scsi_host/host*/scan

2. Tail system message file for checking the newly added disk is probed.
[root@RHEL ~]# tail -f /var/log/messages
Mar  6 16:34:56 RHEL kernel: SCSI device sdc: 545259520 512-byte hdwr sectors (279173 MB)
Mar  6 16:34:56 RHEL kernel: sdc: cache data unavailable
Mar  6 16:34:56 RHEL kernel: sdc: assuming drive cache: write through
Mar  6 16:34:56 RHEL kernel: SCSI device sdc: 545259520 512-byte hdwr sectors (279173 MB)
Mar  6 16:34:56 RHEL kernel: sdc: cache data unavailable
Mar  6 16:34:56 RHEL kernel: sdc: assuming drive cache: write through
Mar  6 16:34:57 RHEL kernel:  sdc: unknown partition table
Mar  6 16:34:57 RHEL kernel: Attached scsi disk sdc at scsi0, channel 0, id 2, lun 0
Mar  6 16:34:57 RHEL scsi.agent[31318]: disk at /devices/pci0000:00/0000:00:10.0/host0/target0:0:2/0:0:2:0
Mar  6 16:34:57 RHEL udevd[1418]: udev done!

3. Now the new disk (/dev/sdc) is  visible in fdisk output (With a invalid disk label for new disks)
[root@RHEL ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        3916    31350847+  8e  Linux LVM

Disk /dev/sdb: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        9138    73400319+  8e  Linux LVM

Disk /dev/sdc: 279.1 GB, 279172874240 bytes
255 heads, 63 sectors/track, 33940 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table

4. Create physical volume on new disk
#pvcreate /dev/sdc
5. Extend the VG(VgBSL) to new disk (/dev/sdc)
[root@RHEL ~]# vgextend VgBSL /dev/sdc
  /dev/cdrom: open failed: No medium found
  Volume group "VgBSL" successfully extended
5. List the existing Physical Volumes
[root@RHEL ~]# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/sda2  VolGroup00 lvm2 a-    29.88G      0
  /dev/sdb1  VgBSL     lvm2 a-    69.97G   1.53G
  /dev/sdc   VgBSL     lvm2 a-   259.97G 259.97G

6. Extend logical Volume to new size (old size + newly available)
[root@RHEL ~]# lvextend -L 299G /dev/mapper/VgBSL-LogVol02
  Extending logical volume LogVol02 to 299.00 GB
  Logical volume LogVol02 successfully resized

7. Extend the Volume using ext2online command.
[root@RHEL ~]# ext2online /dev/mapper/VgBSL-LogVol02
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
8. Now the Volume is resized to new size
[root@RHEL ~]# df -h /apps
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VgBSL-LogVol02
                      295G   37G  247G  13% /apps

Saturday, 16 April 2011

Colon Separated WWPN in Soalris

The script prints the WWPN of Solaris 10 HBA cards WWPN in a familiar colon separated format that Storage Admin can use easily in SAN devices.

root@solaris-10 # fcinfo hba-port|grep 'HBA Port WWN'|awk {'print $4'}|perl -pe 's/(..)/\1:/g'|cut -c 1-23
21:00:00:1b:32:95:56:2c
21:01:00:1b:32:b5:56:2c
21:00:00:1b:32:95:66:2c
21:01:00:1b:32:b5:66:2c

Tuesday, 12 April 2011

Script for Deleting a Specific day older files

 

#Source Directory
SRC=/apps/temp
#Specify size of file system in percentage when the script work. Nothing will happen if the FS utilization is below this.
CUTOFF=15
#Specify the age of file to be moved (older than this)
OLD=14
TS=`date "+%Y_%m_%d_%H:%M:%S"`
#location of Logfile
LOG=/tmp/mvfile.$TS
X=`df $SRC |grep -v Used|awk '{print $4}'|cut -c1-2|grep -v ^$`

if [ -f  $LOG ]
        then
        rm  $LOG
fi

if [[ $X -gt $CUTOFF ]]
then
        echo "/usr/bin/find $SRC -mtime +$OLD -print >>/tmp/mvfiles.$TS"
        /usr/bin/find $SRC -mtime +$OLD -print >>$LOG
                for i in `cat $LOG`
                do
                rm $i
                done
                echo "Log file Available:  $LOG"
fi

Monday, 11 April 2011

sudo configuration on Solaris shared zones

 

Since /usr is will be read-only on zone, its not possible to do any changes on sudo configuration from shared zones. Use visudo command from global zone for below tasks.

1. Create alias for each zones with corresponding hostnames.

Host_Alias ZONE1=zone1.example.com
Host_Alias ZONE1=zone2.example.com

2. Use above alias for each line as below (user1 has privileges for below command on zone1 and user2 has zone2. Its is mandatory the user should exists on global zone.)

user1 ZONE1=NOPASSWD:/usr/bin/passwd, /usr/sbin/useradd, /usr/sbin/usermod
user2 ZONE2=NOPASSWD:/usr/bin/passwd, /usr/sbin/useradd, /usr/sbin/usermod