1

How can i expose a iso file as iSCSI target in Linux. I tried the following,

mknod /dev/fake-dev1 b 7 201

losetup /dev/fake-dev1 1.iso

And then I modified the ietd.conf to point to the block device,

Lun 0 Path=/dev/fake-dev1,Type=blockio,ScsiId=lun0,ScsiSN=lun0 IOMode=ro

And then restarted the iscsitarget. From windows if I connect I only see it is unallocated drive and not the files. When I insert a USB drive and point the 'Path=/dev/sdb' then the drive is seen on the Windows machine. But I am not able to get it working with a ISO file. Please let me know what am I missing here.

Thomas
  • 489
  • 1
  • 8
  • 13

1 Answers1

1

I am not sure why you are using mknod and losetup. They should not be needed.

Just set up a "fileio" target, and the file you point to is the ISO file itself.

For me, this looks like:

o- backstores .............................................................................................................. [...]  
  | o- block .................................................................................................. [Storage Objects: 0]  
  | o- fileio ................................................................................................. [Storage Objects: 2]  
  | | o- iso1 .......................... [/alt/ISO_Images/SLE-12-SP3-Server-DVD-x86_64-Beta2-DVD1.iso (3.2GiB) write-back activated]  
  | o- pscsi .................................................................................................. [Storage Objects: 0]  
  | o- ramdisk ................................................................................................ [Storage Objects: 0]  

For the "backend" part of the storage, and then just set it up like any other file, i.e. allocate an iSCSI target, set the LUN to point at the fileio object created above, then set up an ACL and portal for it. Again, mine looks like:

  o- iscsi ............................................................................................................ [Targets: 2]  

  | o- iqn.2003-01.org.linux-iscsi.worklaptop.x8664:sn.c551a059614d ...................................................... [TPGs: 1]
  |   o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 1]
  |     | o- iqn.1996-04.de.suse:01:919acd32c5a2 .................................................................. [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ................................................................................. [lun0 fileio/iso1 (rw)]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ...................................... [fileio/iso1 (/alt/ISO_Images/SLE-12-SP3-Server-DVD-x86_64-Beta2-DVD1.iso)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 192.168.20.2:3260 ................................................................................................ [OK]

Once this is set up, then you discover it like any other iSCSI target. In my case, I got "/dev/sdb", "/dev/sdb1", and "/dev/sdb2". The first obviously is the whole device, including the partition table. The second device is the first partition, and is the UEFI boot partition in my case. And the second partition, "/dev/sdb2", is the ISO, and was mounted read-only when I mounted it.

Lee-Man
  • 374
  • 1
  • 8