Exporting disk image files via iSCSI on Linux

Installing the iSCSI target software

If you do not have dedicated iSCSI target hardware, you will need to install the iSCSI Enterprise Target Daemon (ietd). If you are lucky, then your distro will already have packaged this for you; try installing a package called iscsitarget or iscsi-target. If this fails, you can download the source for the latest version from http://sourceforge.net/project/showfiles.php?group_id=108475&package_id=117141.

Adding an iSCSI target image

To add a disk image file as an iSCSI target, you need to add the following two lines to /etc/ietd.conf:

  Target iqn.2007-08.name.dns.target.my:iscsiboot
      Lun 0 Path=/path/to/image/file.img,Type=fileio

where /path/to/image/file.img is the path to your disk image file, and name.dns.target.my is your DNS name in reverse order.

(For completeness, you should also replace 2007-08 with the year and month in which you first obtained your DNS domain. The iSCSI naming schemes are somewhat pedantic, but it won't affect anything in practice; as long as the target name is unique then everything will work just fine.)

Make a note of the iSCSI target IQN that you chose (iqn.2007-08.name.dns.target.my:iscsiboot in the above example). You are now ready to