Skip to content

Instantly share code, notes, and snippets.

@chrwei
Last active January 27, 2020 03:21
Show Gist options
  • Save chrwei/42f8bbb687290b04b598 to your computer and use it in GitHub Desktop.
Save chrwei/42f8bbb687290b04b598 to your computer and use it in GitHub Desktop.
How To install SCST on Ubutuntu 15.04 with in-tree kernel patches

These instructions are for SCST trunk as of 5/25/2015 and Ubuntu server 15.04 with 3.19.0-18-generic amd64 kernel. adjust paths as needed

SCST official site

commands all relative to the build dir of your choice and mostly dependent on the command above it

get latest SCST:

 svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk scst

make kernel patch:

 cd scst
 scripts/generate-kernel-patch 3.19 > ../scst.patch
 cd ..

get kernel source and tools:

 apt-get source linux-image-$(uname -r)
 apt-get build-dep linux-image-$(uname -r)
 apt-get install libncurses5-dev

apply scst patch to kernel and prepare it for building (note: -Np1 is a One(1) not a lower case L (l) ):

 cd linux-3.19.0/
 patch -Np1 -i ../scst.patch
 chmod a+x debian/scripts/*
 chmod a+x debian/scripts/misc/*

create a custom flavor for scst based on the generic flavor:

 cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.scst
 cp debian.master/abi/3.19.0-17.17/amd64/generic debian.master/abi/3.19.0-17.17/amd64/scst
 cp debian.master/abi/3.19.0-17.17/amd64/generic.modules debian.master/abi/3.19.0-17.17/amd64/scst.modules
 cp debian.master/control.d/vars.generic debian.master/control.d/vars.scst

edit debian.master/control.d/vars.scst to reflect SCST instead of Generic

edit debian.master/etc/getabis and add scst to the getall amd64... line

edit debian.master/rules.d/amd64.mk and add scst to the flavours = ... line

Update configs for our new flavor. Take default answer on any prompts:

 fakeroot debian/rules clean
 debian/rules updateconfigs

Edit the configs to enable scst modules, only edit amd64/config.flavour.scst, say "n" to all the others:

 debian/rules editconfigs

In the GUI select Networking Support, then Networking options, under TCP/IP networking press spacebar on TCP/IP zero-copy transfer completion notification to enable it. Select Exit twice and select Device Drivers, then SCSI Target (SCST) Support, then press spacebar on the option to make it <M>, leave what shows up as defaults. Select Exit until you get a Save prompt, choose Yes. You will get many config-check failures, they are all ARM and PPC related and do not affect us.

Compile the kernel:

 fakeroot debian/rules clean
 fakeroot debian/rules binary-headers binary-scst
 cd ..
 ls -l

you should now have several .deb files. Copy them to the target system and install the needed ones:

 dpkg -i linux-image-* linux-headers*

Reboot into the new kernel and cd back into your build dir to compile and install scst, iscsi, and scstadmin

 cd scst
 make scst scst_install iscsi iscsi_install scstadm scstadm_install
 cd ..

To enable boot-time startup:

  systemctl enable scst.service

Create /etc/scst.conf and add our devices and iscsi config. filename can be any storage block device, including MD, LVM, and mapper aliases, or a filename such as created with dd if=/dev/zero of=disk01 bs=1M count=1024. the TARGET name needs to be unique on your LAN, the part after the : is what you change (tgt in the example). You must also always have a LUN 0, in case you might want to remove any LUN, make a small file to be LUN 0 that will always exist.

 HANDLER vdisk_fileio {
        DEVICE disk01 {
                filename /media/data/disk01
                nv_cache 1
        }
 }
 TARGET_DRIVER iscsi {
        enabled 1
        TARGET iqn.2015-05.iscsi.lan:tgt {
                LUN 0 disk01
                enabled 1
        }
 }

Start the service:

 service scst start

iSCSI Initiators should now see your LUNs.

@gstanden
Copy link

gstanden commented Sep 26, 2016

FYI for anyone who might need to install SCST: Version 3.1.x of SCST no longer requires a custom kernel build for kernels >= 2.6.30. So if your kernel is 2.6.30 or higher, just get SCST version 3.1.x from SVN and then install it. You can use my automated bundle scst-files.tar at my github to do all of this for you automatically. https://github.com/gstanden/orabuntu-lxc and download the zip archive and then just unpack the scst-files.tar archive and follow the instructions. In about 15 minutes you will have SCST up and running. The bundle is now multi-distro : it works with Ubuntu Linux and with CentOS Linux. It will almost surely work with RedHat and the bundle could easily be modified for RedHat. I don't have a RedHat instance to validate on, but I do have an Oracle Linux instance, and will be testing it and releasing scst-files.tar for Oracle Linux as well. Thanks.

@gstanden
Copy link

gstanden commented Jul 6, 2017

Hi just an update in case it helps anyone: I now have a scripted automated solution which builds Debian *.deb package for SCST 3 for Ubuntu 14.04, 15.04, 16.04 and 17.04 (all tested) and should work on the 14.10, 15.10 etc. as well (not yet tested). You can get the tar archive with the scripting for building the Debian package here: https://sites.google.com/site/nandydandyoracle/scst/scst-create-deb-package-and-install-fpm (PS It works great!). You'll go from 0-60 and have the SCST SAN up and running in less than 10 minutes. It creates the SCST package, installs it, builds the SAN and LUNs and creates a matching multipath.conf file automatically. Note that these isn't a totally genuine deb package it will still require re-running my create-scst-install.sh script (re-building the package) whenever the kernel is updated (but only takes a minute to do). It is better than make install though because it at least puts everything under deb package management. Thanks. Gilbert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment