45Drives Knowledge Base |
KB450299- Setup iSCSI Storage Server on Ubuntu 20.04 LTS https://knowledgebase.45drives.com/kb/kb450299-setup-iscsi-storage-server-on-ubuntu-20-04-lts/ |
In this tutorial, we will explain how to setup iSCSI targets on Ubuntu 20.04 server
The iSCSI target is LIO and is managed via targetcli
(We don't recommend using bonds with iSCSI, we recommend using Multi-path instead)
apt install targetcli-fb
root@ceph-ubuntu1:~# cd /tank/images root@ceph-ubuntu1:~# dd if=/dev/zero of=lun0 bs=1 count=0 seek=(size of LUN)
root@ceph-ubuntu1:~# targetcli targetcli shell version 2.1.51 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> cd backstores/fileio /backstores/fileio> create lun0 /tank/images/lun0
/backstores/fileio> ls o- fileio ..................................................................................................... o- lun0 ...................................................................... o- alua ....................................................................................................... o- default_tg_pt_gp ...........................................................................
/backstores/block> cd /iscsi /iscsi> create iqn.2021-04.com.45lab:ubuntu.iscsi0 Created target iqn.2021-04.com.45lab:ubuntu.iscsi0. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd iqn.2021-04.com.45lab:ubuntu.iscsi0/tpg1/luns /iscsi/iqn.20...si0/tpg1/luns> create /backstores/fileio/lun0 Created LUN 0.
/iscsi/iqn.20...si0/tpg1/luns> cd /iscsi/iqn.2021-04.com.45lab:ubuntu.iscsi0/tpg1/acls /iscsi/iqn.20...si0/tpg1/acls> create iqn.1991-05.com.microsoft:win10 Created Node ACL for iqn.1991-05.com.microsoft:win10 Created mapped LUN 0.
/iscsi/iqn.20...si0/tpg1/acls> cd iqn.1991-05.com.microsoft:win10/ /iscsi/iqn.20...crosoft:win10> set auth userid=username Parameter userid is now 'username'. /iscsi/iqn.20...crosoft:win10> set auth password=password Parameter password is now 'password'.
/iscsi/iqn.20...crosoft:win10> exit Global pref auto_save_on_exit=true Configuration saved to /etc/rtslib-fb-target/saveconfig.json
cd iscsi
/iscsi> delete iqn.2021-04.com.45lab:ubuntu.iscsi0 Deleted Target iqn.2021-04.com.45lab:ubuntu.iscsi0.
cd /backstores/fileio/
/backstores/fileio> delete lun0 Deleted storage object lun0.