Freenas as an iscsi initiator

Nick Howard

Contributor
Joined
May 20, 2014
Messages
129
Ok so I've read numerous posts on this and also read the manual which states the only way to set this up is via the CLI using iscontrol. I find it a little strange this isn't built in and enabled from within the GUI. Is this something that will be added in the future?

I'm willing to give it go however, although I'm only just getting to grips with the CLI and from what I've read this will still lose all the settings after any reboot of the freenas, again not an ideal.

The reason I'm wanting to try this is because I've just got my hands on a FC san with 45 x 750gb drives. I've got a fc/iscsi router and have it all set up from that end. I've set my pc up as an initiator and can see all the storage fine, it would just be ideal if I could get freenas to use it.
 
Last edited:

iSCSIinitiator

Dabbler
Joined
Jul 17, 2014
Messages
16
Mr. Howard,

Hi. I am trying to do the same thing. I haven't had success yet. Running iscontrol from the shell gives the following error:

sysctlbyname("net.iscsi_initiator.driver_version") failed; is the iscsi driver loaded?

on FreeNAS 9.2.1.6. I noticed that the iscsi_initatiator.ko module is not in /boot/kernel in FreeNAS. I tried doing some crazy things that didn't work to load it:

  1. Download and mount FreeBSD-9.2-RELEASE-amd64-dvd1.iso or whatever FreeBSD release matches the FreeNAS release you're using (the above ISO was used with FreeNAS-9.2.1.6-RELEASE-x64.iso).
  2. Copy ISCSI_INITIATOR.KO from BOOT/KERNEL in the FreeBSD ISO to a FAT32-formatted flash drive, safely eject the flash drive from the your computer and connect it to a running FreeNAS system.
  3. In a FreeNAS shell, use mkdir /mnt/usb then mount -t msdosfs /dev/da0s1 /mnt/usb to mount the USB flash drive (your flash drive might be a different device under /dev).
  4. Use mount -uw / to mount / in read/write mode.
  5. Use cp /mnt/usb/ISCSI_INITIATOR.KO /boot/kernel/iscsi_initiator.ko to copy the initiator from the flash drive to the FreeNAS system.
  6. Use nano /conf/base/etc/rc.conf to edit the FreeNAS configuration file that persists across boots. Edit the line that reads kld_list="dtraceall if_cxgbe" to read kld_list="dtraceall if_cxgbe iscsi_initiator" and write out the file.
  7. Use mount -r / to mount / in read only mode.
  8. Shut down the FreeNAS system. Remove the USB flash drive with the ISCSI_INITIATOR.KO module and power on the FreeNAS system.
Unfortunately, this process didn't get the module to load. The changes I made to /conf/base/etc/rc.conf and to /boot/kernel persisted across reboots (which is great), but I still get the same error when I run iscontrol and kldstat -v | less does not list the iscsi_initiator at all. Perhaps the kernel has to be rebuilt to get the module to load?

I'm really trying to get this working, as I am in a similar situation (multiple iSCSI targets that I want to mount in FreeNAS). If anyone has any suggestions, I'd really appreciate them.

Thanks very much.

