targetcli

2023-05-16

Linux-IO (LIO) Target is an open-source implementation of the SCSI target thathas become the standard one included in the Linux kernel and the one present inRed Hat Enterprise Linux 7. The popular scsi-target-utils package is replacedby the newer targetcli which makes configuring a software iSCSI target quitedifferent.

In earlier versions one had to edit the /etc/tgtd/targets.conf file andservice tgtd restart. Here is an example configuration:


<target iqn.2008-09.com.example:server.target1>
    backing-store /dev/vg_iscsi/lv_lun1
    backing-store /dev/vg_iscsi/lv_lun2

    incominguser user2 secretpass23
    outgoinguser userA secretpassA
</target>
  

targetcli can be used either as an interactive shell or as stand alone commands.Here is an example shell session which creates a file-based disk image. Comments areprovided inline:


# yum install -y targetcli
# systemctl enable target

# targetcli 

# first create a disk image with the name of disk1. All files are sparsely created.

/> backstores/fileio create disk1 /var/lib/libvirt/images/disk1.img 10G
Created fileio disk1 with size 10737418240

# create an iSCSI target. NB: this only defines the target

/> iscsi/ create iqn.2015-04.com.example:target1
Created target iqn.2015-04.com.example:target1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

# TPGs (Target Portal Groups) allow the iSCSI to support multiple complete
# configurations within one target. This is useful for complex quality-of-service
# configurations. targetcli will automatically create one TPG when the target
# is created, and almost all setups only need one.

# switch to TPG definition for our target

/> cd iscsi/iqn.2015-04.com.example:target1/tpg1

# list the contents

/iscsi/iqn.20...:target1/tpg1> ls 
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 0]
  o- luns ................................................................................................................ [LUNs: 0]
  o- portals .......................................................................................................... [Portals: 1]
    o- 0.0.0.0:3260 ........................................................................................................... [OK]

# create a portal aka IP:port pairs which expose the target on the network

/iscsi/iqn.20...:target1/tpg1> portals/ create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
This NetworkPortal already exists in configFS.

# create logical units (LUNs) aka disks inside our target
# in other words bind the target to its on-disk storage

/iscsi/iqn.20...:target1/tpg1> luns/ create /backstores/fileio/disk1
Created LUN 0.

# disable authentication

/iscsi/iqn.20...:target1/tpg1> set attribute authentication=0
Parameter authentication is now '0'.

# enable read/write mode

/iscsi/iqn.20...:target1/tpg1> set attribute demo_mode_write_protect=0
Parameter demo_mode_write_protect is now '0'.

# Enable generate_node_acls mode. This can be thought of as 
# "ignore ACLs mode" -- both  authentication and LUN mapping
# will then use the TPG settings.

/iscsi/iqn.20...:target1/tpg1> set attribute generate_node_acls=1
Parameter generate_node_acls is now '1'.

/iscsi/iqn.20...:target1/tpg1> ls
o- tpg1 ........................................................................................................ [gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 0]
  o- luns ................................................................................................................ [LUNs: 1]
  | o- lun0 ..................................................................... [fileio/disk1 (/var/lib/libvirt/images/disk1.img)]
  o- portals .......................................................................................................... [Portals: 1]
    o- 0.0.0.0:3260 ........................................................................................................... [OK]

# exit or Ctrl+D will save the configuration under /etc/target/saveconfig.json

/iscsi/iqn.20...:target1/tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

# after creating a second target the layout looks like this

