配置举例
更新时间 2026-03-24 17:15:47
最近更新时间: 2026-03-24 17:15:47
本节给出Linux客户端挂载HBlock单机版的卷示例。
应用场景
Linux客户端需要连接HBlock单机版的卷。
需要连接的HBlock单机版的卷为lund1和lunf1,lund1有CHAP认证。
前置条件
对于需要连接HBlock单机版的客户端,已经按照客户端配置的前置条件成准备工作。
对于HBlock服务器端,已经成功创建卷lund1和lunf1。
操作步骤
HBlock服务器端
查询要连接的LUN及LUN对应iSCSI Target的详细信息。
[root@hblockserver CTYUN_HBlock_Plus_4.0.0_x64]# ./stor lun ls -n lund1
LUN Name: lund1 (LUN 0)
Storage Mode: Local
Capacity: 500 GiB
Status: Normal
iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetd.4(192.168.0.32:3260,Active)
Create Time: 2026-01-21 10:00:34
Local Sector Size: 4096 Bytes
Data Health: 100% normal, 0% low redundancy, 0% error
Write Policy: WriteBack
WWID: 33000000068f2f320
UUID: lun-uuid-3ddcc779-bf34-42b9-ac5e-0339dae28821
Path: /mnt/storage01
Snapshot Count: 0
Snapshot Size: 0 B (Note: Snapshot size may vary due to LUN issues or parent snapshot deletion.)
[root@hblockserver CTYUN_HBlock_Plus_4.0.0_x64]# ./stor target ls -n targetd
Target Name: targetd
Max Sessions: 2
Create Time: 2026-01-21 09:59:12
iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetd.4(192.168.0.32:3260)
LUN: lund1(LUN 0)
Reclaim Policy: Retain
CHAP: testd,T12345678912,Enabled
[root@hblockserver CTYUN_HBlock_Plus_4.0.0_x64]# ./stor lun ls -n lunf1
LUN Name: lunf1 (LUN 0)
Storage Mode: Local
Capacity: 600 GiB
Status: Normal
iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetf.5(192.168.0.32:3260,Active)
Create Time: 2026-01-21 10:00:56
Local Sector Size: 4096 Bytes
Data Health: 100% normal, 0% low redundancy, 0% error
Write Policy: WriteBack
WWID: 33000000030f798a5
UUID: lun-uuid-7b7f91d8-b75e-4de2-ac69-621e4be7a0cf
Path: /mnt/storage01
Snapshot Count: 0
Snapshot Size: 0 B (Note: Snapshot size may vary due to LUN issues or parent snapshot deletion.)
[root@hblockserver CTYUN_HBlock_Plus_4.0.0_x64]# ./stor target ls -n targetf
Target Name: targetf
Max Sessions: 2
Create Time: 2026-01-21 10:00:15
iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetf.5(192.168.0.32:3260)
LUN: lunf1(LUN 0)
Reclaim Policy: RetainLinux客户端
发现lund1和lunf1的Target:
[root@client ~]# iscsiadm -m discovery -t st -p 192.168.0.32 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetf.5 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetd.4 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetc.3登录iSCSI存储。
登录lund1的iSCSI存储,需要进行CHAP认证:
[root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.authmethod --value=CHAP [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.username --value=testd [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.password --value=************* [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -p 192.168.0.32:3260 -l Logging in to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetd.4, portal: 192.168.0.32,3260] (multiple) Login to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetd.4, portal: 192.168.0.32,3260] successful.登录lunf1的iSCSI存储
[root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetf.5 -p 192.168.0.32:3260 -l Logging in to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetf.5, portal: 192.168.0.32,3260] (multiple) Login to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetf.5, portal: 192.168.0.32,3260] successful.
显示会话情况,查看当前iSCSI连接。
[root@client ~]# iscsiadm -m session tcp: [1] 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetd.4 (non-flash) tcp: [2] 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetf.5 (non-flash)查看iSCSI磁盘、磁盘对应的LUN(通过lsscsi -i可以查看LUN的wwid)。
[root@client ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 500G 0 disk sdb 8:16 0 600G 0 disk vda 253:0 0 40G 0 disk ├─vda1 253:1 0 4G 0 part └─vda2 253:2 0 36G 0 part / vdb 253:16 0 100G 0 disk └─vdb1 253:17 0 100G 0 part /mnt/storage01 vdc 253:32 0 100G 0 disk vdd 253:48 0 100G 0 disk [root@client ~]# lsscsi -i [2:0:0:0] disk CTYUN iSCSI LUN Device 1.00 /dev/sda 33000000068f2f320 [3:0:0:0] disk CTYUN iSCSI LUN Device 1.00 /dev/sdb 33000000030f798a5说明
可以看出/dev/sda对应HBlock卷lund1(卷WWID为33000000068f2f320),/dev/sdb对应HBlock卷lunf1(卷WWID为33000000030f798a5)。
5. 格式化iSCSI磁盘。
[root@client ~]# mkfs.ext4 /dev/sda
mke2fs 1.42.9 (28-Dec-2013)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768000 inodes, 131072000 blocks
6553600 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2279604224
4000 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, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@client ~]# mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
39321600 inodes, 157286400 blocks
7864320 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2304770048
4800 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, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done挂载iSCSI磁盘。
将iSCSI磁盘分区挂载到本地目录上,挂载之后可以写入数据。
[root@client ~]# mount /dev/sda /mnt/disk_sda [root@client ~]# mount /dev/sdb /mnt/disk_sdb [root@client ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 500G 0 disk /mnt/disk_sda sdb 8:16 0 600G 0 disk /mnt/disk_sdb vda 253:0 0 40G 0 disk ├─vda1 253:1 0 4G 0 part └─vda2 253:2 0 36G 0 part / vdb 253:16 0 100G 0 disk └─vdb1 253:17 0 100G 0 part /mnt/storage01 vdc 253:32 0 100G 0 disk vdd 253:48 0 100G 0 disk