# iSCSI on FreeBSD 10



## ilemur (Jun 8, 2014)

Seems as this stuff is pretty new - no detailed HowTo is available so I ran into some problems. Running a virtualised FBSD FreeBSD I want to pass a simple ZFS back to ESXi 5.5 as a datastore. So at first *I* created:

```
#zpool create esxistore mirror da1 da2 mirror da3 da4
#zfs create esxistore/store
```

Then I touched and made a ctl.conf:

```
debug 5

portal-group pg0 {
        discovery-auth-group no-authentication
        listen 0.0.0.0
        listen [::]
}

target iqn.2013-10.com.example:target0 {
        auth-group no-authentication
        portal-group pg0

        lun 0 {
        path /esxistore/store
        }
}
```

Upon starting *I* just get errors in logs like:

```
Jun  8 21:58:18 bsdstore ctld[50189]: error returned from LUN creation request: ctl_be_block_open: error opening /esxistore/store
Jun  8 21:58:18 bsdstore ctld[50189]: failed to add lun 0, target iqn.2013-10.com.example:target0
Jun  8 21:58:18 bsdstore ctld[50189]: failed to apply configuration, exiting
```

What am *I* missing?


----------



## Oko (Jun 8, 2014)

FreeNAS supports iSCSI and is based on FreeBSD 9.2 so it can't be that new. I just recently got interested in iSCSI so I am following your thread with great interest.


----------



## CliffJ (Jun 8, 2014)

I'm not an expert but I got my setup working by creating a file of specific size with truncate and this is what is pointed to in the lun section. There was also a matching size statement in the lun section*.*


----------



## trasz@ (Aug 4, 2014)

The problem above is that the "path" needs to point to a file, or a device, while in your case it points to directory.


----------



## jem (Aug 7, 2014)

As the previous poster said.

Create a zvol on your pool, then point ctld at the corresponding /dev/zvol/... device


----------



## usdmatt (Aug 7, 2014)

> Running a virtualised FreeBSD I want to pass a simple ZFS back to ESXi 5.5 as a datastore



Is this VM running on the ESXi5.5 host? Having a FreeBSD VM, creating an iSCSI export, then mounting it on the ESXi host to use as a datastore for other VMs seems a bit of an awkward configuration... (unless it's just for testing)

Anyway, you have created a ZFS filesystem, mounted on /esxistore/store. This isn't NFS, iSCSI exports block devices, not filesystems.
You need to create a block device for the iSCSI service to use. With ZFS you have two options:

1) Create a ZFS block device (ZFS volume)

```
# zfs create -sV 1T esxistore/store (you'd need to delete the existing filesystem or call this volume something else)
```
This -V 1T option here tells it to create a 1 terabyte ZFS volume, and the -s tells it to make the volume sparse, so it will only start using pool space as it fills up. Without the -s it will immediately claim 1 terabyte of you pool space.

This will create a block device node on the system at /dev/zvol/esxistore/store, which is what you should use as the path in the iSCSI configuration.

2) The iSCSI service also supports using a file as a block device, so you could do the following

```
# cd /esxistore/store (assuming this filesystem still exists)
# truncate -s 1T vmdata.img
```
In this case you would use /esxistore/store/vmdata.img as the path in the iSCSI configuration. This is a sparse file so it will show as 1T in `ls -h`. However, if you run `du -h` in that directory, you will see the actual space being used.


----------

