Iscsi
- Debian version used: 12
Note: I will be connecting to an iscsi server on my Synology NAS, these steps should be mostly the same, but ymmv.
Mounting iscsi
First, you need to install open-iscsi
sudo apt install open-iscsi
Next, copy the initiator name found in /etc/iscsi/initiatorname.iscsi and make sure the permissions are set on the iscsi server
Next, open /etc/iscsi/iscsid.conf
and set node.startup
to automatic
. If you use CHAP, you can also set this here.
restart iscsid with service iscsid restart
Next, run a discovery against the target (server) host:
iscsiadm -m discovery -t sendtargets -p IP_OF_TARGET
node down the IQN of the target, and run
iscsiadm --mode node --targetname IQN --portal PORTAL_IP:PORT --login
restart iscsi again with sudo service iscsid restart
Now you should see a new drive, if you run blkid
, that appears as a normal drive (sdX)
Formatting the drive and mounting
Now we need to format and mount the drive, replace sdX
with the device (eg: sdb
)
parted -s --align optimal /dev/sdX -- mklabel gpt mkpart primary 4MiB 100% mkfs -t ext4 /dev/sdX1
next, edit /etc/fstab
LABEL=LUN-1 /mnt/iscsi ext4 _netdev 0 0
and run mount /mnt/iscsi
to mount
(you can set a label using e2label
)
Performance testing
Make a 10G test file: dd if=/dev/urandom of=testfile bs=1M count=10240
space reclamation
use fstrim <mountpoint>
to reclaim space