RPi iSCSI Initiator

Back to RPi Guides.

Raspberry Pi iSCSI Initiator Setup

=Introduction=

This guide is split into two parts, part 1 deals with rebuilding the standard Debian image to include iscsi support so that the pi can access an iscsi target (and function as a target itself if needed, but this guide deals with setting up as an initiator), part 2 then extends on this to enable booting from an iscsi root. For the sake of simplicity we will be performing on-device kernel recompiles, these take 4-6 hours, you can simply perform a cross-compile elsewhere to speed this up if you prefer.

=Assumptions/Pre-requisites=

This guide assumes a number of things:
 * At least a basic knowledge of iscsi, and that you already have a suitable target setup on your SAN/NAS/wherever.
 * You are working as the root user - If you're using a non-root user, most commands will need to be prefixed with a sudo.
 * You have repartitioned your SD card to increase the amount of space in / over the default 1.6GB provided by the Debian image (around 2GB is needed in total) - A good guide on doing this is available Here.

=Part 1 - iSCSI Support=

First up, we need to get the iscsi initiator service installed, along with git, gcc, make, ncurses-devel and python, which are needed for an on-device kernel recompile:

apt-get install open-iscsi git gcc make python libncurses5-dev

Lets create a folder in which to keep the various content we'll need for the kernel rebuild:

mkdir /root/raspberrypi cd /root/raspberrypi

We now need to fetch the kernel sources to build from, this will take a while:

git clone https://github.com/raspberrypi/linux.git --depth 1

Now take a copy of your current running kernel configuration, which we can then alter:

cd /root/raspberrypi/linux zcat /proc/config.gz > .config

Now let's load the system's UI-based kernel configuration editor (these changes can be adjusted manually, but the UI is simple):

make menuconfig

Once the UI has loaded, navigate to the "Device Drivers" section (enter to navigate between pages, space to change an option), then "SCSI device support", then "SCSI Transports". Change the "iSCSI Transport Attributes" option twice (so that it shows a *) to build it into the kernel. Go back a page, hit space for "SCSI low-level drivers" to enable this option, then enter to descend into it, then space twice for a * on "iSCSI Initiator over TCP/IP".

Once these options are enabled, exit the UI and save changes. To ensure these are set, run:

grep ISCSI .config

This should return the following:

CONFIG_SCSI_ISCSI_ATTRS=y CONFIG_ISCSI_TCP=y
 * 1) CONFIG_ISCSI_BOOT_SYSFS is not set

With this in place, compile your new kernel:

make

This process will take in the region of 4-6 hours to complete.

Once done, we need to generate an image of this kernel for the Pi to boot from, then replace your existing kernel:

First up, we need the mkimage python tool:

cd /root/raspberrypi git clone https://github.com/raspberrypi/tools

Now build the image:

cd /root/raspberrypi/tools/mkimage python imagetool-uncompressed.py /root/raspberrypi/linux/arch/arm/boot/Image

Now create a backup of your existing kernel, then replace the running kernel with the newly-generated one:

cp /boot/kernel.img /boot/kernel.img-backup cp kernel.img /boot/kernel.img

With this done, reboot your pi into your new iscsi-enabled kernel:

reboot

If you have any problems with booting at this point, you can always revert to your old kernel by mounting your SD card into a card reader on another system, then revert kernel.img-backup to kernel.img.

Assuming all has gone well, you can now use iscsiadm to discover then login to your iscsi target (though hopefully youll already be familiar with configuring an initiator to access a target), for example:

iscsiadm --mode discovery --type sendtargets --portal XXX.XXX.XXX.XXX

where the IP address in the above should be the address of your iscsi target, then once it has been discovered, login to the target with:

iscsiadm --mode node --loginall=all

=Part 2 - iSCSI root=

Coming shortly