Iscsi - target and initiator setup debian
Jump to navigation
Jump to search
iSCSI - target (server) setup
We'll use tgt to handle everything dynamically
iSCSI - initiator (client) setup
Link to page:
http://iscsitargetandinitiator.blogspot.dk/
Show target devices and initiators connected
tgtadm --lld iscsi --op show --mode target
Add devices/disks/partitions to target
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb
Re-adding LVM based iscsi disks after reboot
Requires a change in how LVM 'attaches' to disks.
So if you've added say /dev/sdb to be a complete iscsi device and on the initiator using it as a LVM, it does not attach itself to the target on reboot.
Edit /etc/lvm/lvm.conf and change:
# By default we accept every block device: #filter = [ "a/.*/" ] # Every block device except /dev/sdb, that is. filter = [ "r|/dev/sdb|" ]
More info here: http://www.sysarchitects.com/iscsi_target_on_rhel6
On debian I couldn't get this to work; I found a simple init-script from RH bugzillatracker which did the trick:
#!/bin/sh ### BEGIN INIT INFO # Provides: tgtd # Required-Start: $network $syslog # Required-Stop: $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Start the iSCSI target server tgt # Description: iSCSI target server tgt (http://stgt.sf.net) ### END INIT INFO set -e TGTD="/usr/sbin/tgtd" TGTADMIN="/usr/sbin/tgt-admin" DEFAULTS="/etc/default/tgt" # Check for daemon presence [ -x "$TGTD" ] || exit 0 OPTIONS="" MODULES="" # Include tgtd defaults if available [ -r "$DEFAULTS" ] && . "$DEFAULTS" # Get lsb functions . /lib/lsb/init-functions case "$1" in start) log_begin_msg "Starting iSCSI target (tgt) services..." start-stop-daemon --start --quiet --oknodo --exec "$TGTD" -- $OPTIONS [ -x "$TGTADMIN" ] && $TGTADMIN -e log_end_msg $? ;; stop) log_begin_msg "Stopping iSCSI target (tgt) services..." start-stop-daemon --stop --quiet --oknodo --retry 2 --exec "$TGTD" log_end_msg $? ;; restart) $0 stop sleep 1 $0 start ;; reload|force-reload) log_begin_msg "Reloading iSCSI target (tgt) services..." start-stop-daemon --stop --signal 1 --exec "$TGTD" log_end_msg $? ;; status) status_of_proc "$TGTD" tgtd ;; *) log_success_msg "Usage: /etc/init.d/tgt {start|stop|restart|reload|force-reload|status}" exit 1 esac
iSCSI with HA
Attached pdf document which describes DRBD, Pacemaker and iSCSI setup: