From: Stefan de Konink Subject: [SCRIPT] Using iSCSI in your xen setup Date: Sun, 25 Nov 2007 23:41:50 +0100 Message-ID: <4749FA2E.8030809@xs4all.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000506090801070407060201" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-users-bounces@lists.xensource.com Errors-To: xen-users-bounces@lists.xensource.com To: Xen Users , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------000506090801070407060201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, This is my first version of the block-iscsi script. Easy to setup, easy to work with. > #general > name = "skinkie_gentoo_old"; > memory = 256; > > # booting > kernel = "/home/skinkie/xen/boot/gentoo"; > > # virtual harddisk > disk = [ "iscsi:/dev/disk/by-path/ip-192.168.0.2:3260-iscsi-iqn.1986-03.com.sun:02:c6719b9f-7993-444d-c6d2-80d4e15ee52c-lun-0,hda,w" ]; > root = "/dev/hda ro" The script parses the structure used by udev, so it will extract the IP address and ISCSI target from the parameter. It starts a discovery based on the IP target, login to the server upon create/migration. And logout from the server is the domain is migrated or destroyed. The sleep in the script could probably reduced to 1 or 2 seconds, but udev needs to populate the /dev/disk/by-path directory. It borks without the wait. Probably next implementations will include a returncode, with a prettier wait function. Yes, it lacks basic chap/pap authentication but since nothing was provided, it is a nice first attempt to get ISCSI to work in the Xen opensource environment. It assumes you don't use the same iscsi target anywhere else otherwise you will have a problem upon destroy ;) Howto install: copy the script to /etc/xen/scripts/ and make it executable with chmod +x block-iscsi. My setup now: Gentoo Linux NFS client (Xen Node) Gentoo Linux Development (Provides DHCP/PXE boot/Monitoring) OpenSolaris with ZFS (Provides iSCSI/NFS storage) Upon start the NFS client registers itself with the Monitoring server to join the to be monitored pool and gets a callback from the XenAPI. Stefan -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHSfouYH1+F2Rqwn0RClo1AJ9JHN2ocYp8E0O1lrb43XfbLlkN2gCfeCSb Sx0ThJa/lDQWGvmbz2HNZHI= =VHIr -----END PGP SIGNATURE----- --------------000506090801070407060201 Content-Type: text/plain; name="block-iscsi" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="block-iscsi" #!/bin/bash # Usage: block-iscsi dir=$(dirname "$0") . "$dir/block-common.sh" p=$(xenstore_read "$XENBUS_PATH/params") udev=`basename $p` ip=`echo $udev | sed "s/ip-\(.*\)-iscsi.*/\1/g"` target=`echo $udev | sed "s/.*iscsi-\(.*\)-lun.*/\1/g"` case "$command" in add) if [ ! -a $p ] then /usr/sbin/iscsiadm -m discovery -t sendtargets -p $ip /usr/sbin/iscsiadm -m node -T $target -p $ip --login sleep 4 fi if [ -a $p ] then write_dev $p exit 0 fi exit 1 ;; remove) if [ -a $p ] then /usr/sbin/iscsiadm -m node -T $target -p $ip --logout fi exit 0 ;; esac --------------000506090801070407060201 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users --------------000506090801070407060201--