Iscsi

iPXE 到 iSCSI 目標 - 缺少參數和命名混亂

  • July 28, 2021

我有一個pyTarget iSCSI 目標。我可以使用 iPXE 連接到目標並安裝 Ubuntu。但是,安裝後,我無法啟動到映像。

pyTarget 配置.xml:

<root>
   <!-- configure target console -->
   <console ip="" port="3260" debug_level="6" />

   <!-- configure the first target -->
   <target name="iscsi" ip="192.168.1.10" port="3260" portal="1">
       <!-- the first iqn of this target configured for disk array -->
       <host name="iqn.2006-11.1" target_pwd="" initiator_pwd="">
           <lun id="0" type="0" path="E:\pyTarget\ubuntu16.ima" capacity="81943040" />
       </host>
   </target>
</root>

pyTarget 啟動時的控制台:

INFO:   pyTarget 1.5.7.1 2010-12-26
INFO:   start iSCSI Service ...
INFO:   start iSNS Service ...
INFO:   initialize virtual device, please wait...
INFO:   start Http Service ...
DEBUG:  create target iscsi 192.168.1.10 3260 1
DEBUG:  create host iqn.2006-11.1
DEBUG:  target iscsi add host iqn.2006-11.1
DEBUG:  Disk(E:\pyTarget\ubuntu16.ima) : initialize finish!
DEBUG:  host iqn.2006-11.1 add lun 0.
DEBUG:  configure target done
INFO:   initialize finish, start to run ...

安裝開始時:

DEBUG:  create connect
INFO:   initiator 192.168.1.15:38822 connect.
NEGOTIATION:    SessionType = Discovery
NEGOTIATION:    TargetName = iscsi
NEGOTIATION:    InitiatorName = iqn.2006-11.1
DEBUG:  create session 00023d000000-0001.
DEBUG:  host iqn.2006-11.1 add session 00023d000000-0001.
INFO:   SessionID: 00023d000000-0001
DEBUG:  session 00023d000000-0001 add connect 0.
INFO:   ConnectID: 0
NEGOTIATION:    TargetPortalGroupTag = 1
NEGOTIATION:    HeaderDigest = None
NEGOTIATION:    DataDigest = None
NEGOTIATION:    MaxRecvDataSegmentLength = 32768
NEGOTIATION:    TargetMaxRecvdataLength = 65536
NEGOTIATION:    ErrorRecoveryLevel = 0
NEGOTIATION:    DefaultTime2Retain = 0
NEGOTIATION:    DefaultTime2Wait = 2
NEGOTIATION:    OFMarker = No
NEGOTIATION:    IFMarker = No
DEBUG:  connect 0 login finish
COMMAND:        Text Request
DEBUG:  session 00023d000000-0001 add connect 0.
DEBUG:  host iqn.2006-11.1 remove session 00023d000000-0001.
DEBUG:  destroy session 00023d000000-0001.
DEBUG:  connect 0 finish.
DEBUG:  create connect
DEBUG:  destroy connect 0
INFO:   initiator 192.168.1.15:38824 connect.
NEGOTIATION:    SessionType = Discovery
NEGOTIATION:    TargetName = iscsi
NEGOTIATION:    InitiatorName = iqn.2006-11.1
DEBUG:  create session 00023d000000-0002.
DEBUG:  host iqn.2006-11.1 add session 00023d000000-0002.
INFO:   SessionID: 00023d000000-0002
DEBUG:  session 00023d000000-0002 add connect 0.
INFO:   ConnectID: 0
NEGOTIATION:    TargetPortalGroupTag = 1
NEGOTIATION:    HeaderDigest = None
NEGOTIATION:    DataDigest = None
NEGOTIATION:    MaxRecvDataSegmentLength = 32768
NEGOTIATION:    TargetMaxRecvdataLength = 65536
NEGOTIATION:    ErrorRecoveryLevel = 0
NEGOTIATION:    DefaultTime2Retain = 0
NEGOTIATION:    DefaultTime2Wait = 2
NEGOTIATION:    OFMarker = No
NEGOTIATION:    IFMarker = No
DEBUG:  connect 0 login finish
COMMAND:        Text Request
DEBUG:  session 00023d000000-0002 add connect 0.
DEBUG:  host iqn.2006-11.1 remove session 00023d000000-0002.
DEBUG:  destroy session 00023d000000-0002.
DEBUG:  connect 0 finish.
DEBUG:  create connect
DEBUG:  destroy connect 0
INFO:   initiator 192.168.1.15:38826 connect.
NEGOTIATION:    SessionType = Normal
NEGOTIATION:    TargetName = iscsi
NEGOTIATION:    InitiatorName = iqn.2006-11.1
DEBUG:  create session 00023d010000-0003.
DEBUG:  host iqn.2006-11.1 add session 00023d010000-0003.
INFO:   SessionID: 00023d010000-0003
DEBUG:  session 00023d010000-0003 add connect 0.
INFO:   ConnectID: 0
NEGOTIATION:    TargetPortalGroupTag = 1
NEGOTIATION:    TargetAlias = DESKTOP-54T1C9D
NEGOTIATION:    HeaderDigest = None
NEGOTIATION:    DataDigest = None
NEGOTIATION:    MaxRecvDataSegmentLength = 65536
NEGOTIATION:    TargetMaxRecvdataLength = 65536
NEGOTIATION:    ErrorRecoveryLevel = 0
NEGOTIATION:    DefaultTime2Retain = 0
NEGOTIATION:    DefaultTime2Wait = 2
NEGOTIATION:    OFMarker = No
NEGOTIATION:    IFMarker = No
NEGOTIATION:    MaxConnections = 1
NEGOTIATION:    InitialR2T = Yes
NEGOTIATION:    ImmediateData = Yes
NEGOTIATION:    DataPDUInOrder = Yes
NEGOTIATION:    DataSequenceInOrder = Yes
NEGOTIATION:    MaxOutstandingR2T = 1
NEGOTIATION:    MaxBurstLength = 262144
NEGOTIATION:    FirstBurstLength = 65536
DEBUG:  connect 0 login finish
COMMAND:        SCSI Request
COMMAND:        Inquiry LUN:0
COMMAND:        SCSI Request
COMMAND:        Inquiry LUN:0
COMMAND:        SCSI Request

