The target is LIO on debian Wheezy (runs on a Cubox-i4pro) with targetcli as management interface
For the client I used open-iscsi.
Step 1: get create a LUN on the target
Step 2: change /etc/iscsi/initiatorname.iscsi to something more readable and add credentials to /etc/iscsi/iscsid.conf.
Attention: changing the part before the last colon does nothing, only the last part can be changed
Step 3: configure the ACLs on the target correctly with the initiator name from the client.
Step 4: attach the target to the client by restarting open-iscsi service (this will attach all luns that are mapped to the initiator's acl
Step 5: partition and format the iscsi "disk"
Step 6: copy the rootfs into the iscsi disk
Step 7: important if you use dhcp, then you have to make sure that dhclient doesn't interrupt the network service when it acquires the IP address!
This is done by adding a hook script into /etc/dhcp/dhclient-enter-hooks.d of the iscsi disk
Code: Select all
if [ x$reason = xPREINIT ]; then
# tell dhclient we already have an IP address from the kernel
reason=RENEW
old_ip_address=$new_ip_address
elif [ x$reason = xREBOOT ]; then
# tell dhclient we already have an IP address from the kernel
reason=RENEW
old_ip_address=$new_ip_address
fi
Step 8: tell update-initramfs to add iscsi to the initramfs image
This is done by adding a file named "iscsi.initramfs" into /etc/iscsi
what you can also do is to add the iscsi infos into this file that would otherwise have to be put into the kernel commandline:
Code: Select all
ISCSI_INITIATOR=iqn.1993-08.org.debian:01:local.home.avconv
ISCSI_TARGET_NAME=iqn.2016-06.local.home.cubox:linux-root
ISCSI_TARGET_IP=192.168.2.105
ISCSI_TARGET_PORT=3260
ISCSI_TARGET_GROUP=1
ISCSI_USERNAME=[username]
ISCSI_PASSWORD=[password]
Step 10: copy the current kernel[7].img to e.g. kernel7-4.4.9-v7+.img
Step 11: add "kernel" and "initramfs" lines to config.txt like so:
Code: Select all
kernel=kernel7-4.4.9-v7+.img
initramfs initrd.img-4.4.9-v7+ followkernel
This is done so that a kernel update can't break the boot process. You'll have to manually switch to the new kernel
EDIT: This safety measure does not work anymore, since the raspberrypi-kernel package as of kernel version 4.4.13 removes the modules of older kernels.
Step 12: change cmdline.txt
The important part is this:
Code: Select all
ip=::::[hostname]:eth0:dhcp root=UUID=[uuid of iscsi partition]

Regards
Aydan
PS: I'm running Devuan Jessie on the Pi3, so there could be some differences towards Debian Jessie and SystemD