The Linux target framework (tgt) is a user space SCSI target framework that supports the iSCSI and iSER transport protocols and that supports multiple methods for accessing block storage. tgt consists of user-space daemon and tools. Being a user space server, it does not require a kernel module to run. In Alpine Linux, the package is called scsi-tgt
In Alpine, scsi-tgt is split over several packages:
Only scsi-tgt is required to run the tgt target daemon. A running daemon can be configured with tgtadm command line tool. However, if you want to use configuration files you need the tgt-admin helper tool, which reads the config and emits appropriate tgtadm commands. The tgt-admin tool is written in perl, and so depends on perl being installed, which is why we have it as a separate package.
This guide assumes that you want to configure iSCSI targets via a configuration file, and have it automatically start during boot.
To install scsi-tgt and the utilities to configure tgt:
# apk add scsi-tgt scsi-tgt-scripts
Note: Note that without setting up the configuration file /etc/tgt/targets.conf first, the tgtd daemon will run with an empty configuration
Once you have editited the configuration file, you can activate the service with
# rc-update add tgt-admin
# service tgt-admin start
Here is an example configuration for exporting a local image file as a iSCSI target (virtual SCSI disk):
Contents of /etc/tgt/conf.d/iscsi.conf
# tgt-admin configuration file
## By default, tgt-admin looks for its config file in /etc/tgt/targets.conf
# Set the driver. If not specified, defaults to "iscsi".
## Define a target
# iSCSI naming convention for iqn format:
## General settings
## iSCSI features
## Access control
incominguser user1 secretpass12
## iSCSI targets (exports)
params thin_provisioning=1 rotation_rate=0 sense_format=1
tgt-admin is a convenience script to configure the running tgtd daemon. It is not needed if you want to manually configure tgtd using the tgtadm tool.