Monday, February 21, 2011

Managing HBAs and SAN disks in Redhat Linux 4 & 5

Redhat 5 :

To list the LUNs and their paths :
# multipath -ll

To display pv information on a multipath :
# pvdisplay /dev/mapper/mpath0

To find the server hardware details :
# dmidecode <- hardware info To scan for new LUNs: # ls /sys/class/fc_host host0 host1 # fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l

# echo "1" > /sys/class/fc_host/host0/issue_lip

# echo "- - -" > /sys/class/scsi_host/host0/scan

# echo "1" > /sys/class/fc_host/host1/issue_lip

# echo "- - -" > /sys/class/scsi_host/host1/scan

# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l

# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l



RHEL 4.6 :

To see HBA details like firmware, wwn,etc.. :
# cat /proc/scsi/qla2xxx/0

To list the HBAs along with their HBA :
# adapter_info

To scan for new LUNs:
# hp_rescan -a

To show the WWN of a LUN :
# scsi_info /dev/sdb


To list the configured Qlogic adapters:
# lspci | grep -i qlo


To list the LUNs:
# /opt/hp/hp_fibreutils/lssd

Output will be like

sda H,B,T,L

where
H is the host number of the HBA
B is the bus number (normally 0)
T is the target number
L is the LUN number
is a string which uniquely identifies the storage array.

To remove a lun from OS:
# echo "1" > /sys/block/sd/device/delete
# echo "scsi remove-single-device H B T L" > /proc/scsi/scsi
# echo "1" > /sys/class/scsi_host/host/device/targetH:B:T:L/H:B:T:L/delete

Wednesday, December 1, 2010

Swap Space

1. To setup swap space on a newly created partition :
# mkswap /dev/sdb3

2. To enable the swap partition :
# swapon /dev/sdb3

3. To enable the above swap device at boot time, add the below line to /etc/fstab

/dev/sdb3 swap swap defaults 0 0

4 To create a swap file:

a. Create an empty file
# dd if=/dev/zero of=/swapfile bs=1024 count=65536

b. Create swap space on the file
# mkswap /swap-file

c. Enable the swap file
# swapon /swap-file

d. Add the below line to /etc/fstab
/swap-file swap swap defaults 0 0

5. To remove a swap file

a. Disable swap on the file
# rmswap /swap-file
b. Remove the corresponding entry in /etc/fstab
c. Delete the file
# rm /swap-file

Kernel Module

1. To list the currently loaded kernel modules :
# lsmod

2. To load a module :
# modprobe hid
For detailed output:
# modprobe -v hid

3. To unload a module (only the unused and undependent modules) :
# rmmod hid

4. Module files are kept under /lib/modules//kernel/drivers/

5. To display information about a specific module :
# modinfo -d hid

Identifying a system using /proc Filesystem

1. To show the OS (Kernel) version:
# cat /proc/version

2. To identify the processor details :
# cat /proc/cpuinfo

3. To identify the memory information :
# cat /etc/meminfo

4. To show the raid devices :
# cat /proc/mdstat

5. File containing the disk partition details :
/proc/partitions

6. File containing the swap details :
/proc/swaps

7. File containing the uptime details :
/proc/uptime

Starting and Stopping Services

1. To start http service :
# /etc/rc.d/init.d/httpd start
# service sshd start

2. To stop http service :
# /etc/rc.d/init.d/httpd stop
# service sshd stop

3. To restartp http service :
# /etc/rc.d/init.d/httpd restart
# service sshd restart

4. To show the status of http service :
# /etc/rc.d/init.d/httpd status
# service sshd status

5. To show the status of all the services :
# service --status-all

6. To list the state of a service in different run levels :
# chkconfig --list ypxfrd

7. To list the state of all the services in different run levels :
# chkconfig --list

8. To enable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd on

9. To disable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd off

Software Management

1. To install a RPM package :
# rpm -ivh foo-1.0-2.i386.rpm

2. To uninstall a RPM package :
# rpm -e foo

3. To upgrade a RMP package :
# rpm -Uvh foo-1.0-2.i386.rpm

