3

Using Ubuntu Linux Server 22.04 minimal edition without GUI, I need some help in mounting the iSCSI LUN using Open-iSCSI so it is mapped to /dev/sdb with the below command:

Could you please let me know if I missed any steps on the following:

Edit the file /etc/iscsi/initiatorname.iscsi into:

InitiatorName=iqn.2023-02.com.domain.repo01:repo01.initiator01

and then continue with:

sudo systemctl restart iscsid open-iscsi
sudo iscsiadm -m discovery -t sendtargets -p 192.168.1.111 (this is the IP address of my NAS target).
sudo iscsiadm -m node -o show 
sudo iscsiadm -m node –login
sudo iscsiadm -m discovery -t st -p 192.168.1.111

Edit the /etc/iscsi/iscsid.conf file and set the value into:

node.startup = automatic

and then reboot the VM.

However, when I check with the below command after multiple reboot no /dev/sdb mounted

sudo fdisk -l

If you could provide me with any assistance, I would greatly appreciate it.

Senior Systems Engineer
  • 1,335
  • 2
  • 37
  • 73

1 Answers1

1

All iSCSI is doing is presenting a block device, but it still needs to be formatted with a filesystem before it can be mounted. This has (2) parts:

a) Partitioning:

So in the output of fdisk -l find your new block device- in this example "sdd"- and partition it. Specify "n" for a new partition and you can (generally) just hit to accept the default values and finally specify "w" to write the changes and exit:

ubuntu@server:~$ sudo fdisk /dev/sdd
<snip>
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p. Partition number (1-4, default 1): First sector (2048-2097151, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-2097151, default 2097151):

Created a new partition 1 of type 'Linux' and of size 1023 MiB.

Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.

b) Formatting with a Filesystem

Use mkfs to laydown a filesystem:

ubuntu@server:~$ sudo mkfs.ext4 /dev/sdd1
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done                            
Creating filesystem with 261888 4k blocks and 65536 inodes
Filesystem UUID: f09b7659-a60a-4963-a44f-d59c9dbbe671
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done

So now you've got a filesystem on the iSCSI LUN which is capable of being mounted, preferably as a SystemD service. The process is a bit fiddily, so I scripted it so that it's fool-proof if you follow my instructions in the README.md file:

https://github.com/f1linux/iscsi-automount

This will automate setting up a SystemD automount that connects the iSCSI as a SystemD Service on boot.

I wrote the script to connect an iSCSI LUN to an Ubuntu host- my case a Raspberry Pi 4- and then specify the folder that it's mounted to on the host as a Docker Volume in my docker-compose.yml file to hold persistent data apart from the container. Will work for any other use-case though.

Hope this helps-

F1Linux
  • 465