Thinkcat
Posts: 28
Joined: Wed Mar 14, 2018 10:50 pm
Location: Finland

All the iSCSI solutions for Raspbian

Thu Oct 31, 2019 3:42 pm

Hello

I'm running a Pi4 and wanted to mount an iSCSI share to it from a FreeNAS server. Problem is, no discovery produces any results from iSCSI shares that clearly are there and work with other systems and solutions.

So I figured out that I should study the issue by setting up my Pi3 as an iSCSI server. Problem is, there seems to be two solutions to do that. One is tgt, another is iscsitarget.

With the latter one, the kernel modules fail to compile:

Code: Select all

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 71.0 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://raspbian.mirror.constant.com/raspbian stretch/main armhf iscsitarget-dkms all 1.4.20.3+svn502-2 [71.0 kB]
Fetched 71.0 kB in 0s (76.9 kB/s)     
(Reading database ... 88326 files and directories currently installed.)
Preparing to unpack .../iscsitarget-dkms_1.4.20.3+svn502-2_all.deb ...

------------------------------
Deleting module version: 1.4.20.3+svn502
completely from the DKMS tree.
------------------------------
Done.
Unpacking iscsitarget-dkms (1.4.20.3+svn502-2) over (1.4.20.3+svn502-2) ...
Setting up iscsitarget-dkms (1.4.20.3+svn502-2) ...

Creating symlink /var/lib/dkms/iscsitarget/1.4.20.3+svn502/source ->
                 /usr/src/iscsitarget-1.4.20.3+svn502

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....
make -j4 KERNELRELEASE=4.19.66-v7+ -C /lib/modules/4.19.66-v7+/build M=/var/lib/dkms/iscsitarget/1.4.20.3+svn502/build.....(bad exit status: 2)
Error! Bad return status for module build on kernel: 4.19.66-v7+ (armv7l)
Consult /var/lib/dkms/iscsitarget/1.4.20.3+svn502/build/make.log for more information.
Removing old iscsitarget-1.4.20.3+svn502 DKMS files...

------------------------------
Deleting module version: 1.4.20.3+svn502
completely from the DKMS tree.
------------------------------
Done.
Loading new iscsitarget-1.4.20.3+svn502 DKMS files...
It is likely that 4.19.66-v7+ belongs to a chroot's host
Building for 4.19.66+ and 4.19.66-v7+
Building initial module for 4.19.66+
Error! Bad return status for module build on kernel: 4.19.66+ (armv7l)
Consult /var/lib/dkms/iscsitarget/1.4.20.3+svn502/build/make.log for more information.
I've been unable to figure out if I really have two kernels installed or just one. What is the difference between 4.19.66+ and 4.19.66-v7+, or are they somehow versions of the same? Their headers are from the same package. And in /boot there's kernel.img and kernel7.img, both about 5 MB in size. uname -r gives 4.19.66-v7+.

I will try tgt next.

epoch1970
Posts: 3864
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: All the iSCSI solutions for Raspbian

Fri Nov 01, 2019 1:49 pm

Tgt was replaced by iscsi/LIO about 10 years ago.
https://wiki.archlinux.org/index.php/ISCSI
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Thinkcat
Posts: 28
Joined: Wed Mar 14, 2018 10:50 pm
Location: Finland

Re: All the iSCSI solutions for Raspbian

Sat Nov 02, 2019 9:12 pm

My adventure with setting up tgt on a Pi3 (without the plus) has gone like this:

For testing, I created a sparse file of a few gigabytes into my home directory:

Code: Select all

dd if=/dev/zero of=/home/pi/.abigsparsefile bs=1 count=0 seek=32G
Then I continued setting up the service:

Code: Select all

sudo tgtadm --lld iscsi --mode target --op new --tid 1 --targetname myiscsitarget
sudo tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-name iqn.1993-08.org.debian:01:23456789012
sudo tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address 192.168.1.40
sudo tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store /home/pi/.abigsparsefile
sudo tgtadm --lld iscsi --mode account --op new --user carrot --password cabbage
sudo tgtadm --lld iscsi --mode account --op bind --tid 1 --user carrot
sudo tgtadm --lld iscsi --mode lld --op start
The settings are read by the service from /etc/tgt/targets.conf and /etc/tgt/conf.d/ but are not written there automatically. To write a configuration file, run tgt-admin --dump (notice the different binary) and either append the result to targets.conf or create a new file inside the conf.d directory. Also reinsert the password if one was used.

This way I had a working iSCSI target once I fixed a few stupid mistakes I made the first time round.

Return to “Advanced users”