linux的target

添加磁盘
磁盘分区
 su -
centos
lsblk
fdisk /dev/nvme0n2
n(两次)(分完)
w
lsblk
linux虚拟机配置ip,
    1  nmcli connection add con-name ddd type ethernet ifname ens160 autoconnect yes ipv4.method manual ipv4.addresses 172.16.0.3/16
    2  ping 172.16.0.2
    3  lsblk
    4  iscsiadm -m discovery -t st -p 172.16.0.2
    5  iscsiadm -m node -l
    6  lsblk
(nmcli connection up ens160  
ip a)


开始:
lsblk
mkdir /mnt/dvd
mount /dev/sr0 /mnt/dvd/
    8  cd /etc/yum.repos.d/
    9  ls
   10  rm * -rf
   11  ls
   12  vim local.repo 配置本地yum源

[base]
name=base
baseurl=file:///mnt/dvd/BaseOS
enabled=1
gpgcheck=0

[app]
name=app
baseurl=file:///mnt/dvd/AppStream
enabled=1
gpgcheck=0
:wq!


   15  cat local.repo 
   16  yum makecache
   17  yum install targetcli -y


安装targetcli

[root@localhost yum.repos.d]# targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]


使用block映射。

/> cd backstores/block
/backstores/block>create win.disk /dev/nvme0n2p1
ls
create linux.disk /dev/nvme0n2p3 
/backstores/block> ls
o- block .................................................. [Storage Objects: 2]
  o- linux.disk .............. [/dev/nvme0n2p3 (29.0GiB) write-thru deactivated]
  | o- alua ................................................... [ALUA Groups: 1]
  |   o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]
  o- win.disk ................ [/dev/nvme0n2p1 (20.0GiB) write-thru deactivated]
    o- alua ................................................... [ALUA Groups: 1]
      o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]
/backstores/block> cd /iscsi 
ls 
创建iscsi对象,
/iscsi> create 
Created target iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.2a8acda9de2b.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi .......................................................... [Targets: 0]
/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.2a8acda9de2b.
ls
cd tpg1/
ls
cd luns
ls
create /backstores/block/win.disk
ls
cd ..
ls
cd acls
ls
create iqn.1991-05.com.microsoft:win-gd5bn2d89d5(windows虚拟机的iqn) 
/iscsi/iqn.20...e2b/tpg1/acls> cd /
/> ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 2]
  | | o- linux.disk .......... [/dev/nvme0n2p3 (29.0GiB) write-thru deactivated]
  | | | o- alua ............................................... [ALUA Groups: 1]
  | | |   o- default_tg_pt_gp ................... [ALUA state: Active/optimized]
  | | o- win.disk .............. [/dev/nvme0n2p1 (20.0GiB) write-thru activated]
  | |   o- alua ............................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ................... [ALUA state: Active/optimized]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 2]
  | o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.2a8acda9de2b ... [TPGs: 1]
  | | o- tpg1 ........................................... [no-gen-acls, no-auth]
  | |   o- acls ...................................................... [ACLs: 1]
  | |   | o- iqn.1991-05.com.microsoft:win-gd5bn2d89d5 ........ [Mapped LUNs: 1]
  | |   |   o- mapped_lun0 .......................... [lun0 block/win.disk (rw)]
  | |   o- luns ...................................................... [LUNs: 1]
  | |   | o- lun0 ......... [block/win.disk (/dev/nvme0n2p1) (default_tg_pt_gp)]
  | |   o- portals ................................................ [Portals: 1]
  | |     o- 0.0.0.0:3260 ................................................. [OK]
  | o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.78ea3dce79db ... [TPGs: 1]
  |   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]
  o- loopback ..................................................... [Targets: 0]
/> exit
开防火墙
systemctl restart targetd
firewall-cmd --add-port=3260/tcp
firewall-cmd --add-port=3260/tcp --permanent

systemctl stop firewalld.service

去windows虚拟机发现门户(IP是linux虚拟机的)后连接
连接成功就可以去磁盘管理创建新卷

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值