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

Posted in Uncategorized | Tagged: , , , , , , , | 1 Comment »

Hot-swap drive

Posted by jaysoncena on October 19, 2011

cat /sys/bus/scsi/devices/2\:0\:0\:0/model
echo “1” > /sys/bus/scsi/devices/2\:0\:0\:0/delete
replace harddrive
echo > /sys/bus/scsi/devices/2\:0\:0\:0/rescan
– OR –
echo “- – -” > /sys/class/scsi_host/host2/scan

Posted in Uncategorized | Leave a Comment »

Enable Guest-Enabled Shared Folder on an ADS-modeled Samba Server

Posted by jaysoncena on October 17, 2011

# smbpasswd -an nobody
[global]

guest account = nobody
map to guest = bad user

[shared_folder]

guest ok = yes
guest only = yes
host deny = ALL
host allow = 192.168.0.0/16
force user = nobody
force group = nogroup
public = yes
writeable = yes

Posted in Uncategorized | Tagged: , , , | Leave a Comment »

Samba Shadow Copy Module

Posted by jaysoncena on August 9, 2011

[shadowshare1]
	path = /mnt/storage/shadowshare
	vfs objects = shadow_copy2
	shadow: snapdir = /mnt/storage/shadowshare-snapcollection
	shadow: basedir = /mnt/storage/shadowshare
	available = yes
	browseable = yes
	writeable = yes
	force user = nobody
	valid users = op_jayson,kenneth,dino

------------------------------------------------------
/dev/mapper/storage-shadowshare on /mnt/storage/shadowshare type xfs (rw)
/dev/mapper/storage-shadowshare_snap1 on /mnt/storage/shadowshare-snapcollection/@GMT-2011.08.09-03.28.53 type xfs (ro,nouuid)
/dev/mapper/storage-shadowshare_snap2 on /mnt/storage/shadowshare-snapcollection/@GMT-2011.08.09-03.31.42 type xfs (ro,nouuid)
------------------------------------------------------
root@fileserver0 ~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/turnkey-root
                       17G  2.4G   14G  15% /
none                  499M  232K  499M   1% /dev
none                  502M     0  502M   0% /dev/shm
none                  502M   18M  484M   4% /var/run
none                  502M     0  502M   0% /var/lock
none                  502M     0  502M   0% /lib/init/rw
/dev/sda1             473M   17M  432M   4% /boot
/dev/mapper/storage-projects
                      262G  133G  130G  51% /mnt/storage/projects
/dev/mapper/storage-units
                      130G  120G   11G  93% /mnt/storage/units
/dev/mapper/storage-installers
                       10G  5.1G  5.0G  51% /mnt/storage/installers
/dev/mapper/storage-shadowshare
                      5.0G  4.2M  5.0G   1% /mnt/storage/shadowshare
/dev/mapper/storage-shadowshare_snap1
                      5.0G  4.2M  5.0G   1% /mnt/storage/shadowshare-snapcollection/@GMT-2011.08.09-03.28.53
/dev/mapper/storage-shadowshare_snap2
                      5.0G  4.2M  5.0G   1% /mnt/storage/shadowshare-snapcollection/@GMT-2011.08.09-03.31.42
------------------------------------------------------
  --- Logical volume ---
  LV Name                /dev/storage/shadowshare
  VG Name                storage
  LV UUID                eXONzU-lV03-Ilao-engz-L5Jj-er3g-wrUlp2
  LV Write Access        read/write
  LV snapshot status     source of
                         /dev/storage/shadowshare_snap1 [active]
                         /dev/storage/shadowshare_snap2 [active]
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:7

  --- Logical volume ---
  LV Name                /dev/storage/shadowshare_snap1
  VG Name                storage
  LV UUID                AhEOAF-G0UT-8igr-NUw0-X7Sc-G1cJ-87mypZ
  LV Write Access        read/write
  LV snapshot status     active destination for /dev/storage/shadowshare
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  COW-table size         5.00 GiB
  COW-table LE           1280
  Allocated to snapshot  0.04%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:8

  --- Logical volume ---
  LV Name                /dev/storage/shadowshare_snap2
  VG Name                storage
  LV UUID                4NDVmg-vBDi-0UgN-woQ8-GCuI-mXWE-fyR383
  LV Write Access        read/write
  LV snapshot status     active destination for /dev/storage/shadowshare
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  COW-table size         5.00 GiB
  COW-table LE           1280
  Allocated to snapshot  0.04%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:11

Posted in Uncategorized | Leave a Comment »

Hello world!

Posted by jaysoncena on April 10, 2011

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can alway preview any post or edit you before you share it to the world.

Posted in Uncategorized | 1 Comment »