Building and connecting an iSCSI disk, using ZFS volume for the storage backend.
Vocabulary
- iSCSI Qualified Name (IQN)
-
IQN is the ISCSI name, it refers both to the target and to the initiator, it is composed of 4 elements: the type (here iqn), date of creation of the naming authority, naming authority (the domain name whose terms are reversed), the name assigned by the authority.
1 2 3 4
Type Date Naming Auth Name defined by authority +--++-----+ +---------+ +--------------------------------+ | || | | | | | iqn.2001-04.com.example:storage
- Target
-
This is the server, it provides access to the LUN (Logical Unit Number) resources representing storage space.
- Initiator
-
It can be regarded as the client, it’s the part that will connect to the target to obtain a LUN on which to perform the read/write operations.
- Portal
-
It’s the set of IP address and port number on which the target is listening.
- Autodiscovery
-
This is the process where the initiator requests to the portal the list of available targets.
Target
We create a ZFS dataset dedicated as storage backend for iscsi
volumes, so that properties can be inherited by its children dataset,
in particular we set the volmode
to dev
to avoid importing the created device into the server host.
1 2 3 4 |
|
When creating the device used as storage for iSCSI, it it possible
to select a few options, such as sparse volume (-s
) and
blocksize (-b
)
1 2 |
|
We will use the native FreeBSD implementation ctld
,
but other are available using ports/packages such as such as
iscsi-target
and istgt
.
In the following example the targets are shared with whoever is able to
authenticate.
- The Microsoft initiator (silently) imposes the use of a password of at least 12 characters.
- No encryption is done on the network protocol itself
- Not everyone support a 4k-blocksize target, for example it is not possible to boot from iPXE with it.
Initiator
The initiator is controlled by the iscsid
daemon, it is necessary
to have it started to manage iscsi sessions (adding or removal of iscsi volume)
It is not necessary to have an iscsi.conf
file to create or add
iscsi session, it can be done on the fly using the
iscsictl
command.
But the iscsi.conf
is a convenient way to store the configuration.
- The
iscsi.conf
store unencrypted password, it is important to ensure that the file permissions are set responsibly (usually0600
).
Usually iscsi session are started automatically during boot-up
(see: iscsictl_enable
), but it is also possible to manage them
manually with the iscsictl
command, some examples below:
1 2 3 |
|
The content of the disk can be protected, by encrypting it.
For that, the geli
module can be used on FreeBSD:
1 2 |
|