Wednesday, January 6, 2010

Remove LUNs from Linux

I have a previous post here on how to add SAN Presentations (LUNs) to Linux. This post uses the same QLogic Dynamic Target and LUN Discovery utilities as the previous post. The steps below apply to SLES 10 and RHEL 5 servers using QLogic HBAs and PowerPath. That is what we have at my workplace and so that is what I'm most familiar with. This post also assumes that you have put the qlogic utilities into /tmp/ql_utils as described in the other post.

To remove a LUN and all associated PowerPath and Linux devices from the host environment follow these steps. These steps must be run with root privileges. (Note that it is critical to follow the procedures in exact order because deviating from the procedures can cause the host to panic.) These steps were put together using steps from QLogic KB articles.

1. Stop any I/O to the device being removed. [Unmount the filesystem or make sure that the disk has been completely removed from within Oracle ASM control.] It is critical to stop all I/O on the device that is being removed.

2. Run the following command to determine which native SCSI devices are mapped to the pseudo device:

powermt display dev=all

Find the name of the LUN to be removed and match it up with the emcpower device name. This will need to be done on each server individually.

3. Run the command:

powermt remove dev=emcpower

Where corresponds to the LUN to be removed.

4. Run the command:

powermt release

Failing to run this command results in the pseudo device still being visible in /dev and /sys/block and may lead to some complications when the new devices are dynamically added.

5. In the /tmp/ql_utils directory, there should be a script to rescan the qlogic hbas. (If this script doesn't exist, see the previous post for the steps to get the script.) The script is called ql-dynamic-tgt-lun-disc.sh. Run the script:

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

6. You will now remove the device from the storage array using your array admin utilities. On the Linux server, run powermt display to verify that the device has been removed.

7. Now remove the LUN from the Storage Group (CLARiiON) or unmap it from the FA ports (DMX).

Display WWN in SLES 9

I have another post regarding how to do this on SLES 10, so I decided to create a post on how to do this in SLES 9. In SLES 9 you can easily find the WWN for QLogic HBA's by running:

# cat /proc/scsi/qla2xxx/* | grep node

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