Add and remove SCSI hot to linux.

August 4, 2011 at 11:24 am (Uncategorized)

I do file restores from snapshots using a linux server.  In my case it’s Centos.

I do this by creating a disk resource from a snapshot on my IPStor SAN.  Then I assign the new resource to all nodes of my HQ VMWare cluster.

  1. Create a disk resource from a snapshot on my IPStor SAN.
  2. Assign the new resource to all nodes of my HQ VMWare cluster.
  3. In VMWare, set the path settings for the new FC resource to round robin.  (Do this on each node in the cluster.)
  4. Add the resource to the restore linux server as a Raw Device Mappings.
  5. SSH into Linux server used for doing restores.
  6. Rescan the SCSI bus in order to make the new device available for mount.     Replace the “X” with the proper host number.

echo “- – – ” > /sys/class/scsi_host/hostX/scan

  • View the /var/log/messages file in order to determine what block device ID this resource has showed up as. In the example output, you will notice in green that this resource is registered as block device sdb1.  Look for some output like this:
Aug  4 10:48:28 zenoss ntfs-3g[7273]: Unmounting /dev/sdb1 (Users) 
Aug  4 11:06:22 zenoss kernel:   Vendor: VMware    Model: Virtual disk      Rev: 1.0 
Aug  4 11:06:22 zenoss kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Aug  4 11:06:22 zenoss kernel:  target0:0:1: Beginning Domain Validation
Aug  4 11:06:22 zenoss kernel:  target0:0:1: Domain Validation skipping write tests
Aug  4 11:06:22 zenoss kernel:  target0:0:1: Ending Domain Validation
Aug  4 11:06:22 zenoss kernel:  target0:0:1: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Aug  4 11:06:22 zenoss kernel: SCSI device sdb: 1572864000 512-byte hdwr sectors (805306 MB)
Aug  4 11:06:22 zenoss kernel: sdb: Write Protect is off
Aug  4 11:06:22 zenoss kernel: sdb: cache data unavailable
Aug  4 11:06:22 zenoss kernel: sdb: assuming drive cache: write through
Aug  4 11:06:22 zenoss kernel: SCSI device sdb: 1572864000 512-byte hdwr sectors (805306 MB)
Aug  4 11:06:22 zenoss kernel: sdb: Write Protect is off
Aug  4 11:06:22 zenoss kernel: sdb: cache data unavailable
Aug  4 11:06:22 zenoss kernel: sdb: assuming drive cache: write through
Aug  4 11:06:22 zenoss kernel:  sdb: sdb1
Aug  4 11:06:22 zenoss kernel: sd 0:0:1:0: Attached scsi disk sdb
Aug  4 11:06:22 zenoss kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0
  • Make sure that you can see the new resource.

cat /proc/scsi/scsi

  • Mount the new resource to a available mount spot.
mount /dev/sdb1 /mnt/recover1
  • Do your restore by copying off the files that you need….yada yada yada
  • Now it is time to unmount and disconnect the restore resource.
  • unmount the block device:

umount /dev/sdb1 /mnt/recover1

  • Delete the SCSI resource from the SCSI bus:

echo “scsi remove-single-device a b c d” > /proc/scsi/scsi
a == hostadapter id (first one being 0)
b == SCSI channel on hostadapter (first one being 0)
c == ID
d == LUN (first one being 0)

  • Make sure the resource is gone.

cat /proc/scsi/scsi

  • Now remove the RDM from the virtual host.
  • Remove SAN assignment of the snapshot resource from VMWare cluster.
  • Have vmware hosts rescan their FC connectsions.
  • Delete snap shot resource from SAN.
  • You are done.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: