How To Attach iSCSI Storage to Debian 12
Dependencies
Install the iscsi administration tools
sudo apt install open-iscsi -yCollect the IQN from the target server
iqn.2005-10.org.freenas.ctl:mirems-blockConfigure the iSCSI Connection
If using CHAP for authentication, modify the /etc/iscsi/iscsid.conf file and uncomment the credentials section under CHAP.
Discover the target
sudo iscsiadm -m discovery -t sendtargets -p <ip of truenas server>Confirm status after discovery
sudo iscsiadm -m node -o showLogin to the target
sudo iscsiadm -m node --login -p <ip of truenas box>Confirm the session is established
sudo iscsiadm -m session -o showEnable automatic mapping during boot
sudo iscsiadm -m node -p <ip of truenas box> -o update -n node.startup -v automaticSetting up iSCSI Partition
Set up location for the data to be mounted
sudo mkdir /srv/storage
sudo chmod 000 /srv/storage
sudo chattr +i /srv/storageFind the new device (e.g. /dev/sdb)
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 953M 0 part /boot
└─sda2 8:2 0 99.1G 0 part /
sdb 8:16 0 50G 0 disk
sr0 11:0 1 1024M 0 romCreate the partition and filesystem on the LUN (if it’s a brand new LUN)
sudo apt install parted -y
sudo parted --script /dev/sdb "mklabel gpt"
sudo parted --script /dev/sdb "mkpart primary 0% 100%"
sudo mkfs.ext4 /dev/sdb1
sudo mount /dev/sdb1 /srv/storage
sudo chmod 777 /srv/storageAdd this to the /etc/fstab so the filesystem is mounted automatically
/dev/sdb1 /srv/storage ext4 _netdev 0 0