Results 1 to 3 of 3

Thread: Persistently exposing iSCSI LUNS after a reboot

  1. #1
    Join Date
    Oct 2015
    Beans
    16

    Persistently exposing iSCSI LUNS after a reboot

    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!




    Last edited by Neil_Sherin; July 17th, 2019 at 12:00 AM.

  2. #2
    Join Date
    Oct 2015
    Beans
    16

    Re: Persistently exposing iSCSI LUNS after a reboot

    i then tried to set up a udev mapping to see if that would resolve the issue:


    • Create udev rule for proper device mapping of sdX to iscsi_X on boot


    Using sdb as an example:

    udevadm info --query=property --name=/dev/sdb

    Make a note of the values of:
    ID_SCSI_SERIAL
    ID_SERIAL
    ID_SERIAL_SHORT

    Create symbolic link for iscsi_1 mapping:

    ln -s /dev/sdb /dev/iscsi_1

    Set up udev rule:

    nano /etc/udev/rules.d/70-persistent-drive.rules

    Add the following:

    SUBSYSTEM=="block", ENV{ID_SCSI_SERIAL}=="6000c29831ec9a7d45dc007e6439 a6d6", ENV{ID_SERIAL}=="36000c29831ec9a7d45dc007e6439a6d6 ", ENV{ID_SERIAL_SHORT}="6000c29831ec9a7d45dc007e6439 a6d6". SYMLINK+="iscsi_1"

    Reload udev rules:

    udevadm control --reload-rules && udevadm trigger

    On reboot, it still does not expose the LUN. I have to do the following to get the LUN exposed:

    ln -s /dev/sdb /dev/iscsi_1
    udevadm control --reload-rules && udevadm trigger
    systemctl tgt restart

    Again, any help would be much appreciated.

    Last edited by Neil_Sherin; July 17th, 2019 at 11:56 AM.

  3. #3
    Join Date
    Nov 2009
    Location
    Catalunya, Spain
    Beans
    14,560
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Persistently exposing iSCSI LUNS after a reboot

    Did you go through the official doc in case something there can help you? It seems they are doing it in a different way (hasn't worked with iscsi that much lately myself).
    https://help.ubuntu.com/lts/servergu...initiator.html
    Darko.
    -----------------------------------------------------------------------
    Ubuntu 18.04 LTS 64bit

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •