# istgt or iscsi_target with 4k drive



## stefarossi (Oct 9, 2013)

Hello,

I'm trying to setup istgt or iscsi_target with a GELI encrypted device. The problem is that the drive is a 4K sector drive.


```
# geli list
Geom name: ada1p3.eli
State: ACTIVE
EncryptionAlgorithm: AES-XTS
KeyLength: 128
Crypto: software
UsedKey: 0
Flags: NONE
KeysAllocated: 698
KeysTotal: 698
Providers:
1. Name: ada1p3.eli
   Mediasize: 2995224162304 (2.7T)
   Sectorsize: 4096
   Mode: r0w0e0
Consumers:
1. Name: ada1p3
   Mediasize: 2995224166400 (2.7T)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r1w1e1
```

I'm getting errors with both:

```
Oct  9 01:39:33 NAS istgt[1356]: istgt_lu_disk.c: 330:istgt_lu_disk_allocate_raw: ***ERROR*** lu_disk_read() failed
Oct  9 01:39:33 NAS istgt[1356]: istgt_lu_disk.c: 650:istgt_lu_disk_init: ***ERROR*** LU1: LUN0: allocate error
Oct  9 01:39:33 NAS istgt[1356]: istgt_lu.c:2091:istgt_lu_init_unit: ***ERROR*** LU1: lu_disk_init() failed
Oct  9 01:39:33 NAS istgt[1356]: istgt_lu.c:2166:istgt_lu_init: ***ERROR*** LU1: lu_init_unit() failed
Oct  9 01:39:33 NAS istgt[1356]: istgt.c:2799:main: ***ERROR*** istgt_lu_init() failed
Oct  9 01:39:33 NAS root: /usr/local/etc/rc.d/istgt: WARNING: failed to start istgt
Oct  9 01:50:41 NAS iscsi-target: pid 1440:disk.c:675: ***ERROR*** error reading "target0"
Oct  9 01:50:41 NAS iscsi-target: pid 1440:disk.c:807: ***ERROR*** error allocating space for "target0"
Oct  9 01:50:41 NAS iscsi-target: pid 1440:target.c:1553: ***ERROR*** device_init() failed
Oct  9 01:50:41 NAS iscsi-target: pid 1440:iscsi-target.c:145: ***ERROR*** target_init() failed
Oct  9 01:50:41 NAS root: /usr/local/etc/rc.d/iscsi_target: WARNING: failed to start iscsi_target
```
I know the problem is the sector size, because trying with a testfile works.

```
Geom name: md0.eli
State: ACTIVE
EncryptionAlgorithm: AES-XTS
KeyLength: 128
Crypto: software
UsedKey: 0
Flags: NONE
KeysAllocated: 1
KeysTotal: 1
Providers:
1. Name: md0.eli
   Mediasize: 524287488 (500M)
   Sectorsize: 512
   Mode: r0w0e0
Consumers:
1. Name: md0
   Mediasize: 524288000 (500M)
   Sectorsize: 512
   Mode: r1w1e1
```
With md0.eli they both start up fine. How do I tell one of the two that the drive is a 4K one?
Thanks.


----------



## Sebulon (Oct 10, 2013)

Like this with net/istgt:

/usr/local/etc/istgt/istgt.conf

```
[LogicalUnitX]
    BlockLength              4096
```

HTH!

/Sebulon


----------



## stefarossi (Oct 15, 2013)

Sebulon said:
			
		

> Like this with net/istgt:
> 
> /usr/local/etc/istgt/istgt.conf
> 
> ...


Worked perfectly. Thanks!


----------

