Hiya,
I've just set up an Ubuntu 18.04 VM with a second 10GB drive as a test that I want to set up as block storage over iSCSI. The problem is, when I reboot the iSCSI target VM, the LUN dos not show up when running tgtadm --mode target --op show
Running a systemctl restart fixes the issue and the LUN shows up as LUN 1 when running tgtadm --mode target --op show
Here's what I did to set up an iSCSI target:
Assume:
/dev/sdb is the disk to use as an iSCSI LUN
iqn.2019-07.local.nsnetworks:netstorage is the target name
192.168.1.30 is the IP address of the iSCSI target portal
Setting up the target:
- Install required packages:
sudo su -
apt install -y tgt
- Create iSCSI target (tid 1)
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2019-07.local.nsnetworks:netstorage
- Add logical Unit (lun 1) to iSCSI target (Target ID 1)
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb
- Publish iSCSI target (tid 1) to all IP address
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
- Save configuration for iSCSI target. If you do not save configuration, configuration will be removed after restarting tgtd
tgt-admin --dump |grep -v default-driver > /etc/tgt/conf.d/disk.conf
- Enable service:
systemctl enable tgt
- Show status
tgtadm --mode target --op show
Any help getting the LUN to show up persistently when the iSCSI target is rebooted would be much appreciated!
Many thanks in advance!
Bookmarks