iscsi搭建

ISCSI ————— linux 7.4 版本
iSCSI(Internet Small Computer System Interface,Internet 小型计算机系统接口)是一种由IBM公司研究开发的IP SAN技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,基于 TCP/IP的协议连接iSCSI服务端(Target)和客户端(Initiator),使得封装后的SCSI数据包可以在通用互联网传输,最终实现iSCSI服务端映射为一个存储空间(磁盘)提供给已连接认证后的客户端。portals入口(ip port)
术语概念
TPG:共享存储组,某个特定iSCSI目标要侦听的接口IP地址和TCP端口的集合。可以将目标配置添加到TPG以协调多个LUN的设置。
ACL:访问权限控制列表,一种使用节点IQN(通常是启动器名称)来验证启动器的访问权限的访问限制
IQN:iSCSI限定名称,全球唯一名称,用于以强制命名格式来识别启动器和目标。
IQN格式如下:
iqn.YYYY-MM.com.reversed.domain[:optional_string]
iqn:表示此名称使用域为标识符。
YYYY-MM:表示拥有域名的年月时间。
com.reversed.domain:拥有此iSCSI组织的逆向域名
:optional_string:以冒号为前缀的可选字符串,全球唯一,由域所有者分配,其中可包含冒号为分割符的组织边界
LUN:逻辑单元号,带有编号的块设备,连接到目标且通过目标来使用。可以有一个或多个LUN连接到单个目标,但通常一个目标提供一个LUN
portals入口:目标或启动器上用于建立的IP地址和端口。

工作原理
iSCSI系统由SCSI适配器发送一个SCSI命令。
命令封装到TCP/IP包中并送入到以太网络。
接收方从TCP/IP包中抽取SCSI命令并执行相关操作。
把返回的SCSI命令和数据封装到TCP/IP包中,将它们发回到发送方。
系统提取出数据或命令,并把它们传回SCSI子系统。
工作流程
通过iscsi实现存储共享,创建IQN用于识别启动器和目标,然后建立tpg共享存储组,设置相应的访问控制权限,然后在共享存储组添加lun逻辑单元(存储设备),然后建立实现共享

服务端配置:
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
安装软件
[root@localhost ~]# yum install -y targetcli.noarch
[root@localhost ~]# targetcli
targetcli shell version 2.1.fb46
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]
/> cd backstores/block
/backstores/block> create name=LUN0 dev=/dev/sdb ##创建一个块存储对象
Created block storage object LUN0 using /dev/sdb.
/backstores/block> create name=LUN1 dev=/dev/sda5
Created block storage object LUN1 using /dev/sda5.
/backstores/block> create name=LUN2 dev=/dev/sda6
Created block storage object LUN2 using /dev/sda6.
/backstores/block> ls
o- block …………………………………………………………………………………… [Storage Objects: 3]
o- LUN0 ……………………………………………………………… [/dev/sdb (20.0GiB) write-thru deactivated]
| o- alua ……………………………………………………………………………………. [ALUA Groups: 1]
| o- default_tg_pt_gp …………………………………………………………… [ALUA state: Active/optimized]
o- LUN1 …………………………………………………………….. [/dev/sda5 (0 bytes) write-thru deactivated]
| o- alua ……………………………………………………………………………………. [ALUA Groups: 1]
| o- default_tg_pt_gp …………………………………………………………… [ALUA state: Active/optimized]
o- LUN2 …………………………………………………………….. [/dev/sda6 (0 bytes) write-thru deactivated]
o- alua ……………………………………………………………………………………. [ALUA Groups: 1]
o- default_tg_pt_gp …………………………………………………………… [ALUA state: Active/optimized]
/backstores/block> cd ..
/backstores> cd ..
/> ls
o- / ……………………………………………………………………………………………………. […]
o- backstores ………………………………………………………………………………………….. […]
| o- block ……………………………………………………………………………….. [Storage Objects: 3]
| | o- LUN0 ………………………………………………………….. [/dev/sdb (20.0GiB) write-thru deactivated]
| | | o- alua ………………………………………………………………………………… [ALUA Groups: 1]
| | | o- default_tg_pt_gp ……………………………………………………….. [ALUA state: Active/optimized]
| | o- LUN1 …………………………………………………………. [/dev/sda5 (0 bytes) write-thru deactivated]
| | | o- alua ………………………………………………………………………………… [ALUA Groups: 1]
| | | o- default_tg_pt_gp ……………………………………………………….. [ALUA state: Active/optimized]
| | o- LUN2 …………………………………………………………. [/dev/sda6 (0 bytes) write-thru deactivated]
| | 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: 0]
o- loopback ……………………………………………………………………………………… [Targets: 0]
/> cd iscsi
/iscsi> ls
o- iscsi ………………………………………………………………………………………..
注意:
在7.0版本中,创建target不会自动创建portal,但是在7.2版本中会自动创建portal,如果需要自定义ip和端口,需要在创建target之前关闭自动创建portal功能
使用以下命令
/iscsi>set group=global auto_add_default_portal=false
/iscsi> set group=global auto_add_default_portal=false
Parameter auto_add_default_portal is now ‘false’.
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14.
Created TPG 1.
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145.
Created TPG 1.
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353.
Created TPG 1.
/iscsi> ls
o- iscsi ………………………………………………………………………………………….. [Targets: 3]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145 …………………………………………… [TPGs: 1]
| o- tpg1 ………………………………………………………………………………. [no-gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 0]
| o- portals …………………………………………………………………………………… [Portals: 0]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14 …………………………………………… [TPGs: 1]
| o- tpg1 ………………………………………………………………………………. [no-gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 0]
| o- portals …………………………………………………………………………………… [Portals: 0]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353 …………………………………………… [TPGs: 1]
o- tpg1 ………………………………………………………………………………. [no-gen-acls, no-auth]
o- acls ………………………………………………………………………………………… [ACLs: 0]
o- luns ………………………………………………………………………………………… [LUNs: 0]
o- portals …………………………………………………………………………………… [Portals: 0]

/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145/tpg1/
设置发起端的访问策略
/iscsi/iqn.20…17279145/tpg1>set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
Parameter demo_mode_write_protect is now ‘0’.
Parameter authentication is now ‘0’.
Parameter generate_node_acls is now ‘1’.
Parameter cache_dynamic_acls is now ‘1’.
/iscsi/iqn.20…17279145/tpg1> cd luns
/iscsi/iqn.20…145/tpg1/luns> create /backstores/block/LUN0
Created LUN 0.
/iscsi/iqn.20…353/tpg1/luns> cd ..
切换到 portals 的子目录 并且指定iscsi taget端的ip和使用的端口号(端口号默认是3260):
/iscsi/iqn.20…17279145/tpg1> cd portals
/iscsi/iqn.20…/tpg1/portals> create 192.168.223.145 ip_port=3260
Using default IP port 3260
Created network portal 192.168.223.145:3260.
/iscsi/iqn.20…/tpg1/portals> ls
o- portals ………………………………………………………………………………………… [Portals: 1]
o- 192.168.223.145:3260 ………………………………………………………………………………….. [OK]
/iscsi/iqn.20…/tpg1/portals> cd ..
/iscsi/iqn.20…17279145/tpg1> cd ../..
/iscsi> ls
o- iscsi ………………………………………………………………………………………….. [Targets: 3]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 …………………………………………………………. [block/LUN0 (/dev/sdb) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 1]
| o- 192.168.223.145:3260 …………………………………………………………………………….. [OK]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 ………………………………………………………… [block/LUN1 (/dev/sda5) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 0]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353 …………………………………………… [TPGs: 1]
o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
o- acls ………………………………………………………………………………………… [ACLs: 0]
o- luns ………………………………………………………………………………………… [LUNs: 1]
| o- lun0 ………………………………………………………… [block/LUN2 (/dev/sda6) (default_tg_pt_gp)]
o- portals …………………………………………………………………………………… [Portals: 0]

/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14/tpg1/
/iscsi/iqn.20…92afff14/tpg1> set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
Parameter demo_mode_write_protect is now ‘0’.
Parameter authentication is now ‘0’.
Parameter generate_node_acls is now ‘1’.
Parameter cache_dynamic_acls is now ‘1’.
/iscsi/iqn.20…92afff14/tpg1> cd luns
/iscsi/iqn.20…f14/tpg1/luns> create /backstores/block/LUN1
Created LUN 0.
/iscsi/iqn.20…f14/tpg1/luns> cd ..
/iscsi/iqn.20…f14/tpg1/> cd portals
/iscsi/iqn.20…/tpg1/portals> create 192.168.223.145 ip_port=3261
Created network portal 192.168.223.145:3261.
/iscsi/iqn.20…/tpg1/portals> cd ../../..
/iscsi> ls
o- iscsi ………………………………………………………………………………………….. [Targets: 3]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 …………………………………………………………. [block/LUN0 (/dev/sdb) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 1]
| o- 192.168.223.145:3260 …………………………………………………………………………….. [OK]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 ………………………………………………………… [block/LUN1 (/dev/sda5) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 1]
| o- 192.168.223.145:3261 …………………………………………………………………………….. [OK]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353 …………………………………………… [TPGs: 1]
o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
o- acls ………………………………………………………………………………………… [ACLs: 0]
o- luns ………………………………………………………………………………………… [LUNs: 1]
| o- lun0 ………………………………………………………… [block/LUN2 (/dev/sda6) (default_tg_pt_gp)]
o- portals …………………………………………………………………………………… [Portals: 0]

/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353/tpg1/
/iscsi/iqn.20…20eae353/tpg1> ls
o- tpg1 ………………………………………………………………………………….. [no-gen-acls, no-auth]
o- acls ……………………………………………………………………………………………. [ACLs: 0]
o- luns ……………………………………………………………………………………………. [LUNs: 0]
o- portals ………………………………………………………………………………………. [Portals: 0]
/iscsi/iqn.20…20eae353/tpg1> set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
Parameter demo_mode_write_protect is now ‘0’.
Parameter authentication is now ‘0’.
Parameter generate_node_acls is now ‘1’.
Parameter cache_dynamic_acls is now ‘1’.
/iscsi/iqn.20…20eae353/tpg1> cd luns
/iscsi/iqn.20…353/tpg1/luns> create /backstores/block/LUN2
Created LUN 0.
/iscsi/iqn.20…353/tpg1/luns> cd ..
/iscsi/iqn.20…353/tpg1/> cd portals
/iscsi/iqn.20…/tpg1/portals> create 192.168.223.145 ip_port=3262
Created network portal 192.168.223.145:3262.
/iscsi/iqn.20…/tpg1/portals> cd ../../..
/iscsi> ls
o- iscsi ………………………………………………………………………………………….. [Targets: 3]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 …………………………………………………………. [block/LUN0 (/dev/sdb) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 1]
| o- 192.168.223.145:3260 …………………………………………………………………………….. [OK]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14 …………………………………………… [TPGs: 1]
| o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
| o- acls ………………………………………………………………………………………… [ACLs: 0]
| o- luns ………………………………………………………………………………………… [LUNs: 1]
| | o- lun0 ………………………………………………………… [block/LUN1 (/dev/sda5) (default_tg_pt_gp)]
| o- portals …………………………………………………………………………………… [Portals: 1]
| o- 192.168.223.145:3261 …………………………………………………………………………….. [OK]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353 …………………………………………… [TPGs: 1]
o- tpg1 …………………………………………………………………………………. [gen-acls, no-auth]
o- acls ………………………………………………………………………………………… [ACLs: 0]
o- luns ………………………………………………………………………………………… [LUNs: 1]
| o- lun0 ………………………………………………………… [block/LUN2 (/dev/sda6) (default_tg_pt_gp)]
o- portals …………………………………………………………………………………… [Portals: 1]
o- 192.168.223.145:3262 …………………………………………………………………………….. [OK]

/iscsi> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@localhost ~]# systemctl restart target.service
[root@localhost ~]# systemctl status target.service
● target.service - Restore LIO kernel target configuration
Loaded: loaded (/usr/lib/systemd/system/target.service; disabled; vendor preset: disabled)
Active: active (exited) since Fri 2018-08-17 14:16:16 CST; 6s ago
Process: 2381 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS)
Main PID: 2381 (code=exited, status=0/SUCCESS)

Aug 17 14:16:16 localhost.localdomain systemd[1]: Starting Restore LIO kernel target configuration…
Aug 17 14:16:16 localhost.localdomain systemd[1]: Started Restore LIO kernel target configuration.
验证
windows客户端
使用iscsi发起程序

