Before you begin, open the command line and ensure you have installed the open-iscsi
utility.
To install the utility on an Ubuntu/Debian distribution, enter command sudo apt update && sudo apt install open-iscsi
.
After the installation completes, ensure the iscsid service is running using the sudo service iscsid start
command.
First, with the iscsid service started, run the iscsiadm
command with the discovery arguments and get the necessary information to connect to the share.
Next, discover and log into the iSCSI share.
-
Run the command sudo iscsiadm \--mode discovery \--type sendtargets \--portal {IPADDRESS}
.
The output provides the basename and target name that TrueNAS configured.
Alternatively, enter sudo iscsiadm -m discovery -t st -p {IPADDRESS}
to get the same output.
Note the basename and target name given in the output. You need them to log in to the iSCSI share.
When a Portal Discovery Authentication Method is CHAP, add the three following lines to /etc/iscsi/iscsid.conf.
discovery.sendtargets.auth.authmethod = CHAP
discovery.sendtargets.auth.username = user
discovery.sendtargets.auth.password = secret
The user for discovery.sendtargets.auth.username
is set in the Authorized Access used by the iSCSI share Portal.
Likewise, the password to use for discovery.sendtargets.auth.password
is the Authorized Access secret.
Without those lines, the iscsiadm does not discover the portal with the CHAP authentication method.
-
Enter comand sudo iscsiadm \--mode node \--targetname {BASENAME}:{TARGETNAME} \--portal {IPADDRESS} \--login
,
where {BASENAME} and {TARGETNAME} is the discovery command information.
Now you partition an iSCSI disk.
When the iSCSI share login succeeds, the device shared through iSCSI shows on the Linux system as an iSCSI Disk.
To view a list of connected disks in Linux, enter command sudo fdisk -l
.
Because the connected iSCSI disk is raw, you must partition it.
Identify the iSCSI device in the list and enter sudo fdisk {/PATH/TO/iSCSIDEVICE}
.
Shell lists the iSCSI device path in the sudo fdisk -l
output.
Use the fdisk
command defaults when partitioning the disk.
Remember to type w when finished partitioning the disk.
The w
command tells fdisk
to save any changes before quitting.
After creating the partition on the iSCSI disk, a partition slice displays on the device name.
For example, /dev/sdb1.
Enter fdisk -l
to see the new partition slice.
Next, make a file system on the iSCSI disk.
Finally, use mkfs
to make a file system on the new partition slice.
To create the default file system (ext2), enter sudo mkfs {/PATH/TO/iSCSIDEVICEPARTITIONSLICE}
.
Mount the iSCSI device and share the data.
Enter sudo mount {/PATH/TO/iSCSIDEVICEPARTITIONSLICE}
.
For example, sudo mount /dev/sdb1 /mnt
mounts the iSCSI device /dev/sdb1 to file /mnt.