Steps to Connect and Mount an iSCSI LUN on Linux Mint (With CHAP Authentication)

Mounting a normal share to /home/user/.local/share/safe isn’t enough for LaunchPad to detect the extra space and won’t let you start more nodes than your local file system has.

Did this… but first create a iSCSI Target on your QNAP NAS, and I recommend adding CHAP Authentication.

1. Install iSCSI Initiator

The iSCSI initiator software is required to connect to the iSCSI target on your storage system.

sudo apt update
sudo apt install open-iscsi

2. Discover the iSCSI Target

Use the following command to discover the available iSCSI targets from the storage server.

sudo iscsiadm -m discovery -t sendtargets -p <NAS_IP>
  • Replace <NAS_IP> with the IP address of the storage server.

3. Set CHAP Authentication

If the iSCSI target requires authentication, you’ll need to set the CHAP username and password before logging in. Follow these steps:

  1. Configure CHAP Authentication:

    Use the following commands to set the CHAP username and password for the iSCSI target.

    sudo iscsiadm -m node -T <TARGET_IQN> -p <NAS_IP> --op=update -n node.session.auth.authmethod -v CHAP
    sudo iscsiadm -m node -T <TARGET_IQN> -p <NAS_IP> --op=update -n node.session.auth.username -v <CHAP_USERNAME>
    sudo iscsiadm -m node -T <TARGET_IQN> -p <NAS_IP> --op=update -n node.session.auth.password -v <CHAP_PASSWORD>
    
    • Replace <TARGET_IQN> with the iSCSI target IQN (from the discovery step).
    • Replace <NAS_IP> with the IP address of the storage server.
    • Replace <CHAP_USERNAME> and <CHAP_PASSWORD> with the authentication credentials.

4. Log In to the iSCSI Target

After setting the authentication, log in to the iSCSI target.

sudo iscsiadm -m node -T <TARGET_IQN> -p <NAS_IP> --login
  • Replace <TARGET_IQN> with the IQN of the iSCSI target (from the discovery step).
  • Replace <NAS_IP> with the IP address of the storage server.

5. Verify the New Device

Once logged in, verify that the iSCSI disk has been added to your system.

lsblk

Look for a new device like /dev/sdb (this will be your iSCSI LUN).

6. Partition and Format the Disk (If Necessary)

If the disk is new and unformatted, you can create a partition and format it.

  1. Partition the Disk:

    sudo fdisk /dev/sdb
    

    Follow the prompts to create a partition (e.g., /dev/sdb1).

  2. Format the Partition:

    sudo mkfs.ext4 /dev/sdb1
    

7. Mount the iSCSI Partition

Create a mount point and mount the partition to make it accessible.

  1. Create the Mount Point:

    sudo mkdir -p /mnt/iscsi_lun
    
  2. Mount the Partition:

    sudo mount /dev/sdb1 /mnt/iscsi_lun
    

8. Set the Partition to Mount Automatically on Boot

To ensure the iSCSI LUN mounts automatically after a reboot, edit the /etc/fstab file.

sudo nano /etc/fstab

Add the following line:

/dev/sdb1 /mnt/iscsi_lun ext4 _netdev 0 0

Save and exit the file.

9. Enable Auto-Login for iSCSI

Configure the iSCSI initiator to automatically log in to the iSCSI target at boot.

sudo iscsiadm -m node -T <TARGET_IQN> -p <NAS_IP> --op=update -n node.startup -v automatic

This ensures that the system automatically logs in to the iSCSI target on boot.

10. Set Permissions (Optional)

If a specific user needs ownership of the mounted iSCSI LUN, you can set the appropriate permissions:

sudo chown -R <user>:<group> /mnt/iscsi_lun

Final Notes

  • Ensure that the iSCSI services (open-iscsi and iscsid) are enabled to start automatically on boot:

    sudo systemctl enable open-iscsi
    sudo systemctl enable iscsid
    
  • After rebooting, test that the iSCSI LUN is automatically logged in and mounted by running:

    df -h | grep iscsi_lun
    

These steps will allow you to securely connect to and mount an iSCSI LUN with CHAP authentication on Linux Mint, ensuring that it is automatically mounted and ready for use after a reboot.

Let me know if you need any additional clarifications!

edit: This post was brought to you by ChatGPT. :rofl: :rofl: :rofl:

5 Likes

Excellent. :slight_smile:

1 Like