Configuring iSCSI Disks in Curtin

Install Open-iSCSI package by running this command:

# This script installs the Open-iSCSI package using the apt command with sudo privileges.

# Install Open-iSCSI package
sudo apt install open-iscsi

# The sudo command allows the user to run commands with root privileges.
# The apt command is used to manage packages on Debian-based systems.
# The install option is used to install a new package.
# The open-iscsi package is a tool for managing iSCSI storage devices.

2. Configure the main configuration file `/etc/iscsid.conf` with your iSCSI target details, as shown below:

#!/bin/sh

# This script configures the main configuration file for iSCSI, located at /etc/iscsid.conf.
# It is important to properly configure this file with your iSCSI target details.

# Set the startup settings for iscsid and node.
# These settings will be controlled by systemd and should be left as is.
iscsid.startup = /usr/sbin/iscsid
node.startup = manual

# Configure CHAP settings for authentication.
# Uncomment the following lines to enable CHAP authentication.
# Replace "username" and "password" with your actual credentials.
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password
discovery.sendtargets.auth.authmethod = CHAP
discovery.sendtargets.auth.username = username
discovery.sendtargets.auth.password = password

# Configure timeouts for iSCSI.
# These settings control how much time iSCSI takes to propagate an error to the upper layer.
# If using multipath, additional settings may be required.
# Uncomment and modify the following lines as needed.
# node.conn[0].timeo.noop_out_interval = 5
# node.conn[0].timeo.noop_out_timeout = 5
# node.session.timeo.replacement_timeout = 120
# node.session.err_timeo.abort_timeout = 15
# node.session.err_timeo.lu_reset_timeout = 30
# node.session.err_timeo.tgt_reset_timeout = 30

# Note: It is important to properly configure the timeouts for your specific setup to ensure optimal performance and error handling.

Replace `node.session.auth.authmethod`, `node.session.auth.username`, and `node.session.auth.password` with your iSCSI target details.

3. Configure the initiator name file `/etc/iscsi/initiatorname.iscsi` to include your iSCSI target’s IP address, as shown below:

# /etc/iscsi/initiatorname.iscsi
# This script is used to configure the initiator name file for iSCSI connections.

# Set the authentication method for the iSCSI session.
node.session.auth.authmethod = CHAP

# Set the username for the iSCSI session.
node.session.auth.username = <insert username here>

# Set the password for the iSCSI session.
node.session.auth.password = <insert password here>

# Configure the initiator name file to include the iSCSI target's IP address.
# This allows the initiator to connect to the target.
InitiatorName=<insert initiator name here>

# Set the target IQN for the iSCSI session.
node.target.iqn.2020-07.example.com:lun1 (non-flash)

Replace `iqn.2020-07.example.com:lun1` with your iSCSI target’s details.

4. Restart the iscsid service to apply changes, as shown below:

# This script restarts the iscsid service to apply changes made to the iSCSI target's details.

# Restart the iscsid service using the systemctl command.
sudo systemctl restart iscsid

# Ensure that the changes have been applied by checking the response.
# The response should include a confirmation that the service has been restarted.
# If the response does not include this confirmation, there may be an error.
# In that case, further troubleshooting may be necessary.

5. Verify that the shared device has been detected by running this command:

# This script is used to verify if a shared device has been detected by running the 'lsblk' command.

# The 'lsblk' command lists information about all available block devices, including shared devices.

# The following line executes the 'lsblk' command.
lsblk

6. Create a file system on the shared device (`sdb`) with the following commands:

# Use sudo to run the following command as root user
sudo fdisk /dev/sdb
# Follow the prompts to create a new partition of type 'Linux' and size 999 MiB.
# This command creates a new partition on the shared device 'sdb' with a size of 999 MiB and sets the type to 'Linux'
sudo mkfs.ext4 /dev/sdb1
# Use mkfs.ext4 to create a file system of type ext4 on the newly created partition 'sdb1'

7. Mount the shared device (`sdb1`) to `/mnt`, as shown below:

# This script mounts the shared device `sdb1` to `/mnt`

# Use `sudo` to run the following command as root user
sudo mount /dev/sdb1 /mnt # Mounts the device `sdb1` to the directory `/mnt`

8. Verify that the mounted partition is accessible, as shown below:

# This script is used to verify the accessibility of a mounted partition by displaying its disk usage information.

# The `df` command is used to display disk usage information.
df -h

Congratulations! You have successfully configured iSCSI disks in Curtin on Ubuntu 20.04 server.

SICORPS