AlpineLinux 3.8: Install open-iscsi for iSCSI initiator

Table of Contents

1 Install open-iscsi

Install open-iscsi package.

$ sudo apk add open-iscsi$ sudo rc-update add iscsid$ sudo rc-service iscsid start

2 Connect to iSCSI target with iscsiadm

Connect to iSCSI target with iscsiadm.

$$$ sudo iscsiadm -m discovery -t st -p “${ISCSI_TARGET_PORTAL}”,1$ sudo iscsiadm -m node –targetname “${ISCSI_TARGET_NAME}” -p “${ISCSI_TARGET_PORTAL}” -lLogging in to [iface: default, target:,portal:,3260] (multiple)Login to [iface: default, target:,portal:,3260] successful.

3 Mount iSCSI target device on boot

Change node.startup to automatic in /etc/iscsi/iscsid.conf.

$ sudo sed -e ‘s/^node.startup = manual/node.startup = automatic/g’ -i /etc/iscsi/iscsid.conf

Connect to iSCSI target. If you have connected to iSCSI target before changing node.startup to automatic, you need to connect to iSCSI target again after changing node.startup to automatic.

$ sudo iscsiadm -m discovery -t st -p “${ISCSI_TARGET_PORTAL}”$ sudo iscsiadm -m node –targetname “${ISCSI_TARGET_NAME}” -p “${ISCSI_TARGET_PORTAL}” -l

Create filesystem on iSCSI target device with fdisk and mkfs.

$ ISCSI_TARGET_DEV=/dev/sda$ cat <<EOF | sudo fdisk ${ISCSI_TARGET_DEV}np1wEOF$ sudo mkfs.ext4 ${ISCSI_TARGET_DEV}1

Add mount entry to /etc/fstab. For avoiding mounting before network initialization, you need to add _netdev option.

$ uuid=$(sudo blkid | grep “^${ISCSI_TARGET_DEV}1:” | sed -e ‘s/.* UUID=”([^”]*)”.*/1/g’)$ cat <<EOF | sudo tee -a /etc/fstabUUID=${uuid} /mnt ext4 _netdev 0 0EOF$ sudo rc-update add netmount

Android | Linux | SDL - Narrow Escape