Monday, May 11, 2009

Setup SAN presentation on Linux

The steps below are to scan for new LUNs from a SAN after the LUNs have been presented from the storage side when using QLogic HBA's . This post uses the QLogic Dynamic Target and LUN Discovery utilities which can be downloaded from:

http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByProduct.aspx?ProductCategory=39&Product=935&Os=126

The steps below will work on SUSE Linux Enterprise Server (SLES) 10 and Red Hat Enterprise Linux (RHEL) 5.
You can discover what version of Linux you are on by running:

cat /etc/*ease

Create a directory to hold the utilites. In this examle we will use the /tmp/ql_utils directory:

mkdir /tmp/ql_utils

Change to the /tmp/ql_utils directory:

cd /tmp/ql_utils

Retrieve the utilities from the download above and extract them from the zip file into the /tmp/ql_utils directory.
This will put five files into /tmp/ql_utils:

ql-dynamic-tgt-lun-disc.sh
README.ql-dynamic-tgt-lun-disc.txt
Copying
revision.qldynamic.txt
sg3_utils-1.23.tgz

The file that we are going to be using is the ql-dynamic-tgt-lun-disc.sh file. We need to ensure that it is set to executable:

chmod a+x /tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh


The ql-dynamic-tgt-lun-disc.sh script has several options available. You can see what these options are by running:

/tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh -h

The commands to scan for new LUNs are listed below. After the commands we'll describe what each command does. These commands should be run with root priveledges while inside the /tmp/ql_utils directory.

powermt display dev=all | egrep "Pseudo|Logical" > before
./ql-dynamic-tgt-lun-disc.sh
Please make sure there is no active I/O before running this script
Do you want to continue: (yes/no)? yes
powermt config
powermt display dev=all | egrep "Pseudo|Logical" > after
diff after before
powermt save

The first line outputs the current list of LUNs to the file named before. This is optional, but, makes it easy to see what new LUNs have been discovered later on.
The second line actually does the scan for new LUNs and prompts you to make sure that it's ok to run the script. Answer yes to the prompt.
The fifth line (powermt config) creates the emcpower devices in /dev.
The sixth line outputs the new list of LUNs to the file named after.
The seventh line runs a command to compare the list of new LUNs to the list of old LUNs. The differences will be displayed on screen. Make sure that names of the new LUNs show up in the output.
The last line saves the configuration.

After this is done, the LUNs can be setup with LVM. (see LVM post)

Wednesday, April 8, 2009

Slides from SLLUG PAM training

I taught a training session at the daytime Salt Lake Linux Users Group meeting today. I wanted to make the slides available to those that attended. They probably won't make a whole lot of sense if you didn't attend the meeting.
Slides from Pam Training presentation

Wednesday, November 26, 2008

Clear Swap Space in Linux

There have been times where it has been necessary for me to clear out the swap space on a Linux system. In order to do this, you must first make sure that you have enough free memory to hold what is being used by swap.
I usually do this in a few steps. You do need to be root to do this. First I want to see what is currently being used.
free

Then I run the actual commands that empty the swap:
swapoff -a && swapon -a

Then I check what is being used after doing this.
free

I have these three steps in a script and then I just run the script, but, the commands could easily be run from the command line.

Tuesday, November 18, 2008

Create Solaris Package from Source

For this example I will use stunnel since I had to create this package at work today. This software will be compiled from source and created as a package.

First we create a directory structure for our new package. In this example, I'll use /var/tmp/src, but it can be created anywhere.

# cd /var/tmp/src
# mkdir LDSstunnel InfoPath

In the InfoPath directory which we just created, use your favorite text editor (vi) to create a file named pkginfo with the following contents.

ARCH=SPARC
CATEGORY=application
NAME=stunnel
PKG=LDSstunnel
VERSION=4.26
DESC=allows to encrypt arbitrary TCP connections inside SSL
VENDOR=stunnel source taken from http://www.stunnel.org
- ARCH - is the architecture this package is built for. Can be sparc, i386 or ppc
- CATEGORY - list under which category to display the package
- NAME - short name of the package
- PKG - name of package. It is customary to make the first four letters unique to your company, such as a stock symbol.
- VERSION - version of package. In this case this is the version of stunnel
- DESC - descriptive information about the package
- VENDOR - used to describe the vendor that holds the software copyright
More information about these fields and other fields that can be used is in the pkginfo(4) man page.


Configure, compile, and install the software in a unique place

# ./configure --prefix=/opt/LDSstunnel
# make
# make install
# cd /opt/LDSstunnel
# mv * /
var/tmp/src/LDSstunnel/
# cd ..
# rmdir LDSstunnel

Make any changes that need to be made to config files, etc.
I copied a default configuration file into /var/tmp/src/LDSstunnel/etc/stunnel/

In the InfoPath directory create a file named prototype. This file can be created manually, however, it is much easier to use the pkgproto tool.
# cd /var/tmp/src
# pkgproto ./LDSstunnel > InfoPath/prototype

Add a line to the end of the prototype file with information about the pkginfo file
# echo "i pkginfo=/var/tmp/src/InfoPath/pkginfo" >> InfoPath/prototype

Use the pkgmk tool to create the package
# pkgmk -f InfoPath/prototype -b /var/tmp/src

We can now use the pkginfo command to get information about this new package which is in the /var/spool/pkg directory
# cd /var/spool/pkg
# pkginfo -d .
application LDSstunnel stunnel

Our package is located in the /var/spool/pkg directory. We could copy the contents of this directory to an nfs export or tarball it and copy it to the destination server and install.

Monday, November 17, 2008

vsftp and /etc/shells

I discovered today that there are a couple of issues with using local accounts with VSFTP. The first issue which is obvious is that local_enable=YES needs to be set in the vsftpd.conf file. The other issue that is not as obvious is that if you have a local user that has a shell set to /bin/false or /sbin/nologin, that user will get a incorrect login error when they try to login. The thing I did to fix this problem was added /sbin/nologin to /etc/shells. This worked on a SUSE Linux Enterprse Server 10 (SLES 10) server. The simple command that I used to do this was:

#echo /sbin/nologin >> /etc/shells

Thursday, September 11, 2008

Display WWN in SLES 10

A key component of setting up a server to a SAN is knowing what the World Wide Name (WWN) is. I was very accustomed to doing this in SLES 9. With SLES 10, the location of finding the WWN has changed and it is now in the file /sys/class/fc_host/host#/node_name. Where # is the number of the host that you want to find the WWN of. 

An even easier way to find this information is to use the systool command:
systool -c fc_host -A node_name

Friday, March 7, 2008

Switch from LSI Logic to BusLogic driver

At the place where I work, we run several SUSE Linux Enterprise Server (SLES) 9.3 VMs on VMWare ESX 3.0.2 servers. When running the LSI Logic driver that ships with SLES 9.3, if there is an interrupt to the disk the disks on the VM can go read-only. This interrupt can be due to SAN fail-over, high I/O, or other issues. This bug has been fixed and doesn't exist in SLES 10.1 or later.
Because of this, we have had the need to switch these from using the LSI Logic driver to use the BusLogic driver. The problem is that the original initial ram disk (initrd) is built with the LSI Logic driver and must be changed. I decided to document the steps required to do this. If you don't take these steps, the server will encounter a kernel panic on reboot after changing the VM to use the BusLogic HBA.

1) Update /etc/sysconfig/kernel with the BusLogic driver. Change the line that reads:

INITRD_MODULES="mptspi reiserfs dm_mod"

to read:

INITRD_MODULES="BusLogic reiserfs dm_mod"

2) Make a backup copy of the initrd file that is currently in use.

cp initrd-2.6.5.77-default initrd-2.6.5.77-default.preBusLogic

3) Rebuild the initial ram disk file to incorporate the changes made to /etc/sysconfig/kernel by running mkinitrd as root.

mkinitrd

Note: You can pass additional options to the mkinitrd command to use a specific kernel. By default it will build an initrd for all the kernel versions in /boot. This is sufficient for the servers in my environment.

4) Update the virtual machine to use the BusLogic HBA

Use the VirtualCenter Client
- Shutdown the VM
- Right click on the VM and select Edit Settings
- Select SCSI Controller 0 and click the Change Type button
- Select the BusLogic radio button and click OK
- Click OK to exit the Virtual Machine Properties
- Power on the VM
- Answer the "change the adapter type for scsi0:0 disk" by selecting the Yes radio button and clicking OK