From patchwork Wed Apr 12 19:59:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Vu-Brugier X-Patchwork-Id: 9678309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D676860382 for ; Wed, 12 Apr 2017 19:59:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C905F2865B for ; Wed, 12 Apr 2017 19:59:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD76028662; Wed, 12 Apr 2017 19:59:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B192865C for ; Wed, 12 Apr 2017 19:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754634AbdDLT7Q (ORCPT ); Wed, 12 Apr 2017 15:59:16 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35678 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754599AbdDLT7P (ORCPT ); Wed, 12 Apr 2017 15:59:15 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 25D57214AC; Wed, 12 Apr 2017 15:59:15 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Wed, 12 Apr 2017 15:59:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc:x-sasl-enc; s=fm1; bh=MmHSucz7tVaiGZsHmsRIojd+SmhIbw CuQbXZDJShZRk=; b=pW2BCuddd5uMbS3QwRlXkO+D8FZTh06xY1gu/r3Mpz3BbL K8yZfM4nR8J0FlVmIgL78QXCc4EaliQssu/GzTYzp1LfJVUx0vvdH63dmZ0ZAxze chGArD1OGLSc1aDBl/A5IzG24qkcCrYX8CqMyNpVOv+NSYcfTyPMei/kc4KBIxnQ Ibl6Taprw94usMpLDRdb4HsnavFm82efFniLBTgDk5SnLTvsPmlR4p2+xVv6dqfg ObCaflNck3JFMm6Vk+i9CQr6ZglI+cvmO2/chYFfEGuIVJyLmXJMzJZYVEBuWzC1 qKSnHHH/GmOtn9tbLf/rnOSwM5znmP5qeKDO40FQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=MmHSuc z7tVaiGZsHmsRIojd+SmhIbwCuQbXZDJShZRk=; b=AKzYrnhaDmjbMvov29diMu 5PvmuD56ap9TDTKPKRvMDfqb/UF53FdnzT0bUSwftUA+KVMhYpvLa8lbwzY1Qib8 GQhQnvBQhB01TTzksmM4bXrJPGfPdI/HhNMTtz8yRutmKQvYrAicY4STEc2+1Vh+ 5llsbYnEjVhfCSfMw/Dld90PKOlyksPgVfdYQLbVobkKiqaaXguLC8XSvSVX/BpN cMi3xDzIZdjIXv9AlyFAQ9cinNy4Or7TMMjqNttmYI2FzZb9IFPPVgdr61VFIzwl lW1b4fkRa13ZHZxeWwIehkNOlrLnDBqyKbGjewAI+82o1DryMeP5AWqFW13rUsaA == X-ME-Sender: X-Sasl-enc: klbzSyXeH/2zveEvFbwtSsIVuMrym3x9Nq3EeoxMANoW 1492027154 Received: from trantor.home (lfbn-1-12058-203.w90-92.abo.wanadoo.fr [90.92.120.203]) by mail.messagingengine.com (Postfix) with ESMTPA id 6B5DB241E1; Wed, 12 Apr 2017 15:59:14 -0400 (EDT) From: Christophe Vu-Brugier To: target-devel@vger.kernel.org Cc: uhmgawa , Vincent Donnefort Subject: [PATCH] Documentation/target: add an example script to configure an iSCSI target Date: Wed, 12 Apr 2017 21:59:08 +0200 Message-Id: <20170412195908.21658-1-cvubrugier@fastmail.fm> X-Mailer: git-send-email 2.11.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The script illustrates how to interact with configfs to create a very simple LIO iSCSI target with a file or block device backstore. The script can serve as a starting point for people that cannot use targetcli because Python is not available on their machine. Signed-off-by: Christophe Vu-Brugier Signed-off-by: Vincent Donnefort --- Documentation/target/target-export-device | 80 +++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 Documentation/target/target-export-device diff --git a/Documentation/target/target-export-device b/Documentation/target/target-export-device new file mode 100755 index 000000000000..b803f4f886b5 --- /dev/null +++ b/Documentation/target/target-export-device @@ -0,0 +1,80 @@ +#!/bin/sh +# +# This script illustrates the sequence of operations in configfs to +# create a very simple LIO iSCSI target with a file or block device +# backstore. +# +# (C) Copyright 2014 Christophe Vu-Brugier +# + +print_usage() { + cat < $BACKSTORE_DIR/control +else + BACKSTORE_DIR=$CORE_DIR/fileio_0/data + mkdir -p $BACKSTORE_DIR + DEVICE_SIZE=$(du -b $DEVICE | cut -f1) + echo "fd_dev_name=${DEVICE}" > $BACKSTORE_DIR/control + echo "fd_dev_size=${DEVICE_SIZE}" > $BACKSTORE_DIR/control + echo 1 > $BACKSTORE_DIR/attrib/emulate_write_cache +fi +echo 1 > $BACKSTORE_DIR/enable + +# Create an iSCSI target and a target portal group (TPG) +mkdir $ISCSI_DIR/$IQN +mkdir $ISCSI_DIR/$IQN/tpgt_1/ + +# Create a LUN +mkdir $ISCSI_DIR/$IQN/tpgt_1/lun/lun_0 +ln -s $BACKSTORE_DIR $ISCSI_DIR/$IQN/tpgt_1/lun/lun_0/data +echo 1 > $ISCSI_DIR/$IQN/tpgt_1/enable + +# Create a network portal +mkdir $ISCSI_DIR/$IQN/tpgt_1/np/$PORTAL + +# Disable authentication +echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/authentication +echo 1 > $ISCSI_DIR/$IQN/tpgt_1/attrib/generate_node_acls + +# Allow write access for non authenticated initiators +echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/demo_mode_write_protect + +echo "Target ${IQN}, portal ${PORTAL} has been created"