Debian LiveにCentOS LiveCDを入れてデュアルブートLiveCDにする

「Debian LiveにCentOS Live CDを仕込んでデュアルブートにできない?」との相談があったのでやってみた。 テストなのでDebian Liveはコンソールしか起動しない最小イメージのstandardを使っています。
Debian Liveの準備
lh config入力して設定の雛形を作ります。
$ lh config
設定の雛形を変更してDebian Liveの設定をしますが、手で設定していくのは面倒くさいのでMakefileとautoディレクトリ以下にスクリプトを置いて自動化できるようにします。
Makefile
BOOTOPTION_LIVE = locale=ja_JP.UTF-8 keyb=jp kmodel=acpi utc=no tz=Asia/Tokyo noswap nopersistent
all: config build
config: clean
lh config \
--binary-images iso \
--bootloader syslinux \
--iso-volume "DebianLive" \
--bootappend-live "${BOOTOPTION_LIVE}" \
--linux-flavours 486 \
--linux-packages "linux-image-2.6" \
--packages-lists "standard" \
--templates `pwd`/config/templates/
build:
sudo lh build
clean:
sudo lh clean
distclean: clean
sudo lh clean --purge
sudo rm -f *.iso *.img *.list *.packages *.buildlog *.md5sum
auto/config
#!/bin/sh
MIRROR_DEBIAN="http://ftp.jp.debian.org/debian/"
MIRROR_SECURITY="http://security.debian.org/"
lh config noautoconfig \
--distribution squeeze \
--archive-areas "main" \
--language ja \
--apt-recommends false \
--apt-secure false \
--mirror-binary ${MIRROR_DEBIAN} \
--mirror-binary-security ${MIRROR_SECURITY} \
--mirror-bootstrap ${MIRROR_DEBIAN} \
--mirror-chroot ${MIRROR_DEBIAN} \
--mirror-chroot-security ${MIRROR_SECURITY} \
${@}
auto/build
#!/bin/sh
BUILDDATE=`date +%Y%m%d%H%M%S`
lh build noautoconfig 2>&1 | tee debian_live-binary-${BUILDDATE}.buildlog
# rename files
if [ -f binary.iso ]; then
mv binary.iso debian_live-binary-${BUILDDATE}.iso
elif [ -f binary.img ]; then
mv binary.img debian_live-binary-${BUILDDATE}.img
fi
[ -f binary.list ] && mv binary.list debian_live-binary-${BUILDDATE}.list
[ -f binary.packages ] && mv binary.packages debian_live-binary-${BUILDDATE}.packages
auto/clean
#!/bin/sh
lh clean noautoconfig --all ${@}
# Remove generated files
rm -f config/binary config/bootstrap config/chroot config/common config/source
# Remove empty directories in config tree
if ls config/*/ > /dev/null 2>&1
then
rmdir --ignore-fail-on-non-empty config/*/
fi
if [ -d config ]
then
rmdir --ignore-fail-on-non-empty config
fi
これで make一発でビルドや make clean で作業ディレクトリを掃除できるので格段に楽になりました。
Debian Liveの設定についてですが、Makefileとauto/configにわかれていることに気がつくと思います。 使い分けは、頻繁に変更する設定についてはMakefileに、apt-lineなど変更する必要はあるけど一度設定すれば変更しないものについてはauto/configに書きます。
CentOS LiveCDの内容をコピーする
ダウンロードしたCentOS LiveCDのISOイメージから内容を取り出して、Debian Liveのconfig/binary_local-includes/ディレクトリにコピーします。 ISOイメージのマウントにはfuseisoを使っています。
ISOイメージをマウント
$ mkdir centos
$ fuseiso CentOS-5.4-i386-LiveCD.iso centos/
CentOSのsquashfsをコピー
$ cp -r centos/LiveOS/ config/binary_local-includes/
CentOSのカーネルとinitrdをコピー
$ mkdir config/binary_local-includes/centos
$ cd centos/isolinux/
$ cp initrd0.img install.img vminst vmlinuz0 ../../config/binary_local-includes/centos/
ISOイメージをアンマウント
$ fusermount -u centos/
syslinuxの設定
CentOS LiveCDを起動するための設定を追加します
Debian Liveのsyslinuxテンプレートをconfig/templates/にコピー
$ cd config/templates/
$ cp -r /usr/share/live-helper/templates/syslinux/ .
centos.cfgの作成
CentOSのisolinux.cfgをコピーしてCentOS起動設定を作ります。
$ cd syslinux/menu/
$ cp ../../../binary_local-includes/centos/isolinux/isolinux.cfg centos.cfg
元のisolinux.cfgからの変更点は
- Debian Liveのsyslinuxと重複しているところを削除。
- CentOSを階層にするので menu begin CentOS 〜 menu end で囲む。
- トップの階層に戻るための menu goto .top を追加。
- 参考: Comboot/menu.c32 - Syslinux Wiki: http://syslinux.zytor.com/wiki/index.php/Comboot/menu.c32
- labelがDebian Liveとぶつからないように頭にcentをつけた。
- syslinuxパラメータの kernel と append のinitrdをCentOSのカーネルとinitrdを置いたcentosディレクトリに変更。
- root=CDLABEL をDebianLiveに変更(Debian LiveのCDラベルの設定 --iso-volume "DebianLive" も変更しておきます。)
- rootfstype= をiso9660からautoに変更
config/templates/syslinux/menu/centos.cfg
menu begin CentOS
label centlinux0
menu label CentOS 5.4 Boot
kernel /centos/vmlinuz0
append initrd=/centos/initrd0.img root=CDLABEL=DebianLive rootfstype=auto ro quiet liveimg
label centlinuxtext0
menu label CentOS 5.4 Boot (text mode)
kernel /centos/vmlinuz0
append initrd=/centos/initrd0.img root=CDLABEL=DebianLive rootfstype=auto ro quiet liveimg 3
label centinstaller
menu label CentOS 5.4 Network Installation
kernel /centos/vminst
append initrd=/centos/install.img text
label Return to top menu
menu goto .top
menu end
ビルド
これでビルドするとCentOSが起動できるDebian Liveができます。