ここではistgtとDHCP設定のクライアント(FreeBSD9.1-amd64)を想定しています。
FreeBSD自体は何でも良いのですが、ここではisbootと一緒に配布している
メモリイメージをLUN割り当てしたものを参考例にしています。
1.埋め込みスクリプト付きのiPXEを作成:
適当なLinuxでgitを使いipxeのソースを取得してきて、ipxeスクリプトを
埋め込んだUSBメモリイメージを作成します。
(テスト用のビルド環境はDebian GNU/Linux 6.0.5を利用)
以下はdn2800mt.ipxeというスクリプトをipxe/srcに用意した場合の例です。
# git clone git://git.ipxe.org/ipxe.git
# cd ipxe/src
# make bin/ipxe.usb EMBED=dn2800mt.ipxe
ここで出来た bin/ipxe.usb をUSBメモリに書き込みます。
2.istgtの設定:
istgtでは複数LUNを1個のTargetに指定でき、かつ、isbootも複数LUNを
処理できるので、
LUN0 起動用ハードディスク
LUN1 FreeBSDインストーラのイメージ
のように指定して初回のみLUN1から起動して、LUN0にインストールを行います。
(DN2800MTでは LUN0=da0, LUN1=da1, USBメモリ=da2 となります)
3.初回起動とLUN1起動方法:
iPXEをインストールしたUSBメモリから起動します。
(DN2800MTの場合はF2でBIOSに入って、USB BootをEnableにして、
F10を押すとブート可能デバイスを選択できます)
インストール前はそのまま放置してもiSCSIディスクが空で起動できないので、
iPXEが起動したらCtrl-Bを押してコマンドラインモードに落ちます。
コマンドラインで以下のようなsanbootを用いLUN1から起動します。
sanboot iscsi:172.18.0.26:::1:iqn.2007-09.jp.ne.peach:aria:dn2800mt-boot
:::1: の部分がキモです。LUN1から起動する設定になります。ポート3260以外に
したい場合、たとえば9999番ポートは ::9999:1: のような感じです。
デフォルトのLUN0とポート番号3260は通常省略されています。
もっと詳しく知りたい場合はRFC4173を参照してください。
※もちろんLUN2など他からも起動可能です。
正しくiSCSIターゲットに接続できれば、FreeBSDインストーラが起動するので
通常のFreeBSD9.1の手順でインストールします。
“iSCSI boot driver + DN2800MT kernel”というのがデフォルトで
選択されているので、そのままインストールします。
その他はお好みで調整可能です。
インストールが終わったら、次回からはLUN0から直接起動できます。
上記パッケージにisboot.koをロードする設定(loader.conf)も同梱されています。
4.不要LUN1の取り外し:
うまくFreeBSDが起動できたらLUN1はもう不要ですので、FreeBSDを
shutdownして終了した後に削除してかまいません。
設定ファイルのLUN1をコメントアウトして、istgt reloadすればOKです。
# /usr/local/etc/rc.d/istgt reload
※終了直後はiSCSIセッションが残って、reloadに失敗する可能性があるので、
その場合は少し時間をおいてから、LUN1を追加しなおして再度取り外してください。
※istgtの現在の仕様です。可能な範囲で順次対応していく予定です。
20120901版でリロード失敗時に再実行できるように設定を維持するようになりました。
失敗した場合はセッションがタイムアウトしたころにリロードすればOKです。
正常にリロードできたら、syslogに
update LU2800: Name=iqn.2007-09.jp.ne.peach:aria:dn2800mt-boot
のような表示が記録されます。
※IQNは大文字小文字関係ないのでここでは小文字で統一してあります。
※LUN0は最新istgtで追加したVBoxの仮想ディスク(20GB)を使っています。
※PG/IG/LUは実際に可動中の設定ファイルの完全コピーです。
istgt.conf の内容(当該LUのみ):
[PortalGroup4]
Portal PGA 172.18.0.26:3260
[InitiatorGroup2800]
InitiatorName "iqn.2010-04.org.ipxe:dn2800mt"
Netmask 172.18.0.0/16
[LogicalUnit2800]
TargetName "iqn.2007-09.jp.ne.peach:aria:dn2800mt-boot"
Mapping PortalGroup4 InitiatorGroup2800
UnitType Disk
QueueDepth 32
LUN0 Storage /tank/iscsi/istgt-DN2800MT.vdi Auto
LUN1 Storage /tank/iscsi/FreeBSD-9.1-BETA1-amd64-memstick-isboot-0.2.5.img Auto
dn2800mt.ipxeの内容:
#!ipxe
ifopen net0
dhcp net0
set initiator-iqn iqn.2010-04.org.ipxe:dn2800mt
prompt --key 0x02 --timeout 3000 Press Ctrl-B for the iPXE command line... && shell ||
sanboot iscsi:172.18.0.26::::iqn.2007-09.jp.ne.peach:aria:dn2800mt-boot
dmesg.boot (ダウンロード用):
Copyright (c) 1992-2012 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.1-PRERELEASE #0: Tue Aug 21 01:32:28 JST 2012
root@dn2800mt:/usr/obj/usr/src/sys/GENERIC amd64
CPU: Intel(R) Atom(TM) CPU N2800 @ 1.86GHz (1866.77-MHz K8-class CPU)
Origin = "GenuineIntel" Id = 0x30661 Family = 6 Model = 36 Stepping = 1
Features=0xbfebfbff
Features2=0x40e39d
AMD Features=0x20100800
AMD Features2=0x1
TSC: P-state invariant, performance statistics
real memory = 8589934592 (8192 MB)
avail memory = 8218251264 (7837 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table:
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s) x 2 HTT threads
cpu0 (BSP): APIC ID: 0
cpu1 (AP/HT): APIC ID: 1
cpu2 (AP): APIC ID: 2
cpu3 (AP/HT): APIC ID: 3
ioapic0: Changing APIC ID to 8
ioapic0 irqs 0-23 on motherboard
lapic0: Forcing LINT1 to edge trigger
kbd1 at kbdmux0
acpi0: on motherboard
acpi0: Power Button (fixed)
hpet0: iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
Event timer "HPET" frequency 14318180 Hz quality 450
Event timer "HPET1" frequency 14318180 Hz quality 440
Event timer "HPET2" frequency 14318180 Hz quality 440
acpi0: reservation of 0, 4000 (3) failed
cpu0: on acpi0
cpu1: on acpi0
cpu2: on acpi0
cpu3: on acpi0
atrtc0: port 0x70-0x77 irq 8 on acpi0
atrtc0: Warning: Couldn't map I/O.
Event timer "RTC" frequency 32768 Hz quality 0
attimer0: port 0x40-0x43,0x50-0x53 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
pcib0: port 0xcf8-0xcff on acpi0
pci0: on pcib0
vgapci0: port 0x40d0-0x40d7 mem 0xd0600000-0xd06fffff irq 16 at device 2.0 on pci0
hdac0: mem 0xd0800000-0xd0803fff irq 22 at device 27.0 on pci0
pcib1: at device 28.0 on pci0
pci1: on pcib1
em0: port 0x3000-0x301f mem 0xd0400000-0xd041ffff,0xd0000000-0xd03fffff,0xd0420000-0xd0423fff irq 16 at device 0.0 on pci1
em0: Using MSIX interrupts with 3 vectors
em0: Ethernet address: 00:22:4d:81:bb:b2
pcib2: at device 28.1 on pci0
pci2: on pcib2
em1: port 0x2000-0x201f mem 0xd0580000-0xd059ffff,0xd0500000-0xd057ffff,0xd05a0000-0xd05a3fff irq 17 at device 0.0 on pci2
em1: Using MSIX interrupts with 3 vectors
em1: Ethernet address: 00:1b:21:57:18:10
uhci0: port 0x40a0-0x40bf irq 23 at device 29.0 on pci0
uhci0: LegSup = 0x2f00
usbus0 on uhci0
uhci1: port 0x4080-0x409f irq 19 at device 29.1 on pci0
uhci1: LegSup = 0x2f00
usbus1 on uhci1
uhci2: port 0x4060-0x407f irq 18 at device 29.2 on pci0
uhci2: LegSup = 0x2f00
usbus2 on uhci2
uhci3: port 0x4040-0x405f irq 16 at device 29.3 on pci0
uhci3: LegSup = 0x2f00
usbus3 on uhci3
ehci0: mem 0xd0704400-0xd07047ff irq 23 at device 29.7 on pci0
usbus4: EHCI version 1.0
usbus4 on ehci0
pcib3: at device 30.0 on pci0
pci3: on pcib3
isab0: at device 31.0 on pci0
isa0: on isab0
ahci0: port 0x40c8-0x40cf,0x40dc-0x40df,0x40c0-0x40c7,0x40d8-0x40db,0x4020-0x402f mem 0xd0704000-0xd07043ff irq 19 at device 31.2 on pci0
ahci0: AHCI v1.10 with 4 3Gbps ports, Port Multiplier not supported
ahcich0: at channel 0 on ahci0
ahcich1: at channel 1 on ahci0
pci0: at device 31.3 (no driver attached)
acpi_button0: on acpi0
acpi_button1: on acpi0
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
sc0: at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
atkbdc0: at port 0x60,0x64 on isa0
atkbd0: irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
ppc0: cannot reserve I/O port range
ctl: CAM Target Layer loaded
est0: on cpu0
p4tcc0: on cpu0
est1: on cpu1
p4tcc1: on cpu1
est2: on cpu2
p4tcc2: on cpu2
est3: on cpu3
p4tcc3: on cpu3
Timecounters tick every 1.000 msec
iSCSI boot driver version 0.2.5
IS: Initiator name: iqn.2010-04.org.ipxe:dn2800mt
NIC0: IP address: 172.18.0.152
NIC0: Prefix: 16
NIC0: Gateway: 172.18.0.1
NIC0: MAC address: 00:22:4d:81:bb:b2
TGT0: Target IP address: 172.18.0.26
TGT0: Target Port: 3260
TGT0: Target LUN: 0
TGT0: Target name: iqn.2007-09.jp.ne.peach:aria:dn2800mt-boot
Boot NIC: em0
Configure IPv4 by NIC0
Attempting to login to iSCSI target and scan all LUNs.
usbus0: 12Mbps Full Speed USB v1.0
usbus1: 12Mbps Full Speed USB v1.0
usbus2: 12Mbps Full Speed USB v1.0
usbus3: 12Mbps Full Speed USB v1.0
usbus4: 480Mbps High Speed USB v2.0
ugen0.1: at usbus0
uhub0: on usbus0
ugen1.1: at usbus1
uhub1: on usbus1
ugen2.1: at usbus2
uhub2: on usbus2
ugen3.1: at usbus3
uhub3: on usbus3
ugen4.1: at usbus4
uhub4: on usbus4
uhub0: 2 ports with 2 removable, self powered
uhub1: 2 ports with 2 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub3: 2 ports with 2 removable, self powered
uhub4: 8 ports with 8 removable, self powered
hdacc0: at cad 1 on hdac0
hdaa0: at nid 1 on hdacc0
pcm0: at nid 3 on hdaa0
hdacc1: at cad 2 on hdac0
hdaa1: at nid 1 on hdacc1
hdaa1: No presence detection support at nid 0
pcm1: at nid 20,27 and 24,25 on hdaa1
pcm2: at nid 21 and 18 on hdaa1
pcm3: at nid 30 on hdaa1
da0 at isboot0 bus 0 scbus3 target 0 lun 0
da0: Fixed Direct Access SCSI-5 device
da0: 20480MB (41943040 512 byte sectors: 255H 63S/T 2610C)
Boot device: da0
lapic1: Forcing LINT1 to edge trigger
SMP: AP CPU #1 Launched!
lapic3: Forcing LINT1 to edge trigger
SMP: AP CPU #3 Launched!
lapic2: Forcing LINT1 to edge trigger
SMP: AP CPU #2 Launched!
Timecounter "TSC-low" frequency 14584146 Hz quality 1000
ugen4.2: at usbus4
umass0: on usbus4
umass0: SCSI over Bulk-Only; quirks = 0x4100
umass0:4:0:-1: Attached to scbus4
da1 at umass-sim0 bus 0 scbus4 target 0 lun 0
da1: < USB Reader 0001> Removable Direct Access SCSI-0 device
da1: 40.000MB/s transfers
da1: 1876MB (3842048 512 byte sectors: 255H 63S/T 239C)
ugen4.3: at usbus4
uhub5: on usbus4
Root mount waiting for: usbus4
ugen1.2: at usbus1
ukbd0: on usbus1
kbd2 at ukbd0
ums0: on usbus1
uhub5: 4 ports with 4 removable, self powered
ums0: 5 buttons and [XYZ] coordinates ID=1
Trying to mount root from ufs:/dev/da0p2 [rw]...