Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chrwei
Last active January 27, 2020 03:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

Thank you for this awesome post!! There has been a need for a good reliable SCST on Ubuntu guide for a long time! I will just add that I need to also run the following commands to get things working:

sudo modprobe scst
sudo modprobe scst_vdisk
sudo modprobe iscsi-scst

otherwise I got errors of the type about the file io handler.

Thank you again, a huge help that you took time to publish this guide.

Gilbert
https://sites.google.com/site/nandydandyoracle

@gstanden
Copy link

If the SCST is running on a desktop, which gets frequent kernel upgrades, it may be necessary to compile the kernel again after an update. When I tried to do this, I kept get failures of "abi checks" at the end of my kernel compilation (long-running) final step. I researched abi checks but must confess I still don't entirely understand what is causing the build to fail abi checks. It's also kind of interesting that the first time you build SCST this error doesn't usually occur, but if you try to build the kernel again after an Ubuntu kernel update on the same desktop, then the abi error hits on the kernel compile.

However, there seems to be a well-known workaround or approach to this problem, which is to run the kernel compile with an additional switch. This switch worked for me (i.e the kernel compiled successfully with no more "abi check" errors). The exact error that would hit right at the end of the long-running compile was:

debian/rules.d/4-checks.mk:3: recipe for target 'abi-check-scst' failed

and the way to make the error "go away" was to run the compile with the additional switch "skipabi=true" i.e. run the compile command:

sudo skipabi=true fakeroot debian/rules -j8 binary-headers binary-scst

The only thing that worries me a bit is that frankly I don't understand what the error means in the first place, so I'm not sure if the workaround is producing a stable reliable kernel build. Hopefully it is. I searched for a good "debian abi for dummies" so to speak, but could not find a good explanation online that really made clear how to understand why the build was failing abi check.

(Note: the "-j8" is just added to supposedly speed up the compile and has nothing to do with the workaround for the abi check failure).

Thanks
Gilbert

@gstanden
Copy link

Using your procedure for creating SCST kernel on Ubuntu 15.04 in my github project here:
https://github.com/gstanden/orabuntu-lxc
Gilbert

@gstanden
Copy link

I've scripted this so that you can build the scst kernel automatically using the above procedure. Go to:

https://github.com/gstanden/orabuntu-lxc

and download the project archive. Unzip the archive and find the scst-files.tar and unzip it with 'tar -xvf scst-files.tar'. Run the scripts in order to create the scst ubuntu kernel. The scripting has been tested on Ubuntu 3.x and 4.x kernels. It automatically edits the required files and automatically selects correct directories based on the detected kernel version. Please let me know at gilstanden@hotmail.com if you hit any bugs running the bundle and I will work to fix them if you provide details.

To create, and then, boot into, the scst kernel, and create the scst binaries, you only need to run the following scripts:

create-scst-1a.sh
create scst-1b.sh
create-scst-1c.sh
create-scst-1d.sh
create-scst-2a.sh
create-scst-2b.sh
create-scst-3.sh

The rest of the scripts create targets and LUNs etc. that are specific to my Oracle on Ubuntu project (orabuntu-lxc) so if you are not going to use the SCST SAN for orabuntu-lxc, you are done, and you can proceed to manually create your targets, groups, LUNs, etc. from that point as per your requirements.

@chrwei
Copy link
Author

chrwei commented Apr 28, 2016

surprisingly, github didn't alert me of your comments, never thought I'd have to star my own gists :)

I hadn't tried recompiling as I run scst on an isolated SAN, only the storage admins and esxi hosts have access to it, so updating is of no priority. when you update, do you apt-get source and apt-get biuld-dep for the new version too? I expect you basically have to do the full guide over, and maybe including a make clean on the kernel and scst.

@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