CentOS-7掛載iscsi網路儲存
// 安裝相關軟體,其中kmod-xfs、xfsprogs為xfs檔案系統的元件。
yum install binutils iscsi-initiator-utils kmod-xfs xfsprogs
//啟動iscsi服務
service iscsi start
//檢視儲存伺服器的iscsi是否線上
iscsiadm -m discovery --type sendtargets --portal 192.168.2.30
如下是輸入上面的命令後返回的結果:
192.168.2.30:3260,1 iqn.1986-03.com.ibm:2145.v37001.node2
//設定開機自動登陸iscsi
iscsiadm -m node -T iqn.1986-03.com.ibm:2145.v37001.node2 -p 192.168.2.30:3260 --op update -n node.startup -v automatic
//顯示當前的連線
iscsiadm -m session
如下是輸入上面的命令後返回的結果:
tcp: [1] 192.168.2.30:3260,1 iqn.1986-03.com.ibm:2145.v37001.node2 (non-flash)
//檢視儲存空間是否已經顯示在磁碟列表中
fdisk -l
如下顯示了我儲存的空間
Disk /dev/sdb: 32985.3 GB, 32985348833280 bytes, 64424509440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disk label type: gpt
//用parted命令進行分割槽
parted /dev/sdb
mklabel gpt //建立標識
mkpart primary 0% 100% //分配所有空間
print //顯示當前分割槽
quit //退出
//用mkfs.ext4命令格式化硬碟
mkfs.ext4 -T largefile /dev/sdb1
引數說明:-T largefile對格式化大檔案速度要快很多
如下是輸入上面的命令後返回的輸出:
[[email protected]~]# mkfs.ext4 -T largefile /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=8 blocks, Stripe width=8 blocks
31457280 inodes, 8053063168 blocks
402653158 blocks (5.00%) reserved for the super user
First data block=0
245760 block groups
32768 blocks per group, 32768 fragments per group
128 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, 214990848, 512000000, 550731776, 644972544, 1934917632,
2560000000, 3855122432, 5804752896
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
//掛載
mount /dev/sdb1 /iscsi/
開機自動掛載
編輯/etc/fstab檔案,加入如下程式碼:
UUID=bdef610b-0f6c-4888-b3ea-7dc986109604 /iscsi ext4 defaults,_netdev 0 0
注意:一定要加_netdev不然系統會無法啟動,_netdev的意思是等有了網路之後再掛載。