安裝完成後,我嘗試啟動映像:

COMMAND:        SCSI Request
COMMAND:        Write(10)  LBA:0x1c40800 LEN:0x8 LUN:0
COMMAND:        SCSI Request
COMMAND:        Write(10)  LBA:0x1c40800 LEN:0x8 LUN:0
COMMAND:        SCSI Request
COMMAND:        Write(10)  LBA:0x1c40800 LEN:0x8 LUN:0
COMMAND:        SCSI Request
COMMAND:        Write(10)  LBA:0x1c40800 LEN:0x8 LUN:0
COMMAND:        SCSI Request
COMMAND:        Write(10)  LBA:0x800 LEN:0x8 LUN:0
COMMAND:        SCSI Request
COMMAND:        Test Unit Ready LUN:0
COMMAND:        SCSI Request
COMMAND:        Test Unit Ready LUN:0
# Install ends here
# Client restarts, attempts to boot to the new install:
DEBUG:  create connect
INFO:   initiator 192.168.1.15:30733 connect.
NEGOTIATION:    SessionType = Normal
WARNING:        initiator name or target name is INVAILD iqn.2006-11.1
DEBUG:  connect 0 finish.

下降到 iPXE shell 並嘗試手動sanboot,它會吐出其他資訊 -此錯誤

(Error code 3c0d61)
This error originated from one of the following locations within the iPXE source code:
net/tcp/iscsi.c (line 1226)
This error indicates an unexpected status received from the iSCSI target.

Wireshark 具有以下功能:

客戶端向主機發送iSCSI LOGIN命令,值得注意的內容:

Key/Value Pairs
   KeyValue: InitiatorName=iqn.2006-11.1
   KeyValue: TargetName=iqn.2006-11.1
   KeyValue: SessionType=Normal
   KeyValue: AuthMethod=CHAP,None

主機返迴iSCSI LOGIN響應,值得注意的內容:

Status: Missing parameter (0x0207)

此郵件列表中簡要討論了此錯誤程式碼,但我不夠精明,無法理解其重要性。

我不明白目標或發起者名稱如何突然無效?也不缺少什麼參數。該連接實際上只是在使用中,並且在安裝過程中沒有任何投訴……我什至可以複製它 - 再次啟動安裝不是問題,並且完成得很好(再次)。重新安裝後,當我嘗試啟動時,同樣的問題!

