These are some basic snippets for using scst on Linux.
A basic configuration to export a file as an iSCSI target can look like this:
# Define a list of devices that will be served
HANDLER vdisk_fileio {
# File backed iSCSI device
DEVICE my-iscsi-device {
filename /storage/block/my-target.iscsi
}
}
# Define a list of iSCSI targets that reference the above devices
TARGET_DRIVER iscsi {
enabled 1
# iSCSI target configuration
TARGET iqn.2019-05.com.domain.server-hostname:mytarget {
IncomingUser "username password"
enabled 1
LUN 0 my-iscsi-device
}
}
To create the file that scst will serve from, truncate
can be used:
truncate -s 1T my-target.iscsi
Edit the /etc/scst.conf
configuration file. Once done, reload the configuration:
scstadmin -config /etc/scst.conf
To list currently configured devices:
scstadmin -list_device
To list currently configured targets:
scstadmin -list_target
First remove the target:
scstadmin -rem_target iqn.2019-05.com.domain.server-hostname:mytarget -driver iscsi
Then the device can be closed/removed:
scstadmin -close_dev my-iscsi-device -handler vdisk_fileio