2011-12-23

カーネル/VM Advent Calender 23日目 Gentoo Linuxでstage4

皆さんが大好きなGentoo Linuxですが、ご存知の通り、インストールにとても長い時間がかかります。
もっとも、#gentooinstallbattleが日常になっているておくれな方々にとっては、かかる時間も楽しいのだと思います。

ですが、今回はGentoo Linuxのstage4を取りあげてみます。
GentooForumsに解説(Gentoo Forums :: View topic - make your own Stage4 mini HOWTO)が書いてあったので、だいたいそれを参考にしてます・ω・

stage4を作成
1. Install Gentoo
いつもの通り、Gentooをインストールします。

2. Configure all drivers (sound, video, usb, etc) and install any software you want to be included on your stage4. For example, I would install X, Xfce4, Sun's JDK, CVS, Emacs, Thunderbird, and Firefox.
ドライバのコンフィグ、stage4に含めたいソフトウェアをインストールしておくようにとのことです。

cat /var/lib/portage/world

で、worldに含まれているパッケージが確認できます。


3. Make a copy of your /boot partition.
/bootパーティションのコピーを作ります。

root# mount /boot 
root# cp -R /boot /bootcpy 
root# umount /boot 


4. Clear out temporary files in /usr/portage/distfiles and /var/tmp to save space.
一時ファイルは邪魔なので、消しておきます。

root# rm -r /usr/portage/distfiles
root# rm -r /var/tmp


5. After everything is how you want it, we will create the archive.
stage4の元を作成する準備ができたので、アーカイブ化します。

root# tar cjpf /path/to/stage4.tar.bz2 / --exclude=stage4.tar.bz2 --exclude=/proc/* --exclude=/tmp/*

(元記事だと
root# tar cCjpf /path/to/stage4.tar.bz2 / --exclude=stage4.tar.bz2 --exclude=/proc
となってましたが、失敗するので変えました。)


おわり・ω・


stage4からインストール
1. Boot live CD
LiveDVDが手元にあるので、今回はDVDを使っています。


2. Partition and mount filesystem
パーティションを切ります。

root# fdisk /dev/sda


3. root# cd /mnt/gentoo
普段のインストールと同じように、

root# mount /dev/sda3 /mnt/gentoo
root# cd /mnt/gentoo


4. copy your stage4 archive(s) to disk. (if it is on another CD type "gentoo cdcache" at the boot prompt. Then you'll be able to umount/mount other CDs.)
作成しておいたstage4アーカイブをコピーして持ってきます。

root# cp /path/to/stage4.tar.bz2 /mnt/gentoo


5. tar xvjpf stage4.tar.bz2
stage4アーカイブを展開します。

root# tar xvjpf stage4.tar.bz2


6. root# cp -R bootcpy /mnt/gentoo/boot. (double check the boot dir after you copy the files over!)
前に作成した/bootのコピー(bootcpy)をコピーしてきます。

root# mount /dev/sda1 /mnt/gentoo/boot
root# cp -R /path/to/bootcpy /mnt/gentoo/boot
root# rm -rf bootcpy


7. fstab
fstabを編集します。

root# nano -w /etc/fstab

今回は、全く同じ構成なので特に編集する必要がありませんでした。


8. grub or lilo
grubの編集、インストールを行います。

root# nano -w /mnt/gentoo/boot/grub.conf
root# grub-install --no-floppy
(root# grub --no-floppy)


#gentooinstallbattle界隈としてstage4はルール的に認められているのかグレーですが、かなり便利だと思いますよ!

(カーネル/VMぽくないのですいません...)

以上!