Skip to content

Instantly share code, notes, and snippets.

@rikka0w0
Last active January 11, 2020 16:13
Show Gist options
  • Save rikka0w0/04f4ee83db647fc9f680daf9e9c7ecc2 to your computer and use it in GitHub Desktop.
Save rikka0w0/04f4ee83db647fc9f680daf9e9c7ecc2 to your computer and use it in GitHub Desktop.
iSCSI target on

Install TGT iSCSI target

sudo apt install -y tgt
sudo nano /etc/tgt/conf.d/TecMint_iscsi.conf

Write the config file (can be any.conf)

<target qwq.cszombie.net:lun0>
     # Provided device as an iSCSI target
     #direct-store /dev/sdb1
     backing-store /dev/sdc
     #initiator-address 192.168.0.10
     #incominguser tecmint-iscsi-user password
     #outgoinguser debian-iscsi-target secretpass
</target>

Restart the service and check the exposed luns

sudo service tgt restart
sudo tgtadm --lld iscsi --op show --mode target

Create an ext4 partition image

dd if=/dev/zero of=myimg.ext4 bs=1M count=20480
mkfs.ext4 myimg.ext4
mount -o loop myimg.ext4 /mnt/tmp/

References:

  1. https://www.tecmint.com/setup-iscsi-target-and-initiator-on-debian-9/
  2. https://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment