Skip to content Skip to main navigation Skip to footer

CentOS7/RHEL7:如何创建并挂载SCSI 共享磁盘

在centos7 系统下我们如何来创建并挂载SCSI 共享磁盘呢?本文将会讲述通过两个虚拟机作为scsi的服务器端和客户端来配置创建并挂载scsi共享磁盘。
实验设备:
用虚拟机虚拟两个 centos6.3 -64bit 系统,并配置好yum
ip设置:
scsi服务端:10.1.1.222
scsi客户端(挂载端):10.1.1.1
1、在服务端安装软件并配置好共享的磁盘,首先在虚拟机中新加入一块硬盘,大小随意。(这里添加100G)

[root@localhost ~]# fdisk -l
 Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005bb6c
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         281     2048000   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             281        2611    18717696   83  Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077087
   Device Boot      Start         End      Blocks   Id  System
 

2、安装scsi服务端软件

yum install scsi-target-utils -y
 

共享磁盘(在配置文件中加入以下代码即可)

vim /etc/tgt/targets.conf
    <target iqn.2008-09.com.example:server.target1>
        backing-store /dev/sdb
    </target>
 

启动服务

service tgtd restart
 

关闭防火墙和selinux
3、在客户端安装客户端软件,并设置挂载
安装客户端软件

yum install iscsi-initiator-utils -y
 

查看是否有共享磁盘

iscsiadm --mode discoverydb --type sendtargets --portal 10.1.1.222 --discover
 

出现以下则表示有共享磁盘 10.1.1.222:3260,1 iqn.2008-09.com.example:server.target1
挂载磁盘

iscsiadm --mode node --targetname iqn.2008-09.com.example:server.target1 --portal 10.1.1.222:3260 --login
 

注意:中间2008-09这段是填写上面查询出来的那个磁盘名
成功挂载后有以下提示

[root@localhost ~]#  iscsiadm --mode node --targetname iqn.2008-09.com.example:server.target1 --portal 10.1.1.222:3260 --login
Logging in to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 10.1.1.222,3260] (multiple)
Login to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 10.1.1.222,3260] successful.
 

查看是否挂载成功
[root@localhost ~]# fdisk -l

 Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00036380
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         281     2048000   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             281        2611    18717696   83  Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077087
   Device Boot      Start         End      Blocks   Id  System
 

成功挂载100G硬盘。

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.