I am using a RHEL server with a few hard drives, and tgtd as the iscsi target software. I a looking for a way to allocate and deallocate space and targets with that space, without restarting my system, or harming other LUNs.
Currently, all my HDDs are PVs in a single VG, and I lvcreate/lvremove as required, and then export the allocated LVs using a tgt script:
usr/sbin/tgtadm --lld iscsi --op new --mode target --tid=1 --targetname iqn.2001-04.com.lab.gss:300gb
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/mapper/iscsi_vg-iscsi_300Gb
/usr/sbin/tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
/usr/sbin/tgtadm --lld iscsi --op new --mode target --tid=2 --targetname iqn.2001-04.com.lab.gss:200gb
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 -b /dev/mapper/iscsi_vg-iscsi_200Gb
/usr/sbin/tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL
/usr/sbin/tgtadm --lld iscsi --op new --mode target --tid=3 --targetname iqn.2001-04.com.lab.gss:100gb
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 3 --lun 1 -b /dev/mapper/iscsi_vg-iscsi_100Gb
/usr/sbin/tgtadm --lld iscsi --op bind --mode target --tid 3 -I ALL
tgtadm --mode target --op show
So in order to remove a LUN, I stop the tgtd service, lvremove the lv, and remove the entry from the iscsi target script
When I add a lun, I run lvcreate, and then add an entry to the script and run it.
This is not quite optimal, since restarting the service is a bad idea while other LUNs are busy, so I am looking for a more scalable and safer way.
Thanks
# tgtadm --lld iscsi --op delete --mode target --tid=X
Guess I'm going to have to stick to openfiler for now... not my first choice, but storage manageability is more important
Umh, use targets.conf and tgt-admin (http://wpkg.org/TGT-admin). Don't need to restart the service ?