LoginSignup
3
3

More than 5 years have passed since last update.

FreeBSD 12 カスタムインストーラ作成

Posted at

配布されている FreeBSD インストーラ ISOイメージを元に、カスタムインストーラ ISOイメージを作成します。
この例では、MegaRAIDのドライバとしてmfi(4)の代わりにmrsas(4)を使用し、インストーラのシェルからstorcliコマンドを使用できるようにします。

イメージ作成、カスタムイメージからの起動は FreeBSD/amd64 12.0-RELEASE で確認しています。

準備

カスタムインストーラ作成環境として、ファイルシステム空き容量がISOイメージの2倍 (オリジナルイメージ + カスタムイメージ) 以上あるFreeBSDを使用します。

オリジナルのISOイメージを準備し、読み書きできるようにマウントします。
マウント時のデバイス名はmdconfigコマンドの実行結果に合わせます。
また、ISOイメージ作成時に使用するmkisoimages.shスクリプトを展開します。

# mkdir /var/tmp/release
# cd /var/tmp/release
# fetch ftp://ftp.jp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/12.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz
FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz                595 MB   13 MBps    44s
# unxz FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz
# mkdir disc1 disc1-union
# mdconfig -o readonly FreeBSD-12.0-RELEASE-amd64-disc1.iso
md0
# mount -r -t cd9660 /dev/md0 disc1
# mount -t unionfs -o noatime disc1-union disc1
# tar xJf disc1/usr/freebsd-dist/src.txz usr/src/release/amd64/mkisoimages.sh
#

カスタマイズ

マウントしたイメージをカスタマイズします。

以下の例では、mfi(4)の代わりにmrsas(4)を使用する設定をloader.confに加え、storcliコマンドをコピーしています。
storcliコマンドはBroadcom社のサイト等から入手します。

# echo 'hw.mfi.mrsas_enable="1"' >> disc1/boot/loader.conf
# install -c -m 555 storcli64 disc1/usr/sbin/storcli
#

ISOイメージ作成

ISOイメージ作成はmkisoimages.shスクリプトを使用します。
スクリプトの引数は次の通りです。

Usage: mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]

以下の様にしてISOイメージを作成します。

# sh usr/src/release/amd64/mkisoimages.sh -b 12_0_RELEASE_AMD64_CD FreeBSD-12.0-RELEASE-amd64-disc1-custom.iso disc1
200+0 records in
200+0 records out
819200 bytes transferred in 0.003049 secs (268692972 bytes/sec)
newfs_msdos: cannot get number of sectors per track: Operation not supported
newfs_msdos: cannot get number of heads: Operation not supported
/dev/md1: 1557 sectors in 1557 FAT12 clusters (512 bytes/cluster)
BytesPerSec=512 SecPerClust=1 ResSectors=1 FATs=2 RootDirEnts=512 Sectors=1600 Media=0xf8 FATsecs=5 SecPerTrack=63 Heads=1 HiddenSecs=0
1+0 records in
1+0 records out
32768 bytes transferred in 0.023710 secs (1382045 bytes/sec)
#

後片付け

イメージのマウントを解除します。
umountはunionfs, cd9660の2回分実行します。
mdconfigコマンド引数のデバイス名は、準備の際のmdconfigコマンドの実行結果に合わせます。

# umount disc1
# umount disc1
# mdconfig -d -u md0
#

不要であればオリジナルISOイメージ等のファイルを削除します。

動作確認

作成したISOイメージをDVD-R、USBメモリ等に書き込み、インストーラを起動します。

Loading kernel...
/boot/kernel/kernel text=0x1678a68 data=0x1cd288+0x768b40 syms=[0x8+0x174cd8+0x8+0x19224a]
Loading configured modules...
can't find '/boot/entropy'
Start @ 0xffffffff80341000 ...
EFI framebuffer information:
addr, size     0x90000000, 0x800000
dimensions     1024 x 768
stride         1024
masks          0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
---<<BOOT>>---
Copyright (c) 1992-2018 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 12.0-RELEASE r341666 GENERIC amd64
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
(中略)
 FreeBSD Installer
 ──────────────────────────────────────────────────────────────────────────────






                      ┌────────────Welcome──────────────┐
                      │ Welcome to FreeBSD! Would you   │
                      │ like to begin an installation   │
                      │ or use the live CD?             │
                      ├─────────────────────────────────┤
                      │ <Install> < Shell > <Live CD>   │
                      └─────────────────────────────────┘









When finished, type 'exit' to return to the installer.
# storcli /c0/v0 show
CLI Version = 007.0813.0000.0000 Dec 14, 2018
Operating system = FreeBSD 12.0-RELEASE
Controller = 0
Status = Success
Description = None


Virtual Drives :
==============

-------------------------------------------------------------
DG/VD TYPE  State Access Consist Cache Cac sCC     Size Name 
-------------------------------------------------------------
0/0   RAID0 Optl  RW     Yes     NRWTD -   OFF 1.636 TB HDD0 
-------------------------------------------------------------

Cac=CacheCade|Rec=Recovery|OfLn=OffLine|Pdgd=Partially Degraded|Dgrd=Degraded
Optl=Optimal|RO=Read Only|RW=Read Write|HD=Hidden|TRANS=TransportReady|B=Blocked|
Consist=Consistent|R=Read Ahead Always|NR=No Read Ahead|WB=WriteBack|
AWB=Always WriteBack|WT=WriteThrough|C=Cached IO|D=Direct IO|sCC=Scheduled
Check Consistency



# diskinfo /dev/da0
/dev/da0    512 1799792623616   3515219968  4096    0   218812  255 63
#

インストーラのシェルからstorcliコマンドが使用できるようになりました。
mfi(4)ドライバの場合、ディスクは /dev/mfid0 のように認識されますが、mrsas(4)ドライバの場合、ディスクは /dev/da0 のように認識されます。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3