jaysoncena

From a Freelancer's Viewpoint

SCST-based Linux SAN

Posted by jaysoncena on March 17, 2013

# Create partition on Disk 1
sgdisk --zap-all /dev/sda
sgdisk -n 1:2048:4095 -c 1:"biosboot" -t 1:ef02 /dev/sda
sgdisk -n 2:4096:1052671 -c 2:"Boot - Node2/Disk1" -t 2:0700 /dev/sda
sgdisk -n 3:1052672:22024191 -c 3:"RAID10 Root Partition" -t 3:FD00 /dev/sda
sgdisk -n 4:22024192:3907029134 -c 4:"RAID5 iSCSI Volume" -t 4:FD00 /dev/sda

# Create partition on Disk 2
sgdisk --zap-all /dev/sdb
sgdisk -n 1:2048:4095 -c 1:"biosboot" -t 1:ef02 /dev/sdb
sgdisk -n 2:4096:1052671 -c 2:"Boot - Node2/Disk2" -t 2:0700 /dev/sdb
sgdisk -n 3:1052672:22024191 -c 3:"RAID10 Root Partition" -t 3:FD00 /dev/sdb
sgdisk -n 4:22024192:3907029134 -c 4:"RAID5 iSCSI Volume" -t 4:FD00 /dev/sdb

# Create partition on Disk 3
sgdisk --zap-all /dev/sdc
sgdisk -n 1:2048:4095 -c 1:"biosboot" -t 1:ef02 /dev/sdc
sgdisk -n 2:4096:1052671 -c 2:"Boot - Node2/Disk3" -t 2:0700 /dev/sdc
sgdisk -n 3:1052672:22024191 -c 3:"RAID10 Root Partition" -t 3:FD00 /dev/sdc
sgdisk -n 4:22024192:3907029134 -c 4:"RAID5 iSCSI Volume" -t 4:FD00 /dev/sdc

# Create partition on Disk 4
sgdisk --zap-all /dev/sdd
sgdisk -n 1:2048:4095 -c 1:"biosboot" -t 1:ef02 /dev/sdd
sgdisk -n 2:4096:1052671 -c 2:"Boot - Node2/Disk4" -t 2:0700 /dev/sdd
sgdisk -n 3:1052672:22024191 -c 3:"RAID10 Root Partition" -t 3:FD00 /dev/sdd
sgdisk -n 4:22024192:3907029134 -c 4:"RAID5 iSCSI Volume" -t 4:FD00 /dev/sdd

###################
# Create redundant boot partition
###################

# Create copy of boot partition
umount /boot
dd if=/dev/sda2 of=/usr/src/sda2.img

# Create replicated boot partition (RAID1)
mdadm --create /dev/md1 --metadata=0.90 --level=raid1 --raid-devices=4 --spare-devices=0 /dev/sdb2 /dev/sdc2 /dev/sdd2 missing

# Check if the array is created
mdadm --detail /dev/md1

# Create partition on the RAID1 boot partition
mkfs.ext3 /dev/md1

# Mount the original boot partition and the new RAID1 boot partition
mkdir /tmp/md1
mount /dev/md1 /tmp/md1

# Sync contents from the original boot partition to the new RAID1 partition
rsync -av /boot/ /tmp/md1/
umount /tmp/md1

# Backup original boot partition
dd if=/dev/sda2 of=/usr/src/sda2.img

# Make the old boot partition a member of the mirrored boot partition
umount /boot
mdadm --manage /dev/md1 --add /dev/sda2

# Install grub on all disks
grub-install /dev/sdb
grub-install /dev/sdc
grub-install /dev/sdd

# Edit /etc/fstab, replace /boot with /dev/md1

# Create iSCSI Target Volume
mdadm --create /dev/md2 --level=raid5 --raid-devices=4 --spare-devices=0 /dev/sda4 /dev/sdb4 /dev/sdc4 /dev/sdd4
mdadm --manage /dev/md2 --run

## Install perl and perl-modules
apt-get install perl perl-modules

## Install iSCSI-SCST
dpkg -i scst_2.2.0-1_i386.deb iscsi-scst_2.2.0-1_i386.deb scstadmin_2.2.0-1_i386.deb

## /etc/scst.conf
HANDLER vdisk_fileio {
	DEVICE array_lun0 {
		filename /dev/md2
	}
}
HANDLER vdisk_nullio {
	DEVICE null_lun1 {
	}
}

TARGET_DRIVER iscsi {
	enabled 1
	TARGET iqn.2013-01.ph.com.citech:node3 {
		LUN 0 array_lun0
		LUN 1 null_lun1
		enabled 1
	}
}

## Create Directory
mkdir -p /var/lib/scst/pr

## Start SCST
service scst start

## List iSCSI LUNs
scstadmin -list_device


#######################
# Client Side (Initiator)
#######################

iscsiadm -m discovery -t st -p 10.254.2.13:3260

Advertisements

One Response to “SCST-based Linux SAN”

  1. […] https://jaysoncena.wordpress.com/2013/03/17/26/  generic.. […]

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: