# ctld will not start



## edkitconsulting (Mar 23, 2014)

I am testing a new RAIDZ setup and was going to do a quick test of NFS and iSCSI speeds. 

This is my basic ctl.conf file:


```
portal-group pg0 {
  discovery-auth-group no-authentication
    listen 0.0.0.0
}

target iqn.2011-05.local.towncountrybank:target0 {
  auth-group no-authentication
    portal-group pg0

    lun 0 {
        path storage/iscsi/testvdi0-0
         size 32212254720
    }
}
```

When I try to start the ctld service, I get the following message:


```
Starting ctld.
ctld: /etc/ctl.conf is world-readable
```

When checked, ctld has not started. I know I should really limit the portal network and use CHAP, but I'm just testing, this is not production. 

Anyone ran into this? Its a brand new installation of FreeBSD 10.0.

Thank you for your time,

Ed


----------



## usdmatt (Mar 23, 2014)

I can't comment on the iSCSI configuration but the error above seems pretty obvious. It doesn't like the fact that /etc/ctl.conf is readable by any user. Not sure what the exact permissions of this file should be be the following is probably close enough:


```
chmod 640 /etc/ctl.conf
```


----------



## edkitconsulting (Mar 23, 2014)

I apologize, I am newer to BSD. I have been a desktop user of linux for awhile, and administer BSD based products (FreeNAS, Netapp, IBM V Series), so I am trying to skill up on FreeBSD. 

I will change the permissions and try again.

EDIT: That cured the "World-Readable" error, but the service will still not start. Is there an error log for the services or ctld specifically?


----------



## edkitconsulting (Mar 23, 2014)

Here are the errors in the logs


```
Mar 23 14:41:00 TC-EDK-BSD ctld[2185]: error returned from LUN creation request: ctl_be_block_open: error opening /storage/iscsi/testvdi/
Mar 23 14:41:00 TC-EDK-BSD ctld[2185]: failed to add lun 0, target iqn.2011-05.local.towncountrybank:target0
Mar 23 14:41:00 TC-EDK-BSD ctld[2185]: failed to apply configuration, exiting
Mar 23 14:41:02 TC-EDK-BSD root: /etc/rc.d/dhclient: ERROR: /etc/rc.d/dhclient: no interface specified
```

The zvol exists...Im not sure where the issue is...


----------



## Sebulon (Mar 24, 2014)

Hi @edkitconsulting!

Yes, the ZVOL exists but not at that path, try this path instead:

/dev/zvol/storage/iscsi/testvdi0-0

/Sebulon


----------



## Avery Freeman (Oct 23, 2017)

mine works on root zvol location - not sure why theirs wouldn't (?)
don't forget to make file before starting ctld

```
# dd if=/dev/zero of=/path/to/zvol/nameoflunfile bs=1 count=0 seek=15G
```
with 15G being an example size of however large you made the setting in your /etc/ctld.conf file. Then

```
# service ctld start
```


----------



## usdmatt (Oct 24, 2017)

> mine works on root zvol location - not sure why theirs wouldn't (?)



Because that would be completely the wrong path. It sounds like you are not using a ZVOL at all.

If you create a ZFS filesystem such as pool/fs, by default it will be mounted at /pool/fs. You could then create a sparse file such as /pool/fs/mylun.dat and use that in your ctld configuration. (It's also easier to use truncate() to create sparse files).

However, most people don't do that. It's common for people to create ZVOL devices for iSCSI. When you create a ZVOL it appears on the system as a block device under /dev/zvol. If you create pool/myzvol, it will appear on the system as a block/disk device called /dev/zvol/pool/myzvol.

Using a ZVOL does make sense if you are using something like iSCSI that works on block devices. You'd expect it to be quicker as ZFS is only providing basic block storage, and you are skipping all the ZFS file system code. ZVOLs used to be a bit buggy on FreeBSD although that was a while ago now.



> don't forget to make file before starting ctld



If you're using ZVOLs then you do not need to create a sparse file.


----------