/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 2]
  | | o- disk1 .................................................. [/var/lib/libvirt/images/disk1.img (10.0GiB) write-back activated]
  | | o- disk2 .................................................. [/var/lib/libvirt/images/disk2.img (10.0GiB) write-back activated]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 2]
  | o- iqn.2015-04.com.example:target1 ................................................................................... [TPGs: 1]
  | | o- tpg1 .................................................................................................. [gen-acls, no-auth]
  | |   o- acls .......................................................................................................... [ACLs: 0]
  | |   o- luns .......................................................................................................... [LUNs: 1]
  | |   | o- lun0 ............................................................... [fileio/disk1 (/var/lib/libvirt/images/disk1.img)]
  | |   o- portals .................................................................................................... [Portals: 1]
  | |     o- 0.0.0.0:3260 ..................................................................................................... [OK]
  | o- iqn.2015-04.com.example:target2 ................................................................................... [TPGs: 1]
  |   o- tpg1 .................................................................................................. [gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 0]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ............................................................... [fileio/disk2 (/var/lib/libvirt/images/disk2.img)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 0.0.0.0:3260 ..................................................................................................... [OK]
  o- loopback ......................................................................................................... [Targets: 0]


# enable CHAP and Reverse CHAP (mutual) for both discovery and login authentication

# discovery authentication is enabled under the global iscsi node

/> cd /iscsi
/iscsi> set discovery_auth enable=1
/iscsi> set discovery_auth userid=IncomingUser
/iscsi> set discovery_auth password=SomePassword1
/iscsi> set discovery_auth mutual_userid=OutgoingUser
/iscsi> set discovery_auth mutual_password=AnotherPassword2

# login authentication is enabled either under the TPG node or under ACLs

/iscsi> cd iqn.2015-04.com.example:target1/tpg1
/iscsi/iqn.20...:target1/tpg1> set attribute authentication=1
/iscsi/iqn.20...:target1/tpg1> set auth userid=IncomingUser2
/iscsi/iqn.20...:target1/tpg1> set auth password=SomePassword3
/iscsi/iqn.20...:target1/tpg1> set auth mutual_userid=OutgoingUser2
/iscsi/iqn.20...:target1/tpg1> set auth mutual_password=AnotherPassword4
/iscsi/iqn.20...:target1/tpg1> exit
  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

targetcli 的相关文章

  • 树莓派4B开机自动发微信报告ip地址

    方法的实现基本基于博主虚宇宸轩的 实现 树莓派开机自动向微信发消息报告ip地址 xff08 无第三方代理 xff09 xff0c 具体原理和操作过程 xff0c 请参考该博主的文章 xff0c 写得很详细 xff0c 原理解释的也很清楚 本
  • 解决arm-none-eabi-gcc交叉编译helloworld程序segmentation fault 错误

    目标 xff1a 在x86 64主机上 windows 10或ubuntu 20 04 上交叉编译arm架构的helloworld程序 xff0c 然后通过scp将编译完的可执行文件传给树莓派4B xff0c 在树莓派上执行该程序 xff0
  • 中断方式及DMA工作详解

    一 轮询方式 对I O设备的程序轮询的方式 xff0c 是早期的计算机系统对I O设备的一种管理方式 它定时对各种设备轮流询问一遍有无处理要求 轮流询问之后 xff0c 有要求的 xff0c 则加以处理 在处理I O设备的要求之后 xff0
  • 构成帧的方法

    组帧 组帧的原因是为了在出错的时候只需要重发出错的帧 xff0c 而不需要重发全部数据 xff0c 从而提高效率 为了能让接收方正确地接收并检查所传输的帧 xff0c 发送方必须依据一定的规则把网络层传下来的分组封装成帧 这个动作称为组帧
  • AUTOWARE下底盘CAN通讯实现

    无人驾驶系列 autoware与底盘CAN通讯实现 本文介绍在使用autoware时 xff0c 如何将autoware发送的消息传输给底盘 xff0c 实现对线控底盘的控制 准备工作 xff1a 1 系统具备ROS和autoware 2
  • Boost库安装与使用

    Boost 库很不错 xff0c 所以我今天就安了它一下下 Boost 库不是 C 43 43 标准库的一部分 xff08 据说在下一版本的 C 43 43 标准会采纳它 xff09 xff0c 但它有一些标准库所没有的很有用的一些功能 x
  • ROS Ubuntu20.04多版本opencv运行及bug解决

    ubuntu系统装有多个版本opencv使用方法及可能出现的问题 xff1a 单opencv版本时使用命令 xff1a find package OpenCV 3 2 REQUIRED 其默认是在user local 目录下安装的openc
  • UDP编程

    一切以包裹为中心 xff0c 字节数组为核心 一 UDP的基本步骤 xff1a 1 xff09 发送端 package com sxt udp import java net DatagramPacket import java net D
  • LWIP之lwip_select函数使用

    本测试基于lwip2 1 2 参考了CSDN博主 64 则强 的文章 原文链接 xff1a https blog csdn net baidu 39191253 article details 127630186 部分地方做了修改 xff0
  • 直流无刷电机的调试与代码开源(配套资源)

    本周对手头的一款大疆M3508直流无刷电机调试的相关内容进行整理及个人的代码进行分享 一 M3508直流无刷电机 直流无刷电机的工作原理此处不做阐述 xff0c 相关资料也易查询 1 1电机结构与连接样式图 1 2电机参数 具体不多加阐述
  • Linux网络编程——UDP编程

    文章目录 前言一 udp编程相关函数1 socket函数2 bind函数3 sendto函数4 recvfrom函数5 close函数 二 实际案例总结 前言 1 UDP通信协议 xff0c 服务器端和客户端无需建立连接 xff0c 只需要
  • c++ vector用法 入门必看 超详细

    1 vector的作用 vector是最常用的容器之一 xff0c 功能十分强大 xff0c 可以储存 管理各种类型的数据 在很多情况下可以用来代替功能比较局限的普通数组 xff0c 因为我们知道 xff0c 普通数组只能实现一对一的映射而
  • 比特(bit)和字节(byte)

    比特 xff08 bit xff09 和字节 xff08 byte xff09 比特 一个0或者一个1存储为一个bit xff0c 是计算机中最小的一个存储单位 字节 计算机中最基本的存储单元是字节 xff0c 一个字节是由8个比特构成的
  • 图形化界面如何给画笔加粗

    public void actionPerformed ActionEvent e String bstr 61 e getActionCommand 获得该组件上的文本内容 xff1b str 61 e getActionCommand
  • 在Ubuntu18.04上面安装VMware-tools实现屏幕适配(保姆级别操作)

    默认在虚拟机上面安装了Ubuntu xff0c 如果没有安装点击下面链接 xff0c 对照教程安装即可 注意每个人需要的Ubuntu的版本不一样安装自己的需要下载就行不要完全照着教程来 http t csdn cn Q1r0d 看自己需要安
  • ipv6的一些特殊地址

    2008年7月3日第二次修正 xff01 昨天是修正了地址部分 xff0c 本想发上来的 xff0c 没来得及 今天修正了NDP协议 xff0c 接下来会是路由和转换部分 总结一下各协议的精华 xff1a OSPF在于LSA xff0c B
  • VMware上面实现Ubuntu和Windows文件的复制粘贴功能(以及虚拟机当中插入U盘能够显示)

    一 xff1a 安装VMware tools工具 点击以下链接有详细的教程和操作 xff08 如何在Ubuntu18 04上面安装VMware tools xff09 http t csdn cn is6rZ 二 xff1a 实现Windo
  • IDEA当中System.out.println输出中文乱码,以及控制台中文文字乱码的解决方案

    操作步骤如下 1System out println在控制台输出中文乱码的解决 xff08 原因分析 xff09 因为System out读取系统使用GBK编码输出 xff0c 而IEDA控制台使用的是UTF 8解码 xff08 解决方法
  • rosdep update延时问题最简单方法解决和ros一键下载

    ros一键下载 点击链接即可参考博客教程安装 http t csdn cn HqtoN rosdep update延时问题解决 xff08 time out xff09 方法一 xff1a 第一步 xff1a sudo apt get in

随机推荐

  • Typora基础操作

    Typora操作教程 文章目录 Typora操作教程一 xff1a Markdown语法1 1标题 1 2字体1 3线1 4列表1 5区块1 6代码1 7链接1 8图片二 xff1a Typora与数学公式2 1各种符号的实现2 2各种特殊
  • Tomcat下载和配置详细

    Tomcat下载和配置 1 下载Tomcat安装包 Tomcat下载地址 xff1a https tomcat apache org 点击圈画部分下载安装包 在这里插入图片描述 https img blog csdnimg cn 5b033
  • 【嵌入式知识08】STM32的USART串口通信,给上位机连续发送Hello Windows!

    本文主要介绍串口协议和RS 232 485标准 xff0c 以及RS232 485电平与TTL电平的区别 xff0c 了解 34 USB TTL转232 34 模块的工作原理 xff1b 并完成一个STM32的USART串口通讯程序 本文目
  • dm-vio-ros的安装(详细)

    前言 dm vio安装 参考博客 SLAM DM VIO ros版 安装和论文解读 在安装过程中 xff0c 有些地方提示的不是很清楚 xff0c 故写一篇记录避免再次犯错 在dm vio的一个子目录下创建ros工作空间 xff0c 如图所
  • C语言几种常见头文件,再也不怕用了函数不知道他“妈”的问题了!!!

    不完全统计 xff0c C语言标准库中的头文件有15个之多 xff0c 所以我主要介绍常用的这四个头文件stdio h xff0c string h xff0c math h xff0c stdlib h xff0c 以后用到其他的再做补充
  • K210与STM32之间的通信

    K210与STM32之间使用串口进行通信 K210 K210使用的开发环境是MaixPy IDE 具体解释见代码注释 提示 xff1a 这里可以添加本文要记录的大概内容 xff1a span class token keyword impo
  • Linux多线程编程问题:对‘pthread_create’未定义的引用

    在Linux下进行多线程程序测试时出现如下问题 xff1a 对 pthread create 未定义的引用 collect2 error ld returned 1 exit status 问题原因 xff1a linux下调用子线程时会用
  • PROC系列之---/proc/pid/stat

    proc stat 包含了所有CPU活跃的信息 xff0c 该文件中的所有值都是从系统启动开始累计到当前时刻 root 64 localhost cat proc 6873 stat 6873 a out R 6723 6873 6723
  • realsense d435 launch中修改频率不好用

    警告提示 xff1a Given stream configuration is not supported by the device span class token operator span Stream Color Stream
  • RK1109/RK1126--人工智能NPU强劲算力芯片

    瑞芯微电子第四届 开发者之春 大会上 xff0c 针对视觉领域 xff0c 推出全新的视觉处理器RV1109 1126芯片 从下图中我们可以清晰的看出 xff0c 在2020年瑞芯微推出的产品主要是面向物联网人工智能 机器视觉和机顶盒领域
  • Makefile

    Makefile的引入及规则 使用keil mdk avr等工具开发程序时点点鼠标就可以编译了 xff0c 使用Keil xff0c MDK xff0c AVR等工具开发程序时点点鼠标就可以编译了 它的内部机制是什么 它怎么组织管理程序 怎
  • 转载知乎-深度可分离卷积

    深度可分离卷积
  • vgg16网络改深度可分离卷积

    原网络 span class token keyword class span span class token class name CNN0 span span class token punctuation span nn span
  • Dropout 丢弃函数的使用

    Class span class token class name USeDropout span span class token punctuation span nn span class token punctuation span
  • libtorch-resnet18

    与大家分享一下自己在学习使用libtorch搭建神经网络时学到的一些心得和例子 xff0c 记录下来供大家参考 首先我们要参考着pytorch版的resnet来搭建 xff0c 这样我们可以省去不必要的麻烦 xff0c 上代码 xff1a
  • Yolov5 -libtorch部署

    将python训练好的网络模型转为可以再libtorch上走的pth模型 xff0c 转换代码如下 xff1a 可以直接赋值粘贴 import argparse import sys import time sys span class t
  • c++ 关于error LINK2005: XXXX已经在 .obj 中定义“的问题

    代码很多的时候出现这个问题很棘手 xff0c 小号大量时间来排查问题 xff0c 所以一边学习一边记录学习中出现的问题 原因 xff1a 是因为编程习惯的问题 xff0c 直接在头文件 h中直接定义了变量或者函数 xff0c 然后A cpp
  • 使用vs2019将libtorch或者网络打包成dll

    最近在搞一个程序 xff0c 需要把libtorch打包成dll xff0c 让别人使用 xff0c 在网上找了好久都没只有找到合适的答案 xff0c 最后在一个博主大哥那里找到了 xff0c 很是感激这位大哥与我们分享自己的经验 xff0
  • 【无标题】 libtorch C++ vs2017 debug模式可以正确加载模型,release模式错误

    转发 xff1a libtorch C 43 43 vs2017 debug模式可以正确加载模型 xff0c release模式错误 https blog csdn net weixin 43862688 article details 1
  • targetcli

    Linux IO LIO Target is an open source implementation of the SCSI target thathas become the standard one included in the