linux 安裝iscsi包
[root@localhost ~]# yum list | grep iscs
iscsi-initiator-utils.x86_64 6.2.0.874-7.el7 cr
iscsi-initiator-utils-iscsiuio.x86_64 6.2.0.874-7.el7 cr
libiscsi.x86_64 1.9.0-7.el7 cr
libvirt-daemon-driver-storage-iscsi.x86_64
[root@localhost ~]# yum install iscsi-initiator-utils
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解決依賴關系--> 正在檢查事務---> 軟體包 iscsi-initiator-utils.x86_64.0.6.2.0.874-7.el7 将被 安裝--> 正在處理依賴關系 iscsi-initiator-utils-iscsiuio >= 6.2.0.874-7.el7,它被軟體包 iscsi-initiator-utils-6.2.0.874-7.el7.x86_64 需要--> 正在檢查事務---> 軟體包 iscsi-initiator-utils-iscsiuio.x86_64.0.6.2.0.874-7.el7 将被 安裝--> 解決依賴關系完成
依賴關系解決=======================================================================================================================================================================
Package 架構 版本 源 大小=======================================================================================================================================================================正在安裝:
iscsi-initiator-utils x86_64 6.2.0.874-7.el7 cr 422 k
為依賴而安裝:
iscsi-initiator-utils-iscsiuio x86_64 6.2.0.874-7.el7 cr 90 k
事務概要=======================================================================================================================================================================安裝 1 軟體包 (+1 依賴軟體包)
總下載下傳量:512 k
安裝大小:2.6 M
Is this ok [y/d/N]: y
Downloading packages:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------總計 17 MB/s | 512 kB 00:00:00 Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 資料庫已被非 yum 程式修改。
正在安裝 : iscsi-initiator-utils-6.2.0.874-7.el7.x86_64 1/2
正在安裝 : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.el7.x86_64 2/2
驗證中 : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.el7.x86_64 1/2
驗證中 : iscsi-initiator-utils-6.2.0.874-7.el7.x86_64 2/2 已安裝:
iscsi-initiator-utils.x86_64 0:6.2.0.874-7.el7
作為依賴被安裝:
iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.el7
完畢!
[root@localhost ~]# systemctl enable iscsi
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:b5f8f023e12e
檢視linux iqn存儲上面配置映射