我注意到的一件事是,iSCSI 或 PXE 中的空密碼有些奇怪。在 ubuntu 安裝期間,為了完成 iSCSI 卷登錄,我必須按一次空格鍵 - 它不接受 NULL 長度密碼,即使密碼在配置中本質上是 NULL。

但是,在 iPXE 中無法輸入 SPACE 作為密碼 - 唯一的空白空間似乎被視為 NULL。但是,設置initiator_pwd為 not NULL 似乎沒有幫助。

我已經被困在這一點上幾個小時了。我該從哪裡獲得更多故障排除?

編輯:忘記添加:

iPXE 配置:

#!ipxe
set iscsi-target iscsi:192.168.1.10::::iqn.2006-11.1
set gateway 0.0.0.0
set initiator-iqn iqn.2007-11.1
set keep-san 1
sanboot ${iscsi-target}
boot

新的 config.xml

<!-- configure the first target -->
<target name="iscsi" ip="192.168.1.10" port="3260" portal="1">
   <!-- the first iqn of this target configured for disk array -->
   <host name="iqn.2006-11.1" target_pwd="1" initiator_pwd="1"> # <-- Set passwords to avoid NULL problem, this comment was not part of the actual config
       <lun id="0" type="0" path="E:\pyTarget\ubuntu16.ima" capacity="81943040" />
   </host>
</target>

腳本失敗後丟棄 iPXE shell:

1. dhcp
2. login
  username: iscsi
  password: 1
3. sanboot iscsi:192.168.1.10::::iqn.2006-11.1

新數據包擷取:

iSCSI (Login Command)
   Opcode: Login Command (0x03)
   1... .... = T: Transit to next login stage
   .0.. .... = C: Text is complete
   .... 00.. = CSG: Security negotiation (0x0)
   .... ..01 = NSG: Operational negotiation (0x1)
   VersionMax: 0x00
   VersionMin: 0x00
   TotalAHSLength: 0x00
   DataSegmentLength: 93 (0x0000005d)
   ISID: 40002723b2f3
   TSIH: 0x0000
   InitiatorTaskTag: 0x18ae0002
   CID: 0x0000
   CmdSN: 0x00000000
   ExpStatSN: 0x00000001
   Key/Value Pairs
       KeyValue: InitiatorName=iqn.2007-11.1
       KeyValue: TargetName=iqn.2006-11.1
       KeyValue: SessionType=Normal
       KeyValue: AuthMethod=CHAP,None
   Padding: 000000

iSCSI (Login Response)
   Opcode: Login Response (0x23)
   0... .... = T: Stay in current login stage
   .0.. .... = C: Text is complete
   .... 00.. = CSG: Security negotiation (0x0)
   VersionMax: 0x00
   VersionActive: 0x00
   TotalAHSLength: 0x00
   DataSegmentLength: 0 (0x00000000)
   ISID: 40002723b2f3
   TSIH: 0x0000
   InitiatorTaskTag: 0x18ae0002
   StatSN: 0x00000001
   ExpCmdSN: 0x00000000
   MaxCmdSN: 0x00000000
   Status: Missing parameter (0x0207)

sanboot iscsi:192.168.1.10::::iscsi在客戶端控制台中返回Status: Authentication failed (0x0201)wireshark 和相應的Operation not allowed 410d61

pyTarget 控制台:

DEBUG:  create connect
DEBUG:  destroy connect 0
INFO:   initiator 192.168.1.15:1552 connect.
NEGOTIATION:    SessionType = Normal
NEGOTIATION:    TargetName = iscsi
WARNING:        InitiatorName %s do not exist. iqn.2007-11.1
DEBUG:  connect 0 finish.

最後一條錯誤消息翻轉了電燈開關。尷尬的是,我的名字倒了:

在 iPXE 外殼中:

set initiator-iqn iqn.2006-11.1
sanboot iscsi:192.168.1.10::::iscsi

現在我有啟動…

澄清一下,iPXE 配置在如下所示時有效:

#!ipxe
set iscsi-target iscsi:192.168.1.10::::iscsi
set gateway 0.0.0.0
set initiator-iqn iqn.2006-11.1
set keep-san 1
sanboot ${iscsi-target}
boot

引用自:https://serverfault.com/questions/877381