# Maximum number of iSCSI targets in FreeBSD10



## walterheukels (Apr 7, 2014)

Hi,

I've been looking into using FreeBSD as a storage platform for large numbers of iSCSI volumes. I've got things working quite smoothly with ctld exporting zvol's, but it seems I can only create 256 targets before I run into the following message:


```
Apr  2 17:03:42 kickpuncher kernel: ctl: can't allocate LUN on target 0, out of LUNs
Apr  2 17:03:42 kickpuncher ctld[2667]: error returned from LUN creation request: ctl_be_block_create: LUN configuration error, see dmesg for details
```

Is this an inherent limitation, or am I doing something wrong?


----------



## SirDice (Apr 7, 2014)

As far as I know this is a limitation of iSCSI, there are only 8 bits available for the LUN. But you should be able to define more targets, each with 255 LUNs.


----------



## walterheukels (Apr 8, 2014)

SirDice said:
			
		

> But you should be able to define more targets, each with 255 LUNs.



That's what I would have thought.  My ctld.conf looks like this:

```
target iqn.2012-06.com.example:volume-1 {
        auth-group no-authentication
        portal-group pg0
        lun 0 {
                path /dev/zvol/test/volume-1
        }
}

target iqn.2012-06.com.example:volume-2 {
        auth-group no-authentication
        portal-group pg0
        lun 0 {
                path /dev/zvol/test/volume-2
        }
}
```

... and so on.

`ctladm devlist` shows this:


```
LUN Backend       Size (Blocks)   BS Serial Number    Device ID       
  0 block                  2048  512 MYSERIAL   0     MYDEVID   0     
  1 block                  2048  512 MYSERIAL   1     MYDEVID   1     
  2 block                  2048  512 MYSERIAL   2     MYDEVID   2     
  3 block                  2048  512 MYSERIAL   3     MYDEVID   3     
  4 block                  2048  512 MYSERIAL   4     MYDEVID   4     
  5 block                  2048  512 MYSERIAL   5     MYDEVID   5     
  ...
```

so it looks like LUN's are being numbered automatically.


----------



## SirDice (Apr 8, 2014)

I know enough about iSCSI to get it working and the problem you mentioned is an interesting one. I can imagine, especially with big storage servers, the need to have more than 255. Hopefully somebody with more iSCSI knowledge knows how to deal with that.

While searching for an answer I did find it's not specific to FreeBSD, it seems Windows suffers from the same limitations.


----------



## walterheukels (Apr 8, 2014)

FYI, I've switched to istgt now, which is working fine.  I'm guessing this is a kernel limitation then.


----------



## SirDice (Apr 8, 2014)

walterheukels said:
			
		

> FYI, I've switched to istgt now, which is working fine.  I'm guessing this is a kernel limitation then.


That's interesting. The ctld(8) is a new addition to FreeBSD 10.0, it's probably not complete yet. Hopefully that will be corrected with the next version.


----------



## da1 (Apr 25, 2014)

Maybe submit a bug?


----------



## trasz@ (Aug 4, 2014)

For various reasons the maximum number of LUNs - globally, which means it also limits the number of targets - is hardcoded, see http://svnweb.freebsd.org/base/head/sys ... markup#l63.


----------



## trasz@ (Aug 4, 2014)

I'm wondering, what would be a sensible limit? @walterheukels, how many do you need?


----------

