LoginSignup
4
7

More than 5 years have passed since last update.

CentOSのインストールでUSB Boot からの Kickstartを良い感じに行なう方法

Posted at

USB Bootでkickstartを良い感じに使いたい!!

参考にさせてもらったサイト

この方法の良いところ

  • パーティションはvfatなので、ks.cfg, syslinux.cfgなどの書き換えが簡単。
    • ks.cfgを対象毎に用意して、メニュー追加などが簡単。
  • CentOSのisoをそのままファイルとして置くので、差し替えが簡単。

Linuxで作業します。たぶんCentOS6の方が良いです。LiveCDなどでOK。

USBのパーティション設定

ここでは/dev/sdbがUSBという事にします。

# fdisk /dev/sdb
n (sdb1パーティション作成, First sectorは63にする。)
t (パーティションIDの変更, W95 FAT32 (LBA)へ変更する。cと入力。)
a (sdb1はbootableに変更する。)
n (sdb2パーティションの作成, 全部割り当てる。)
t (sdb2パーティションIDの変更, W95 FAT32 (LBA)へ変更する。cと入力。)
w (write changes to device)

上記適当ですが、sda1,sda2をfat32で作ってsda1をbootanleにすれば良いです。
試してませんが、sda1だけでも良いかもしれないです。

フォーマット

# mkfs -t vfat -n "BOOT" /dev/sdb1
# mkfs -t vfat -n "DATA" /dev/sdb2

* mkfs.vfatはdosfstoolsのrpmに含まれています。

MBRのインストール

# dd conv=notrunc bs=440 count=1 if=/usr/share/syslinux/mbr.bin of=/dev/sdb

* /usr/share/syslinux/mbr.binはsyslinux-nonlinuxのrpmに含まれています。

syslinuxのインストール


# syslinux /dev/sdb1

USBのマウント その1

# mkdir BOOT
# mount /dev/sdb1 BOOT
# mkdir DATA
# mount /dev/sdb2 DATA

LinuxのISOを取得

# cd DATA
# wget http://お好きなミラーサイト/CentOS/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso
# cd ..

USBのマウント その2

# mkdir DVD
# mount /path/to/DATA/CentOS-6.6-x86_64-minimal.iso DVD

DVDからブートに必要なファイルをコピー

# cp DVD/isolinux/* BOOT
これはCentOS6だけ必要。CentOS7では不要です。(私はCentOS7では試していないですが。)
# cp -a DVD/images BOOT

isolinux.cfgをsyslinux.cfgへリネーム

# mv BOOT/isolinux.cfg BOOT/syslinux.cfg

syslinux.cfgの編集

# vi BOOT/syslinux.cfg
以下の箇所を変更します。
label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img
CentOS6の場合は、appendを以下のように変更します。
append initrd=initrd.img method=hd:LABEL=DATA:/ ks=hd:LABEL=BOOT:/ks.cfg
CentOS7の場合は、appendを以下のように変更します。
append initrd=initrd.img inst.stage2=hd:LABEL=DATA:/ ks=hd:LABEL=BOOT:/ks.cfg

* 私はCentOS7では試してませんが、たぶん行けます。

ks.cfgを複数用意してあげて、syslinux.cfgでlabel xxxで増やせば、色々なパターンのks.cfgを使い分けれます。

4
7
1

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
4
7