(Moderators, someone deleted my previous post. I'm sorry, I'm really trying to be helpful here and don't know what I did wrong. I really love FreeNAS and am trying to get this working.)
 

Nick Howard

Contributor
Joined
May 20, 2014
Messages
129
To be honest I've not got as far as yourself, I've not even had chance to download iscontrol as yet. If I get the time this weekend, I'll download it and have a play around. Although not having delved into the CLI all that often, I don't hold out much hope!
 

iSCSIinitiator

Dabbler
Joined
Jul 17, 2014
Messages
16
Thanks for your reply. I've found that FreeNAS can load modules that it comes with from the command line. For example, on a brand-new, clean FreeNAS system, I can run kldstat -v | less and see that, for example, IPMI isn't loaded. I can then do kldload ipmi and then repeat kldstat -v | less and confirm that IPMI has loaded. In this case, IPMI is included with FreeNAS and works as expected. However, when I copy over iscsi_initiator.ko as described in my post above and attempt kldload iscsi_initiator, I get an error. I've tried creating a Tunable and some other stuff, but can't ever get the initiator module to load.

I hope that there's an easy fix for this. However, I'm thinking that the only way to get this to work might be to rebuild FreeNAS from source with the iscsi_initiator module.

If anyone out there has any ideas or suggestions, it would be really helpful.

I'll update if I find anything else.

Thanks everyone.
 
Last edited:

iSCSIinitiator

Dabbler
Joined
Jul 17, 2014
Messages
16
I haven't tested all this yet, but this morning realized that I may have been on the wrong track. It looks like earlier versions of FreeNAS used the iscsi_initiator.ko module along with the iscontrol command. I was able to set up a FreeNAS 9.2.1.6 box as an iSCSI target (fully supported in the GUI), then set up a FreeBSD 9.2 box to connect to the FreeNAS iSCSI target using iscsi_initiator.ko and iscontrol. With that working, I had expected that FreeNAS 9.2.1.6 would similarly use iscontrol, as I believed that it was [mostly] based on FreeBSD 9.2. However, FreeNAS 9.2.1.6 includes some of the new CTL iSCSI stuff that's in FreeBSD 10, and Mr. Hubbard has indicated elsewhere on this message board that CTL will be the standard iSCSI base in FreeNAS 9.3.

Anyways, I was struggling to try to get iscontrol to work on FreeNAS 9.2.1.6 so that I could use FreeNAS as an iSCSI initiator, but it looks like the new method for setting up an iSCSI initiator in FreeBSD 10 uses the iscsictl command. I haven't thoroughly tested it, but this command is included in FreeNAS 9.2.1.6.

See this page

http://www.freebsd.org/doc/handbook/network-iscsi.html

for information on iSCSI in FreeBSD 10, some of which seems to apply to FreeNAS 9.2.1.6. I'm going to test more and report back, but I'm hoping that it will be possible to start an iSCSI initiator in FreeNAS 9.2.1.6 with a command like:

iscsictl -A -p 10.10.10.10 -t iqn.2012-06.com.example:target0

as documented on the above linked page.

Best of luck!
 

iSCSIinitiator

Dabbler
Joined
Jul 17, 2014
Messages
16
The following information is provided in the hope that it will be helpful, but has not been thoroughly tested. It is important to note that FreeNAS does not support running as an iSCSI initiator at the time of writing.

BACKGROUND

FreeBSD 9.2 utilizes the iscsi_initiator.ko module along with the iscontrol command to provide iSCSI initiator functionality. FreeBSD 10 incorporates new iSCSI code and uses the iscsictl command for iSCSI initiator functionality.

FreeNAS 9.2.1.6 does not include the iscsi_initiator.ko module and does include some of the new FreeBSD iSCSI code.

OVERVIEW

The following instructions will describe how to set up two FreeNAS 9.2.1.6 systems, one as an iSCSI target and the other as an iSCSI initiator. Only basic configuration is described and given that this configuration is not officially supported, it may be unstable.

MACHINES

For this example, the initiator system has one directly attached hard disk (da0) acting as the boot drive for FreeNAS 9.2.1.6. The system has IP address 10.0.1.2 on a private network connecting only the initiator and target systems.

The target system has two directly attached hard disks. Disk da0 is acting as the boot drive for FreeNAS 9.2.1.6. Disk da1 is attached but unformatted and unused. The system has IP address 10.0.1.3 on the private network connecting it to the initiator system.

Both the initiator and target systems are running clean installs of 64-bit FreeNAS 9.2.1.6 RELEASE, with no additional customizations.

PART 1 - Configuring The iSCSI Target Storage

  1. In the target machine's web interface (http://10.0.1.3 in this example), go to Storage->Volumes->ZFS Volume Manager.
  2. In the ZFS Volume Manager, enter Volume Name zfs0001 and add the single available da1 disk (the Volume layout will indicated a 1x1xDiskSize Stripe), then click Add Volume.
  3. Go to Storage->Volumes->/mnt/zfs0001->Create zvol.
  4. Enter zvol name zvol0001 and set the size of the zvol to the size of the maximum capacity zfs0001 can accommodate and click Add zvol.

PART 2 - Configuring iSCSI On The Target

  1. Go to Services->iSCSI->Extents->Add Extent.
  2. Enter Extent Name extent0001, Extent Type Device, and ensure that zfs0001/zvol0001 is selected, then click OK.
  3. Go to Services->iSCSI->Initiators->Add Initiator.
  4. In Add Initiator, click OK to allow all initiators access.
  5. Go to Services->iSCSI->Portals->Add Portal.
  6. In Add Portal, click OK.
  7. Go to Services->iSCSI->Target Global Configuration.
  8. Enter an iqn base name, for example, iqn.2014-01.org.mydomain.iscsi0001, check the Enable experimental target and the Enable multithreaded mode checkboxes, and click Save at the bottom of the page.
  9. You will be alerted that a reboot is required for experimental target mode; click Yes.
  10. When the system reboots, log back into the web interface and go to Services->iSCSI->Targets->Add Target.
  11. In Add Target, enter Target Name target0001, select Portal Group ID 1 and Initiator Group ID 1 and click OK.
  12. Go to Services->iSCSI->Targets / Extents->Add Target / Extent.
  13. In Add Target / Extent, set the Target to target0001 and the Extent to extent0001 and click OK.
  14. Go to Services->Control Services.
  15. Turn iSCSI on.
  16. Log out of the web interface and close the browser window. The iSCSI target machine should be ready.

PART 3 - Configuring The Initiator

  1. In the initiator machine's web interface (http://10.0.1.2 in this example), go to Shell.
  2. FreeNAS mounts / as read-only; to mount / with write access, enter mount -uw /
  3. The iscsictl command we're going to use to connect to the iSCSI target requires iscsid, which we need to enable. To do this, enter nano /conf/base/etc/rc.conf
  4. The configuration file should open in the nano text editor. Use the arrow keys on the keyboard to move the cursor to the end of the file, then, on a new line, enter iscsid_enable="YES" and press Control + O, then Return to write out the file. Press Control + X to exit nano.
  5. We can set up a configuration file to point the iSCSI initiator to the target. To do this, type nano /conf/base/etc/iscsi.conf
  6. In the empty nano editor add the text indicated below step 17.
  7. Press Control + O, then Return to write out the file. Press Control + X to exit nano.
  8. To set the appropriate permissions on the file, enter chmod 600 /conf/base/etc/iscsi.conf
  9. Enter mount -r / to mount / as read-only, then close the Shell.
  10. Click Reboot in the web interface and click Reboot.
  11. When the system comes back online, log in to the web interface.
  12. Go to Shell.
  13. Enter iscsictl -Aa
  14. If everything worked as it should, the initiator should have connected to the target system. To verify the connection, enter iscsictl
  15. The system should indicate that the iSCSI target is connected and that da1 is available. This means that /dev/da1 on the initiator system is actually the zvol0001 we created on the target.
  16. Close the Shell.
  17. If you go to Storage->Volumes->View Disks, you will see da1, which is on the iSCSI target. You should be able to use da1 as if it were directly attached until you shutdown or restart the computer.
Text of /conf/base/etc/iscsi.conf:

iscsi0001 {
TargetAddress = 10.0.1.3
TargetName = iqn.2014-01.org.mydomain.iscsi0001:target0001
}

End text of /conf/base/etc/iscsi.conf

NOTES

With the above configuration, at each startup, you will have to go to the shell and enter iscsictl -Aa to reconnect to the target. It should be possible to expand upon the process here to connect to additional drives on a target system and/or to multiple target systems. Based on what I have seen, it appears that presenting zvols from the target is the best method (in the past, using files was preferred, but now zvols are recommended). It should also be possible to adapt the instructions in Part 3 to connect to other (non-FreeNAS) iSCSI targets.

I have not been able to get FreeNAS to automatically connect to an iSCSI target at startup (I don't know that this has ever been possible with older versions of FreeNAS, it certainly wasn't supported).

Also, it is important to note that there is no authentication or security (e.g., CHAP) configured in the above example, so if the connection between the initiator and the target is not private, this configuration is a major security risk. It should be possible to set up CHAP, but I haven't tested it yet.

Thus far, I've found that documentation for iSCSI from FreeBSD 10 has been the most helpful in figuring out how to set up the initiator. Please be careful in using the above information and keep in mind that this sort of configuration is not supported. That being said, I am very interested to keep experimenting with this and would appreciate any suggestions or feedback others might have. I hope that this is helpful.

It's super exciting to see how powerful this software is, even when pushing it to do what it isn't meant to.

Go FreeNAS!

Thanks, everyone.
 

iSCSIinitiator

Dabbler
Joined
Jul 17, 2014
Messages
16
I've been playing around a bit more. If I add the lines

iscsictl_enable="YES"
iscsictl_flags="-Aa"


to /conf/base/etc/rc.conf in addition to the iscsid_enable="YES" line specified in the instructions above, the system will automatically connect to the iSCSI target after boot. However, there is some delay in connecting, which can cause problems.

If the iSCSI target system is online and ready to go and I then cold boot the FreeNAS system I've configured as an initiator, shortly after the system finishes booting, the initiator system spits out a message:

WARNING: 10.0.1.3 (iqn.2014-01.org.mydomain.iscsi0001:target0001): login timed out after 61 seconds: reconnecting
da1 at iscsi1 bus 0 scbus4 target 0 lun 0
da1: <FreeBSD iSCSI Disk 0123> Fixed Direct Access SCSI-5 device
da1: Serial Number **********
da1: ***MB etc.


If I wait without touching anything approximately 1 minute after the initiator finishes booting and after this message appears, I can see da1 in the web interface.

So... the initiator does automatically reconnect after boot, but not at boot, which tends to mess things up.

If anyone has any suggestions as to how I could make the system reconnect to iSCSI targets seamlessly and automatically at boot, I'd really appreciate any help. The only thing I'm modifying to get things to run at boot is /conf/base/etc/rc.conf; perhaps I need to do something else?

Thanks.
 

chopperpl

Cadet
Joined
Aug 11, 2014
Messages
6
Hello everyone!
I would like to announce that above solution works like a charm on my system. FreeNAS has no problems with reconnecting, or maintaining iscsi connectivity with the target. It also auto-reconnects after short reboots (or nightly shut downs) of the target machine. I'm using old Thecus 5200Pro as my target, and it is used for Time Machine backups.
Thank You :D
 

jianmoto

Dabbler
Joined
Jan 25, 2015
Messages
28
I've been playing around a bit more. If I add the lines

iscsictl_enable="YES"
iscsictl_flags="-Aa"


to /conf/base/etc/rc.conf in addition to the iscsid_enable="YES" line specified in the instructions above, the system will automatically connect to the iSCSI target after boot. However, there is some delay in connecting, which can cause problems.

If the iSCSI target system is online and ready to go and I then cold boot the FreeNAS system I've configured as an initiator, shortly after the system finishes booting, the initiator system spits out a message:

WARNING: 10.0.1.3 (iqn.2014-01.org.mydomain.iscsi0001:target0001): login timed out after 61 seconds: reconnecting
da1 at iscsi1 bus 0 scbus4 target 0 lun 0
da1: <FreeBSD iSCSI Disk 0123> Fixed Direct Access SCSI-5 device
da1: Serial Number **********
da1: ***MB etc.


If I wait without touching anything approximately 1 minute after the initiator finishes booting and after this message appears, I can see da1 in the web interface.

So... the initiator does automatically reconnect after boot, but not at boot, which tends to mess things up.

If anyone has any suggestions as to how I could make the system reconnect to iSCSI targets seamlessly and automatically at boot, I'd really appreciate any help. The only thing I'm modifying to get things to run at boot is /conf/base/etc/rc.conf; perhaps I need to do something else?

Thanks.
hello, I do the same things with you today. And when I reboot the freenas, I get an error with iscsi connecting:
WARNING: 10.0.1.3 (iqn.2014-01.org.mydomain.iscsi0001:target0001): login timed out after 61 seconds: reconnecting
And I wait for 1 minute, it reconnect the iscsi server and then get an error :
 

jianmoto

Dabbler
Joined
Jan 25, 2015
Messages
28
The following information is provided in the hope that it will be helpful, but has not been thoroughly tested. It is important to note that FreeNAS does not support running as an iSCSI initiator at the time of writing.

BACKGROUND

FreeBSD 9.2 utilizes the iscsi_initiator.ko module along with the iscontrol command to provide iSCSI initiator functionality. FreeBSD 10 incorporates new iSCSI code and uses the iscsictl command for iSCSI initiator functionality.

FreeNAS 9.2.1.6 does not include the iscsi_initiator.ko module and does include some of the new FreeBSD iSCSI code.

OVERVIEW

The following instructions will describe how to set up two FreeNAS 9.2.1.6 systems, one as an iSCSI target and the other as an iSCSI initiator. Only basic configuration is described and given that this configuration is not officially supported, it may be unstable.

MACHINES

For this example, the initiator system has one directly attached hard disk (da0) acting as the boot drive for FreeNAS 9.2.1.6. The system has IP address 10.0.1.2 on a private network connecting only the initiator and target systems.

The target system has two directly attached hard disks. Disk da0 is acting as the boot drive for FreeNAS 9.2.1.6. Disk da1 is attached but unformatted and unused. The system has IP address 10.0.1.3 on the private network connecting it to the initiator system.

Both the initiator and target systems are running clean installs of 64-bit FreeNAS 9.2.1.6 RELEASE, with no additional customizations.

PART 1 - Configuring The iSCSI Target Storage

  1. In the target machine's web interface (http://10.0.1.3 in this example), go to Storage->Volumes->ZFS Volume Manager.
  2. In the ZFS Volume Manager, enter Volume Name zfs0001 and add the single available da1 disk (the Volume layout will indicated a 1x1xDiskSize Stripe), then click Add Volume.
  3. Go to Storage->Volumes->/mnt/zfs0001->Create zvol.
  4. Enter zvol name zvol0001 and set the size of the zvol to the size of the maximum capacity zfs0001 can accommodate and click Add zvol.

PART 2 - Configuring iSCSI On The Target

  1. Go to Services->iSCSI->Extents->Add Extent.
  2. Enter Extent Name extent0001, Extent Type Device, and ensure that zfs0001/zvol0001 is selected, then click OK.
  3. Go to Services->iSCSI->Initiators->Add Initiator.
  4. In Add Initiator, click OK to allow all initiators access.
  5. Go to Services->iSCSI->Portals->Add Portal.
  6. In Add Portal, click OK.
  7. Go to Services->iSCSI->Target Global Configuration.
  8. Enter an iqn base name, for example, iqn.2014-01.org.mydomain.iscsi0001, check the Enable experimental target and the Enable multithreaded mode checkboxes, and click Save at the bottom of the page.
  9. You will be alerted that a reboot is required for experimental target mode; click Yes.
  10. When the system reboots, log back into the web interface and go to Services->iSCSI->Targets->Add Target.
  11. In Add Target, enter Target Name target0001, select Portal Group ID 1 and Initiator Group ID 1 and click OK.
  12. Go to Services->iSCSI->Targets / Extents->Add Target / Extent.
  13. In Add Target / Extent, set the Target to target0001 and the Extent to extent0001 and click OK.
  14. Go to Services->Control Services.
  15. Turn iSCSI on.
  16. Log out of the web interface and close the browser window. The iSCSI target machine should be ready.

PART 3 - Configuring The Initiator

  1. In the initiator machine's web interface (http://10.0.1.2 in this example), go to Shell.
  2. FreeNAS mounts / as read-only; to mount / with write access, enter mount -uw /
  3. The iscsictl command we're going to use to connect to the iSCSI target requires iscsid, which we need to enable. To do this, enter nano /conf/base/etc/rc.conf
  4. The configuration file should open in the nano text editor. Use the arrow keys on the keyboard to move the cursor to the end of the file, then, on a new line, enter iscsid_enable="YES" and press Control + O, then Return to write out the file. Press Control + X to exit nano.
  5. We can set up a configuration file to point the iSCSI initiator to the target. To do this, type nano /conf/base/etc/iscsi.conf
  6. In the empty nano editor add the text indicated below step 17.
  7. Press Control + O, then Return to write out the file. Press Control + X to exit nano.
  8. To set the appropriate permissions on the file, enter chmod 600 /conf/base/etc/iscsi.conf
  9. Enter mount -r / to mount / as read-only, then close the Shell.
  10. Click Reboot in the web interface and click Reboot.
  11. When the system comes back online, log in to the web interface.
  12. Go to Shell.
  13. Enter iscsictl -Aa
  14. If everything worked as it should, the initiator should have connected to the target system. To verify the connection, enter iscsictl
  15. The system should indicate that the iSCSI target is connected and that da1 is available. This means that /dev/da1 on the initiator system is actually the zvol0001 we created on the target.
  16. Close the Shell.
  17. If you go to Storage->Volumes->View Disks, you will see da1, which is on the iSCSI target. You should be able to use da1 as if it were directly attached until you shutdown or restart the computer.
Text of /conf/base/etc/iscsi.conf:

iscsi0001 {
TargetAddress = 10.0.1.3
TargetName = iqn.2014-01.org.mydomain.iscsi0001:target0001
}

End text of /conf/base/etc/iscsi.conf

NOTES

With the above configuration, at each startup, you will have to go to the shell and enter iscsictl -Aa to reconnect to the target. It should be possible to expand upon the process here to connect to additional drives on a target system and/or to multiple target systems. Based on what I have seen, it appears that presenting zvols from the target is the best method (in the past, using files was preferred, but now zvols are recommended). It should also be possible to adapt the instructions in Part 3 to connect to other (non-FreeNAS) iSCSI targets.

I have not been able to get FreeNAS to automatically connect to an iSCSI target at startup (I don't know that this has ever been possible with older versions of FreeNAS, it certainly wasn't supported).

Also, it is important to note that there is no authentication or security (e.g., CHAP) configured in the above example, so if the connection between the initiator and the target is not private, this configuration is a major security risk. It should be possible to set up CHAP, but I haven't tested it yet.

Thus far, I've found that documentation for iSCSI from FreeBSD 10 has been the most helpful in figuring out how to set up the initiator. Please be careful in using the above information and keep in mind that this sort of configuration is not supported. That being said, I am very interested to keep experimenting with this and would appreciate any suggestions or feedback others might have. I hope that this is helpful.

It's super exciting to see how powerful this software is, even when pushing it to do what it isn't meant to.

Go FreeNAS!

Thanks, everyone.
hello, I do the same things with you today.
But I get the error.My freenas can't boot with the iscsictl time and time again to reconnect. And post the error each time:
freenas iscsid[2161]: 10.0.0.3(iqn.2011-03.org.example.istgt:mytarget): failed to connect to 10.0.0.3: Permission denied.

The version of my freenas is 9.3-stable
and if I don't add "iscsictl_enable="YES" iscsictl_flags="-Aa"" into /etc/rc.conf file ,It will boot successful. and the I run the command "iscsictl -Aa" ,it work with no error.

Is anyone know what mistake that I had made?
 

jianmoto

Dabbler
Joined
Jan 25, 2015
Messages
28
Hello everyone!
I would like to announce that above solution works like a charm on my system. FreeNAS has no problems with reconnecting, or maintaining iscsi connectivity with the target. It also auto-reconnects after short reboots (or nightly shut downs) of the target machine. I'm using old Thecus 5200Pro as my target, and it is used for Time Machine backups.
Thank You :D
I try freenas9.2.1.6 today. I met the same problem…
the system reconnect the iscsi server successful after boot completely,and the volumes create by this iscsi disk post an error.
What I do is :
1.flesh install freenas9.2.1.6
2.login into the shell and type :mount -uw /
3.vi /conf/base/etc/rc.conf and type
iscsid_enable="YES"
iscsictl_enable="YES"
iscsictl_flags="-Aa"
save and exit
4. vi /conf/base/etc/iscsi.conf
target01{
TargetAddress=192.168.1.107
TargetName =iqn.2011-03.org.example.org.istgt:mytarget
AuthMethod=CHAP
chapIName=testiscsi
chapSecret=123456789012
}
4.reboot the system.
5.login the webUI. And create a volume with the disk.
6.reboot the system.
 
Last edited:

thewizard231

Cadet
Joined
Jun 18, 2018
Messages
4
FreeNAS 11.1

I've set it up with the following, confirmed working for build "FreeNAS-11.1-U5" with all glitches fixed and done properly, to the best of my understanding.
Please confirm or note otherwise.

Setup
  1. edit "/conf/base/etc/ix.rc.d/ix-zfs", add "iscsictl" to "# REQUIRE:" line
    Original (line 7):
    Code:
    # REQUIRE: hostid mountcritlocal


    New (line 7):
    Code:
    # REQUIRE: hostid mountcritlocal iscsictl


  2. edit "/conf/base/etc/ipfw.conf.block", remove deny port 3260
    Original (line 4):
    Code:
    /sbin/ipfw -q add 00501 deny tcp from any to any dst-port 111,548,2049,137,138,139,860,3260

    New (line 4):
    Code:
    /sbin/ipfw -q add 00501 deny tcp from any to any dst-port 111,548,2049,137,138,139,860


  3. In web ui, go to "System" --> "Tunables" --> add following three rc.conf configurations ('enabled'):
    1. Variable: iscsid_enable; Value: YES; Type: rc.conf
    2. Variable: iscsictl_enable; Value: YES; Type: rc.conf
    3. Variable: iscsictl_flags; Value: -Ad <iscsi target's ip>; Type: rc.conf
      '3' above uses a "discovery" session vs. <iscsi target's ip> and creates a session for each discovered target.
      An alternative to above '3' is to create "/conf/base/etc/iscsi.conf" file with required iscsictl configuration for exact targets configurations, possibly with authentication, chap, etc., then change the Value in '3' to -Aa (which by defaults creates a session for everything defined in (by default) /etc/iscsi.conf.; another alternative if one doesn't want (or need) to create that file but wants exact target sessions, then use "-At <iqn.xxx> -p <target ip>" ,etc.
  4. In web ui, go to "Tasks" --> "Init/Shutdown Scripts" --> add the following shutdown command:
    1. Type: command; Command: zpool export <pool name created in "Storage" --> "Volumes" [the top most]>
      If still encountering problems in reboot/poweroff, add "-f" to the command. unfortunately that's my current workaround for that bug.

Details

  • ix-zfs is freenas' way to create enteries for it's volume's mount at boot, it must run after iscsictl to see our iscsi initiator's devices.
  • ipfw blocks iscsi only on bootup, which causes an infinite loop of iscsid retries when it gets to that part (after successfully connecting [iscsictl] before), so here allow this.
  • the GUI configurations are just to enable it as explained above, except the last, 4th one, this one is a work-around a bug in freebsd (hadn't found the source for) which prevents reboot/shutdown as it hangs after syncing disks (did kern.iscsi.debug, etc. and saw it continues and frees correctly the device after it, etc. but at some point it stops), doing this allows proper reboot/shutdown.
 
Last edited:

thewizard231

Cadet
Joined
Jun 18, 2018
Messages
4
Yeah, about the path.. apologies, corrected.

I wrote step 4's explanation in the third '*', it's a workaround freebsd zfs on iscsi supposedly bug. Hadn't went all the way to thoroughly investigate what happens inside, kernel, etc. I know sometimes after correct iscsi release on shutdown, in kernel space, it blocks.

Exporting does unmount of that filesystem on post so doesn't get there.
 

fourstone77

Cadet
Joined
Jun 19, 2018
Messages
2
one more thing as I am just testing this setup:
I found that iscsid_enable needs to be set for this to work to some extent, currently the mount does not work smoothly upon starting the freeenas machine.

Maybe the problem is with the Synology NAS which delivers these iSCSI volumes. Before you ask, the reason for this is deploying a remote synology box and syncing zfs snapshots there. iSCSI seemed the easiest way in theory.
 
Last edited:

thewizard231

Cadet
Joined
Jun 18, 2018
Messages
4
Thanks for the debugging. Of course iscsid_enable.

That's another typo. Fixed.

I have it also working as described.

one last thing, if it does still get stuck on poweroff/reboot. add "-f" to '4' command to force the unmount.
unfortunately that's my current workaround as going further to understand it requires kernel debugging the freebsd to see what's up.
 
Last edited:

sjalife

Cadet
Joined
Aug 6, 2019
Messages
2
Hi,

While working on the CLI is fine, what would be the difference if I just setup a PRE INIT command or script under the Tasks section with the
iscsictl declaration?
 

sjalife

Cadet
Joined
Aug 6, 2019
Messages
2
FreeNAS 11.1

Variable: iscsictl_flags; Value: -Ad <iscsi target's IP>; Type: rc.conf
'3' above uses a "discovery" session vs. <iscsi target's IP> and creates a session for each discovered target.
An alternative to above '3' is to create "/conf/base/etc/iscsi.conf" file with required iscsictl configuration for exact targets configurations, possibly with authentication, chap, etc., then change the Value in '3' to -Aa (which by defaults creates a session for everything defined in (by default) /etc/iscsi.conf.; another alternative if one doesn't want (or need) to create that file but wants exact target sessions, then use "-At <iqn.xxx> -p <target IP>" ,etc

Can I use BOTH -Aa for known iSCSI targets and then -Ad to get flexible discovery of Targets as they are changed / added on the remote iSCSI controller?
 
Top