iSCSI configuration on RHEL 7 with existing volume from old Freenas

Solution 1:

You've already created an iSCSI target and a portal for it to listen on, which are necessary first steps.

You need to define backing stores in /backstores/block or /backstores/fileio. These should be the paths to your block devices for files, whichever you're using.

They can be created like so:

/backstores/block create name=<name> dev=<path/to/block/device>

After doing that for all relevant pre-created backing stores, you'll need to map them as LUNS to an ACL that you define within a target. The first step here is to create the LUNs within your target portal group.

/iscsi/<targetname>/tpg1/luns/ create /backstores/block/<name of backstore>

Once you have done that for all relevant LUNs for this target, you'll need to make ACLs to that your initiators can connect to your target. This is done by specifying the initiator IQN as your ACL. This will allow discovery and login.

/iscsi/<targetname>/tpg1/acls/ create <initiator IQN>

After this is done, map LUNs as need be to their appropriate ACLs. This is automatically done by default, and is appropriate in most scenarios. Using automatic mapping, you would be specifying a target per dedicated storage, and adding ACLs to that target to enable the sharing of LUNs in a cluster or similar. If this is what you want, then you're done. You should be able to connect to your targets.

However, in a non-shared environment where initiators are all using the same target name (such as a mass deployed iSCSI boot scenario with fixed firmware settings), then manually mapping limited ranges of LUNs for each ACLs within a target becomes useful. To do this, you will have to first disable automatic mapping.

> set global auto_add_mapped_luns=false

/iscsi/<targetname>/tpg1/acls/<initiator IQN>/ create <mapped_lun> <tpg lun or explicit backstore>

In that command, mapped_lun refers to the LUN ID that you'll be seeing within the ACL. It's typical to start from zero for each ACL. You may also define backstores directly (via /backstores/block/<name>) instead of luns pre-mapped in luns/ to avoid having to manually create those mappings yourself (and skip a step).