存儲劃分50t
發現存儲映射,
[root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.130.101:3260192.168.130.101:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
[fe80:0000:0000:0000:d239:eaff:fe1c:f4d5]:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4192.168.131.101:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4192.168.130.102:3260,2 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4192.168.131.102:3260,2 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
連接配接存儲
[root@localhost ~]# iscsiadm -m node -T iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4 -p 192.168.130.101 -l
Logging in to [iface: default, target: iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4, portal: 192.168.130.101,3260] (multiple)
Login to [iface: default, target: iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4, portal: 192.168.130.101,3260] successful.
[root@localhost ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
磁盤 /dev/sda:3998.0 GB, 3997997989888 位元組,7808589824 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):65536 位元組 / 131072 位元組
磁盤标簽類型:gpt
Disk identifier: DAAB1D88-0795-4EC3-89D7-2171BDD4AB12
# Start End Size Type Name 1 2048 1026047 500M EFI System EFI System Partition 2 1026048 2050047 500M Microsoft basic
3 2050048 7808587775 3.7T Linux LVM
磁盤 /dev/mapper/centos-root:214.7 GB, 214748364800 位元組,419430400 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):65536 位元組 / 131072 位元組
磁盤 /dev/mapper/centos-swap:17.2 GB, 17179869184 位元組,33554432 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):65536 位元組 / 131072 位元組
磁盤 /dev/mapper/centos-ava_app:3765.0 GB, 3765016985600 位元組,7353548800 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):65536 位元組 / 131072 位元組
磁盤 /dev/sdb:8095 MB, 8095006720 位元組,15810560 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):512 位元組 / 512 位元組
磁盤标簽類型:dos
磁盤辨別符:0xcad4ebea
裝置 Boot Start End Blocks Id System/dev/sdb4 * 256 15810559 7905152 b W95 FAT32
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
磁盤 /dev/sdc:54975.6 GB, 54975581388800 位元組,107374182400 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 4096 位元組
I/O 大小(最小/最佳):4096 位元組 / 4096 位元組
磁盤标簽類型:gpt
Disk identifier: E8286D05-FA93-4CE0-82F2-573F930EB840
# Start End Size Type Name 1 34 107374180447 50T Microsoft basic primary
Partition 1 does not start on physical sector boundary.
磁盤 /dev/sdd:20 MB, 20971520 位元組,40960 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):512 位元組 / 512 位元組
[root@localhost ~]#
存儲空間上次分過區了,這裡顯示有一個主分區。
如果是沒分區的話,可以使用parted進行分區(設立不介紹分區步驟了,參考parted 指令)
挂載分區,設定開機自動挂載
[root@localhost ~]# mkdir /DATA
[root@localhost ~]# mount /dev/sdc
sdc sdc1
[root@localhost ~]# mount /dev/sdc1 /DATA
[root@localhost ~]# vi /etc/fstab
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Apr 26 10:27:26 2021#
# 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/centos-root / xfs defaults 0 0/dev/sdc1 /DATA xfs defaults 0 0/dev/mapper/centos-ava_app /ava_app xfs defaults 0 0UUID=c6488b46-0004-4511-9fa1-3fbe2bcdfe40 /boot xfs defaults 0 0UUID=50D8-7F59 /boot/efi vfat umask=0077,shortname=winnt 0 0/dev/mapper/centos-swap swap swap defaults 0 0[root@localhost ~]#
重新開機後會失敗提示如下:
參考部落格:https://blog.csdn.net/jiyiyun/article/details/103798730
解決方法,删掉fstab裡面的新增内容後,重新注冊iscsi,重新配置開機自動挂載iscsi磁盤,操作步驟如下:
[root@localhost ~]# iscsiadm -m node -T iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4 -p 192.168.130.101:3260 --op update -n node.startup -v automatic
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3.7T 0 disk
├─sda1 8:1 0 500M 0 part /boot/efi
├─sda2 8:2 0 500M 0 part /boot
└─sda3 8:3 0 3.7T 0 part
├─centos-root 253:0 0 200G 0 lvm /
├─centos-swap 253:1 0 16G 0 lvm [SWAP]
└─centos-ava_app 253:2 0 3.4T 0 lvm /ava_app
sdb 8:16 0 50T 0 disk
└─sdb1 8:17 0 50T 0 part
sdc 8:32 0 20M 0 disk
[root@localhost ~]#
[root@localhost ~]# mount /dev/sdb1 /DATA/
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Apr 26 10:27:26 2021
#
# 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/centos-root / xfs defaults 0 0
/root/CentOS-7-x86_64-DVD-1804.iso /usbiso iso9660 defaults,ro,loop 0 0
UUID=16d940dc-0d29-4dd1-a652-f40efc83a492 /DATA ext4 defaults,_netdev 0 0
/dev/mapper/centos-ava_app /ava_app xfs defaults 0 0
UUID=c6488b46-0004-4511-9fa1-3fbe2bcdfe40 /boot xfs defaults 0 0
UUID=50D8-7F59 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
[root@localhost ~]#
[root@localhost ~]# df -T
檔案系統 類型 1K-塊 已用 可用 已用% 挂載點/dev/mapper/centos-root xfs 209611776 5435500 204176276 3% /devtmpfs devtmpfs 32627156 0 32627156 0% /dev
tmpfs tmpfs 32639532 0 32639532 0% /dev/shm
tmpfs tmpfs 32639532 10596 32628936 1% /run
tmpfs tmpfs 32639532 0 32639532 0% /sys/fs/cgroup/dev/sda2 xfs 508416 130148 378268 26% /boot/dev/sda1 vfat 511720 10008 501712 2% /boot/efi/dev/loop0 iso9660 4364408 4364408 0 100% /usbiso/dev/mapper/centos-ava_app xfs 3674977024 33840 3674943184 1% /ava_app/dev/sdb1 ext4 53473275824 20 50788904912 1% /DATA
tmpfs tmpfs 6527908 0 6527908 0% /run/user/0[root@localhost ~]#
[root@localhost ~]# blkid/dev/mapper/centos-root: UUID="1c857009-cf25-43dd-9e28-903bb8586b64" TYPE="xfs" /dev/sdb3: UUID="IHCc3d-1MO0-dAzB-ekoZ-pxrp-eR0Q-Bgd1qu" TYPE="LVM2_member" PARTUUID="192f9fb9-542a-4599-8e49-f6d2559bc678" /dev/sdb1: SEC_TYPE="msdos" UUID="D5FD-26B6" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="bad4e1f5-6923-471c-bc54-5b4c91abd22f" /dev/sdb2: UUID="af2a8d27-9f3a-4f83-8952-937ee1f03536" TYPE="xfs" PARTUUID="a880b557-e31a-4fa0-808b-6fd432c8ded6" /dev/sda1: UUID="9679951a-cc96-4c21-93ca-ee29f4aab2e7" TYPE="ext4" PARTLABEL="primary" PARTUUID="80c2e28f-9e2e-4079-a169-1e3fd7288ffc" /dev/mapper/centos-swap: UUID="84cd5ac5-9a99-4430-86fd-be41cd38af2a" TYPE="swap" /dev/sdc4: LABEL="CentOS 7 x8" UUID="B4FE-5315" TYPE="vfat" /dev/sdd1: UUID="34583c79-2cda-46bf-b885-91e88b111d83" TYPE="ext4" [root@localhost ~]#