Tuesday, June 11, 2019

FreeNAS zvol, iSCSI, VMware ESXi, and accessing that datastore from Linux

I am shuffling things around here. Initially, I had setup a file-based iSCSI target on my FreeNAS box for VMware ESXi to use as a datastore. Lately, I've had the desire to access those VM files from outside of ESXi (backup, etc.) and at first thought I would try to move one or two VMs to a NFS datastore served by the same FreeNAS box, but the performance was atrocious.

Right now, I am tinkering with a new zvol-based iSCSI target and accessing those VM files from my Manjaro-based laptop. The ESXi system creates a VMFS file system on the iSCSI target, and from Linux I had to install open-iscsi and vmfs-tools to make this happen.

As is usual with different distributions of GNU/Linux, the locations of files will vary from one distribution to the next. On some, you'll find the iSCSI target datbase in /var/lib/iscsi, while on Manjaro it's located in /etc/iscsi.

Legend:

  • FreeNAS box is 169.254.20.100 (not really, documentation only)
  • zvol is 1TiB in size
  • iSCSI Extent is using FreeNAS defaults, nothing custom
  • iSCSI Portal is not using authentication
  • Domain name is 'example.net' (not really, documentation only)

On my Linux client, I opened a terminal...


# iscsiadm --mode discovery -t sendtargets --portal 169.254.20.100

169.254.20.100:3260="" iqn.2019-06.net.example.istgt:zvol.target


# iscsiadm --mode node --targetname iqn.2019-06.net.example.istgt:zvol.target --portal 169.254.20.100 --login

Logging in to [iface: default, target: iqn.2019-06.net.example.istgt:zvol.target, portal: 169.254.20.100,3260]
Login to [iface: default, target: iqn.2019-06.net.example.istgt:zvol.target, portal: 169.254.20.100,3260] successful.


# fdisk -l

Disk /dev/sdb: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk model: iSCSI Disk      
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 32768 bytes
I/O size (minimum/optimal): 32768 bytes / 1048576 bytes
Disklabel type: gpt
Disk identifier: 79E7F7EF-EB2E-4086-9924-8E1730F8A54B

Device     Start        End    Sectors  Size Type
/dev/sdb1   2048 2147483614 2147481567 1024G VMware VMFS


# vmfs-fuse /dev/sdb1 /mnt/freenas-iscsi-zvol
 
 
# /bin/ls -alF /mnt/freenas-iscsi-zvol

total 794660K
drwxr-xr-t 7 root root      1820 Jun 11 15:10 .
drwxr-xr-x 9 root root      4096 Jun 11 13:23 ..
-r-------- 1 root root   5439488 Jun 11 14:11 .fbb.sf
-r-------- 1 root root 267026432 Jun 11 14:11 .fdc.sf
-r-------- 1 root root   1179648 Jun 11 14:11 .pb2.sf
-r-------- 1 root root 268435456 Jun 11 14:11 .pbc.sf
-r-------- 1 root root 262733824 Jun 11 14:11 .sbc.sf
srwx------ 2 root root       280 Jun 11 14:11 .sdd.sf=
-r-------- 1 root root   4194304 Jun 11 14:11 .vh.sf



That's it, nothing else required. I can now access the iSCSI zvol using vmfs-fuse on my Manjaro Linux laptop.