Linux客户端
[root@localhost ~]# yum install iscsi-initiator-utils.i686
检查是否可以发现
[root@localhost ~]# iscsiadm -m discovery -t sendtargets –portal 192.168.223.145
192.168.223.145:3262,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353
192.168.223.145:3260,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145
192.168.223.145:3261,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14
测试挂载设备
[root@localhost ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353 -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353, portal: 192.168.223.145,3262] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.8a6420eae353, portal: 192.168.223.145,3262] successful.
[root@localhost ~]# fdisk -l

磁盘 /dev/sda:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000bc557

设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 83886079 41737216 8e Linux LVM

磁盘 /dev/sdb:1071 MB, 1071644672 字节,2093056 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 4194304 字节
[root@localhost ~]# lsscsi
[0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
[4:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0
[33:0:0:0] disk LIO-ORG LUN2 4.0 /dev/sdb
[root@localhost ~]# mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
65408 inodes, 261632 blocks
13081 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@localhost ~]# mount /dev/sdb /mnt
[root@localhost ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145 -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145, portal: 192.168.223.145,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.229817279145, portal: 192.168.223.145,3260] successful.
[root@localhost ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14 -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14, portal: 192.168.223.145,3261] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.884992afff14, portal: 192.168.223.145,3261] successful.
[root@localhost mnt]# fdisk -l

磁盘 /dev/sda:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000bc557

设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 83886079 41737216 8e Linux LVM

磁盘 /dev/sdb:1071 MB, 1071644672 字节,2093056 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 4194304 字节

磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 4194304 字节
磁盘标签类型:dos
磁盘标识符:0x394a63e9

设备 Boot Start End Blocks Id System

磁盘 /dev/sdd:1073 MB, 1073741824 字节,2097152 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 4194304 字节

[root@localhost mnt]# mkfs.ext4 /dev/sdc
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdc is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@localhost mnt]# mount /dev/sdc /mnt
[root@localhost mnt]# mkfs.ext4 /dev/sdd
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdd is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
开机自动挂载
[root@localhost ~]# blkid
/dev/sda1: UUID=”5e21e62a-44d4-47a5-8af7-cee9de6a7ba3” TYPE=”xfs”
/dev/sda2: UUID=”z4YXk0-HOHV-LUKT-E0q9-ukqB-qrap-CsVYVk” TYPE=”LVM2_member”
/dev/sr0: UUID=”2017-07-11-01-39-24-00” LABEL=”RHEL-7.4 Server.x86_64” TYPE=”iso9660” PTTYPE=”dos”
/dev/mapper/rhel-root: UUID=”3be1d8d8-04b5-410d-872f-37ef616e2b4f” TYPE=”xfs”
/dev/mapper/rhel-swap: UUID=”aad72dfe-7d0c-4fa5-a957-650eaa86feb2” TYPE=”swap”
/dev/sdb: UUID=”c02b3669-dd37-4d17-a159-5ba8b357b6b9” TYPE=”ext4”
/dev/sdc: UUID=”de514381-8315-414d-889d-b8c5c85c3394” TYPE=”ext4”
/dev/sdd: UUID=”2b0b6216-5ac4-4dbe-b540-dacd3d0804e0” TYPE=”ext4”
[root@localhost ~]# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon May 28 13:56:49 2018
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=5e21e62a-44d4-47a5-8af7-cee9de6a7ba3 /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
UUID=c02b3669-dd37-4d17-a159-5ba8b357b6b9 /mnt ext4 defaults,_netdev 0 0
UUID=de514381-8315-414d-889d-b8c5c85c3394 /mnt ext4 defaults,_netdev 0 0
UUID=2b0b6216-5ac4-4dbe-b540-dacd3d0804e0 /mnt ext4 defaults,_netdev 0 0
“/etc/fstab” 14L, 726C
由于/dev/sdb是一块网络存储设备,而iSCSI协议是基于TCP/IP网络进行传输数据的,因此必须在/etc/fstab配置文件中添加上_netdev参数,代表当系统联网启动后再进行挂载操作,避免系统开机时间过长或启动失败:

猜你喜欢

转载自blog.csdn.net/weixin_42859372/article/details/81805274