
kickstart タイピングレス
で、kickstart 自動インストールを体験しました。今回 さらに kickstartファイルの場所を手入力せずにAlmaLinuxをインストールします。人為的なタイプミスを防ぐことができます。
インストールソース と kickstartファイル の位置・中身はこちらと同じで、手入力していたパラメータを埋め込んだカスタムブートイメージを作成する作戦です。
前提
操作OS
AlmaLinux release 8.8 (Sapphire Caracal)
AlmaLinux release 9.5 (Teal Serval)
インストールソース
http://192.168.0.2/install/AlmaLinux9/
AlmaLinux-9.5-x86_64-dvd.iso をマウントしたパス。
kickstartファイル
http://192.168.0.2/install/ks.cfg
### UTF-8,LF AlmaLinux9.5 kickstart
### インストールソース
url --url=http://192.168.0.2/install/AlmaLinux9
### インストールモード
# text
# graphical
### 言語
lang en_US --addsupport=ja_JP.UTF-8
### キーボード (日本語なら us → jp)
keyboard --vckeymap=us --xlayouts='us'
### タイムゾーン
timezone Asia/Tokyo --utc
### ネットワーク
network --bootproto=dhcp --onboot=on --activate
### root パスワード
# rootpw --plaintext "1234253142425" ← 平文ならこちら
rootpw --iscrypted $6$4QVwEtIRLcRlvtOA$6gc7yCbcoNuROs.QknutEtlCZfPjoDmWVWD8/OGERKxVEh0ouLOwnniF7TlXBF0U3i/XzemyZlZqDgwH4rNnP.
### グループ
group --name=staff
### 起動ローダ
bootloader --location=mbr
### 特定のディスクのみを使用
ignoredisk --only-use=sda
### ディスクパーティション自動構成(ディスク全消去)
autopart --type=lvm
clearpart --all --initlabel
### SELinux 無効化
selinux --disabled
### ファイアウォール無効
# firewall --enabled --service=ssh ← 有効ならこちら
firewall --disabled
### パッケージグループ選択(最小構成)
%packages
@^minimal-environment
chrony
%end
### kdump 無効
# %addon com_redhat_kdump --enable --reserve-mb='auto'
%addon com_redhat_kdump --disable
%end
### 再インストール防止 Enterで電源OFF VirtualBox:×
# halt
### 再インストール防止 光学ISO除去 VirtualBox:×
reboot --eject
### KickStart最終スクリプト ここから
%post --interpreter /bin/bash
### デフォルトロケール
echo 'LANG="ja_JP.UTF-8"' > /etc/locale.conf; cat /etc/locale.conf
### 一般ユーザ追加
useradd -g staff -G wheel wanko
### 再インストール防止 ISOアンマウント VirtualBox:×
umount /run/install/repo || true
### 再インストール防止 VirtualBox:〇
eject /dev/sr0 || true
%end
### KickStart最終スクリプト ここまでカスタムブートイメージの作り方
最小ブートイメージ「AlmaLinux-9.5-x86_64-boot.iso 1,111,998,464バイト」をカスタマイズします。
ホームディレクトリで作業します。フォルダ「dvd」に「AlmaLinux-9.5-x86_64-boot.iso」をマウントします。Xwindowなら「/run/media/wanko/AlmaLinux-9-5-x86_64-dvd」などに自動マウントされているかもしれません。
mkdir ~/dvdホームディレクトリの isoファイルなら
sudo mount -t iso9660 ~/AlmaLinux-9.5-x86_64-boot.iso ~/dvd光学メディアなら
sudo mount -t iso9660 /dev/sr0 ~/dvdファイル・フォルダ 複製
展開されたディスク全体をフォルダ「iso」へコピーします。
sudo cp -r ~/dvd ~/isoこれでコピー元は不要なので マウント解除、削除します。
sudo umount ~/dvd
rm ~/AlmaLinux-9.5-x86_64-boot.isoフォルダ「iso」全体のオーナーを自分に変更します。ID:wanko、Group:staff なら
sudo chown wanko:staff -Rf ~/isoメニュー修正
ここからカスタマイズです。ブート直後のメニューを構成しているファイルをエディタで編集します。
vi ~/iso/isolinux/isolinux.cfgオリジナルとの差は次の通り、kickstartファイルの場所を指定したメニューを先頭に追加し これをデフォルトとしています。IPアドレスをハードコードしているので、ラベルなど 適宜修正してください。
60a61,66
> label autoinstall
> menu label ^Auto Install AlmaLinux 9 from LAN
> menu default
> kernel vmlinuz
> append initrd=initrd.img inst.ks=http://192.168.0.2/install/ks.cfg inst.text quiet
>
68d73
< menu default
120a126
>「~/iso/isolinux/isolinux.cfg」全体は
default vesamenu.c32
timeout 600
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title AlmaLinux 9.5
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
# Border Area
menu color border * #00000000 #00000000 none
# Selected item
menu color sel 0 #ffffffff #00000000 none
# Title bar
menu color title 0 #ff7ba3d0 #00000000 none
# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
# Help text
menu color help 0 #ffffffff #00000000 none
# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label autoinstall
menu label ^Auto Install AlmaLinux 9 from LAN
menu default
kernel vmlinuz
append initrd=initrd.img inst.ks=http://192.168.0.2/install/ks.cfg inst.text quiet
label linux
menu label ^Install AlmaLinux 9.5
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=AlmaLinux-9-5-x86_64-dvd quiet
label check
menu label Test this ^media & install AlmaLinux 9.5
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=AlmaLinux-9-5-x86_64-dvd rd.live.check quiet
menu separator # insert an empty line
# utilities submenu
menu begin ^Troubleshooting
menu title Troubleshooting
label text
menu indent count 5
menu label Install AlmaLinux 9.5 using ^text mode
text help
Try this option out if you're having trouble installing
AlmaLinux 9.5.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=AlmaLinux-9-5-x86_64-dvd inst.text quiet
label rescue
menu indent count 5
menu label ^Rescue a AlmaLinux system
text help
If the system will not boot, this lets you access files
and edit config files to try to get it booting again.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=AlmaLinux-9-5-x86_64-dvd inst.rescue quiet
label memtest
menu label Run a ^memory test
text help
If your system is having issues, a problem with your
system's memory may be the cause. Use this utility to
see if the memory is working correctly.
endtext
kernel memtest
menu separator # insert an empty line
label local
menu label Boot from ^local drive
localboot 0xffff
menu separator # insert an empty line
menu separator # insert an empty line
label returntomain
menu label Return to ^main menu
menu exit
menu endこれで、ブートすると次のような画面になります。

iso形式ファイルに必要なツールをインストールします。
sudo dnf install xorriso syslinux genisoimageフォルダ「iso」から iso形式ファイル「AlmaLinux9.myboot.iso」を作成します。
xorriso -as mkisofs \
-o AlmaLinux9.myboot.iso \
-isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \
-c isolinux/boot.cat \
-b isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e images/efiboot.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-V "ALMALINUX_CUSTOM" \
~/iso出来上がった「AlmaLinux9.myboot.iso」を光学メディアに焼いたり、rufus-4.7 で USBメモリに書き込むか、VirtualBoxなら光学ドライブに設定し、あとは起動するだけでキー入力することなくインストールが始まり完了します。
終わり
インストールソースとkickstartの中身は変更できるので、パスが変わらない限りAlmaLinux9.* であれば使いまわせます。
1.2GB → 320MB
BIOSブート専用にすることでCDROMに収まるサイズに小さくできます。フォルダ「iso」から不要なデータを削除します。