4. To query a RPM package :
# rpm -q foo
# rpm -qa | grep foo

5. To display a RPM package information :
# rpm -qi foo

6. To check the signatue of a RPM package :
# rpm --checksig foo

7. To list files in a RPM package :
# rpm -ql foo

8. To list all the installed RPMs :
# rpm -qa

Hardware Information

1. To show the SCSI HDD/CD/VD drive information

# sdparm -i /dev/sda

2. To show the IDE HDD/CD/VD drive information

# hdparm -i /dev/hda

Monday, September 7, 2009

System Monitoring

File containing Boot messages:
/var/log/boot.msg

To view the content of current kernel buffer:
# dmesg

Few /proc files containing system info:

/proc/cpuinfo : View processor information
/proc/meminfo : View memory information
/proc/devices : View the devices configured on your linux machine
/pro/ioports : View the I/O ports
/pro/interrupts : View the IRQ assignments
/proc/dma : View the DMA channels
/proc/bus/pci/devices : View the PCI information
/proc/scsi/scsi : View the scsi information

Fiew Commands to view hardware details:

To display the list of hardware(devices) installed in your system:
# hwinfo

To display hard drive info and manage its paramets:
# hdparm

To list the current disk partitions:
# fdisk

To display the CPU and I/O statistics:
# iostat

To display the list of PCI buses and the devices connected to it:
# lspci

To collect the system information in HTML or ASCII format:
# siga

To prepare system information using Perl:
# sitar

To display the current time, system uptime, # of users on the system:
# uptime

To list the network ports and their offered services:
# netstat -patune

To display current kernel version:
# uname -a

To display the cpu, memory, swap usage :
# top

To display the system memory and swap usage:
# free

To display memory, swap, io, system and cpu usage:
# vmstat

To display the kernel type:
# getconf LONG_BIT

Networking

To start network services:
# /etc/rc.d/init.d/network start

To stop network services:
# /etc/rc.d/init.d/network stop

To restart network services:
# /etc/rc.d/init.d/network restart

To view the network configuraiton:
# ifconfig [or]
# ip addr show

To configure an interface :
# ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
# Modify the file /etc/sysconfig/network-scripts/ifcfg-eth0

To configure alias on eth0 :
# ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up

To list routing table :
# route

To add the default gateway to the routing table:
# route add default gw 192.168.0.15
[or]
# ip route add default via 192.168.0.5

To add a route for a specific host:
# route add -host 11.0.0.2 gw 192.168.0.115

To add a route for a specific network:
# route add -net 11.0.0.0 gw 192.168.0.115

Daemon used for dynamin routing/ Uses RIP: routed

Command to start routed daemon:
# rcrouted start

Configure a network card:
# ip link set mtu 9000 dev eth0

To show the network links:
# ip link show

To view ARP cache:
# arp -n

To remove an ARP entry:
# arp -d 192.168.1.1

To modifiy the host name resolution order, Modify the below file:
# cat /etc/host.conf
order hosts,bind

To modify the DNS server info:
# cat /etc/resolv.conf
search openna.com
nameserver 218.104.16.6
nameserver 218.104.16.12

To configure networking in Linux, modify the below file:
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=myserver
GATEWAY=192.168.1.1
GATEWAYDEV=eth0

To enable IP Forwarding:

For RHEL 6.2,
a. Add the below lines to /etc/sysctl.conf file
# Enable packet forwarding
net.ipv4.ip_forward = 1

b. Restart network services
# /etc/rc.d/init.d/network restart

For RHEL version lesser than 6.2,
a. Modify /etc/sysconfig/network
b. Restart network services

Disk Partitioning

To list the current partitions:
# fdisk -l

To list the partitions on a disk:
# fdisk -l /dev/sdb

To create partition on a disk:
# fdisk /dev/sdb
-> type n
-> type 'e' for extended or
'p' for primary partition
-> Enter the first cylinder number
-> Enter the last cylinder or size in KB,MB or GB
-> Enter 'p' to verify the partition table
-> Finally save the partition table by entering 'w'

Command used to inform the kernel of partition table changes:
# partprobe