ちょっと古くなってしまった自作PCに、Gentoo Linuxを入れます。
項目 | ||
マザーボード | SOYO SY-6BA+ | |
CPU | Pentium III 500MHz | |
メモリ | PC-100 640MB | |
HDD | 8GB | |
Video | Permedia 2 | |
LAN | PLANEX FW-110TX/TXL(チップはRTL8139) | |
Gentooから、2004.1版のLiveCDをダウンロードしてCD-Rで焼きます。
CD−Rからブートすると、Linuxが立ち上がります。
boot: gentoo dokeymap
CRTの場合、画面モードを聞いてくるので、80x60等適当なものを選択します。
dokeymapを指定した場合、キー配列の国名を聞いてくるので、jp を選択します。
ネットワークが認識されたかどうかは、ifconfigを実行します。lo(ローカルループバック)しか表示されなければ認識できていません。eth0等が表示されていれば認識しています。
# ifconfig :
今回は、カードを自動認識しなかったので、ネットワークカードのドライバモジュールを手動で指定してからネットワーク設定を実行します。
# modprobe 8139too # net-setup eth0
ハードディスクのパーティションを設定します。
パーティション | サイズ | マウントポイント | ファイルシステム |
---|---|---|---|
/dev/hda1 | 32MB | /boot | ext2 |
/dev/hda2 | 512MB | swap | Linux Swap |
/dev/hda3 | 7.4GB | / | reiserfs |
実際に使用する(/にマウントする)パーティションのファイルシステムは、ジャーナルファイルシステムがよいでしょう。ジャーナルファイルシステムには、ext3/ReiserFS/JFS/XFSなどがあります。違いについては、@IT:全貌を現したLinuxカーネル2.6[第3章](1/2)などを参照するとよいでしょう。簡単にいえば、ReiserFSは、ACL・拡張属性が使用できません。XFSだけがオンライン・リサイズに対応しています。
それぞれのパーティションを上述のファイルシステムで初期化します。
# mke2fs /dev/hda1 # mkswap /dev/hda2 # mkreiserfs /dev/hda3
それぞれのパーティションをマウントします。procという特殊なファイルシステムもマウントします。
# swapon /dev/hda2 # mount /dev/hda3 /mnt/gentoo # mount /dev/hda1 /mnt/gentoo/boot # mount -t proc none /mnt/gentoo/proc
Stageファイルを展開します。ここで、Stage1 から 3のどれを使用するかの選択があります。
# cd /mnt/gentoo # tar -xvjpf /mnt/cdrom/stages/stage1-x86-2004.1.tar.bz2 : #
# cd /mnt/gentoo # tar -xvjpf /mnt/cdrom/stages/stage3-pentium3-2004.1.tar.bz2 : #
コンパイルオプションの指定
# nano -w /mnt/gentoo/etc/make.conf
# These settings were set by the catalyst build script that automatically builtthis stage # Please consult /etc/make.conf.example for a more detailed example CFLAGS="-O2 -mcpu=i686 -fomit-frame-pointer" CHOST="i386-pc-linux-gnu" CXXFLAGS="${CFLAGS}" |
このファイルに、インストールするマシンのスペックに応じた設定を加えます。
# These settings were set by the catalyst build script that automatically builtthis stage # Please consult /etc/make.conf.example for a more detailed example CFLAGS="-O2 -march=pentium3 -pipe -fforce-addr -fomit-frame-pointer -mfpmath=sse,387 -falign-functions=4 -falign-jumps=4" CHOST="i686-pc-linux-gnu" CXXFLAGS="${CFLAGS}" MAKEOPTS="-j2" |
ミラーサイトの選択
# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
で、日本のサイトをいくつか選択します。
DNS情報の設定
# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
チェンジルート
# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf # chroot /mnt/gentoo /bin/bash # env-update Regenerating /etc/ld.so cache... # source /etc/profile
Portageのインストール
# emerge sync
※ ファイアウォール越えの場合は、emerge-webrsyncを実行
USEの設定
# nano -w /etc/make.conf
# These settings were set by the catalyst build script that automatically builtthis stage # Please consult /etc/make.conf.example for a more detailed example CFLAGS="-O2 -march=pentium3 -pipe -fforce-addr -fomit-frame-pointer -mfpmath=sse,387 -falign-functions=4 -falign-jumps=4" CHOST="i686-pc-linux-gnu" CXXFLAGS="${CFLAGS}" MAKEOPTS="-j2" USE="cjk mmx sse -kde -qt" |
※ -を付けると、その機能は無効にするようになります。
ブートストラップ構築
# export USE="-java" # cd /use/portage # scripts/bootstrap.sh : # unset USE
システムの構築
# emerge system
タイムゾーンの指定
# ln -sf /usr/share/zoneinfo/Japan /etc/localtime
カーネルソースパッケージの展開
# emerge gentoo-dev-source
※ カーネル2.6系の場合。2.4系やSMP機用には別な名前を指定
genkernelによるカーネルの構築
# emerge genkernel : # genkernel all : Kernel compiled successfully! Required Kernel Parameters: root=/dev/ram0 real_root=/dev/$ROOT init=/linuxrc [And "vga=0x317 splash=verbose" if you use a framebuffer] Where $ROOT is the device node for your root portion as the one specified in /etc/fstab You MUST also tell your bootloader to use the generated initrd. : #
カーネルファイル名、initrdファイル名を記録する
# ls /boot/kernel* /boot/initrd* /boot/initrd-2.6.5-gentoo-r1 /boot/kernel-2.6.5-gentoo-r1
ブート時にハードウェアを検出するhotplugのインストール
# emerge hotplug : # rc-update add hotplug default
モジュール追加設定(例:ネットワーク 8139too)
# nano -w /etc/modules.autoload.d/kernel-2.6
8139too を追加
# modules-update
ファイルシステムを起動時にマウントする設定
# nano -w /etc/fstab
/dev/hda1 /boot ext2 noauto,noatime 1 2 /dev/hda2 none swap sw 0 0 /dev/hda3 / reiserfs noatime 0 1 /dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0 #/dev/fd0 /mnt/floppy auto noauto 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 |
ホスト名を指定します
# echo agate > /etc/hostname
DNSドメイン名を指定
# echo stone.world > /etc/dnsdomainname # rc-update add domainname default
ネットワークの起動時設定
# nano -w /etc/conf.d/net
DHCPの場合
iface_eth0="dhcp" |
固定IPの場合
iface_eth0="192.168.0.77 broadcast 192.168.0.255 netmask 255.255.255.0" gateway="eth0/192.168.0.1" |
※非PCMCIAネットワークカードのとき
# rc-update add net.eth0 default
hostsファイルの設定
# nano -w /etc/hosts
システム共通設定
# nano -w /etc/rc.conf
KEYMAP="jp106" SET_WINDOWKEYS="yes" CLOCK="local" EXTENDED_KEYMAPS="ctrl" |
※EXTENDED_KEYMAPS="ctrl"は、CtrlキーとCapsキーの入れ替えを行う。
ブートローダ GRUB の設定
# emerge --usepkg grub : # grub grub> root(hd0,0) grub> setup(ht0) grub> quit #
# nano -w /boot/grub/grub.conf
default 0 timeout 30 splashimage=(hd0,0)/grub/splash.xpm.gz title=Gentoo Linux 2.6.5r1 root (hd0,0) kernel /kernel-2.6.5-gentoo-r1 root=/dev/ram0 init=/linuxrc realroot=/dev/hda3 vga=0x317 splash=verbose initrd /initrd-2.6.5-gentoo-r1 |
システム・ロガ-の設定
# emerge syslog-ng : # rc-update add syslog-ng default
クーロンの設定
# emerge vixie-cron : # rc-update add vixie-cron default
ファイルシステム用ツール類
# emerge reiserfsprogs
rootパスワードの設定、
# passwd
日常作業用ユーザの設定
# useradd tom -m -G users,wheel,audio -s /bin/bash # passwd tom
リブートします。
# exit # cd / # umount /mnt/gentoo/boot /mnt/gentoo/proc /mnt/gentoo # reboot
DHCPの場合、IPアドレスやDNS等の情報は自動的に取得できます。しかし自分のホスト名が解決されないので、設定を追加します。
方法が不明なので、/etc/hostsに直接IPアドレスを記述・・・
wheelグループに加わっているユーザでないと、suでルートにはなれません。
# nano -w /etc/group
でwheelグループにユーザを追加します。
: wheel::10:root,torutk : |
まず、公開鍵/秘密鍵のペアを作成します。まず、クライアントマシン(主として作業するマシン)で実行します。つまり手元のマシン(ローカルマシン)には秘密鍵を置き、リモートマシンには公開鍵を置くからです。秘密鍵をネットワーク上で転送するのはリスクが非常に高いので、公開鍵を転送するようにするためです。SSHにはバージョン1およびバージョン2があるので、バージョン1を使用するか否かで多少作業が変わります。今回はバージョン2を前提にした手順を示しています。
ローカルマシンにおいて公開鍵/秘密鍵を生成し、公開鍵をリモートマシンへ転送
$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/cygdrive/c/home/torutk/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /cygdrive/c/home/torutk/.ssh/id_rsa. Your public key has been saved in /cygdrive/c/home/torutk/.ssh/id_rsa.pub. The key fingerprint is: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx torutk@pcxxxx $ cd .ssh $ scp id_rsa.pub remote:~ Password: id_rsa.pub 100% 210 1.0KB/s 00:00 $
リモートマシンで公開鍵をSSHアクセス用鍵として設定
(ここでは新規にauthorized_keysを作成する場合のコマンド操作例を示しています。既にファイルが存在する場合はそのファイルに内容を追記します)
$ mkdir .ssh $ mv id_rsa.pub .ssh/authorized_keys $ chmod 600 .ssh/authorized_keys $
ローカルマシンからリモートマシンへsloginでアクセス
$ slogin remote Enter passphrase for key '/cygdrive/c/home/toru/.ssh/id_rsa': Last login: Sun May 16 11:55:13 2004 from xxx.xxx.xxx.xxx torutk@remote torutk $
NTPを使用します。まずはntpパッケージをmergeします。
# emerge ntp :
ntpdateコマンドを実行して、NTPサーバの時刻に同期させます。(これはメモリ上の日時を変更するだけなので、再起動すれば消えてしまいます)。
# ntpdate NTPサーバ名
ntpdateコマンドで合わせた時刻を、ハードウェアクロックに保存します。
# hwclock --systohc
環境変数LANGの設定をします。~/.bash_profileに
export LANG=ja_JP.eucJP |
日本語フォントをインストールします。/usr/portage/media-fonts/の中にフォント関連のebuildファイルがあります。適当に入れてみます。
# emerge kochi-substitute shinonome monafont mplus-fonts aquafont aquapfont mikachan-font :
/etc/X11/XF86ConfigのFilesセクションに追記
FontPath "/usr/X11R6/lib/X11/fonts/truetype/" FontPath "/usr/share/fonts/shinonome/" FontPath "/usr/share/fonts/ttf/ja/monafont/" FontPath "/usr/share/fonts/mplus/" FontPath "/usr/share/fonts/ttf/ja/aqua/" FontPath "/usr/share/fonts/ttf/ja/aquap/" FontPath "/usr/share/fonts/ttf/ja/mikachan" |
/etc/X11/XF86ConfigのModulesセクションに追記
Load "xtt" |
Gnomeを使う場合、/etc/fonts/local.confの<fontconfig>要素の子要素を追記
<fontconfig> : <dir>/usr/X11R6/lib/X11/fonts/truetype</dir> </fontconfig> |
# fc-cache -fv
最新のPortageツリーを取得
# emerge sync :
最新のパッケージにアップデート
# emerge -u system :
パッケージのインストール
# emerge パッケージ名
パッケージのアンインストール
# emerge -C パッケージ名
パッケージの古いバージョンを削除
# emerge -c パッケージ名
パッケージの実行内容を表示(実行はしない)
# emerge -p [オプション...] パッケージ名
パッケージの更新(ダウングレード有り)
# emerge -u パッケージ名
# emerge パッケージ名
パッケージ名にはバージョン番号は付けません。付けてemergeを実行すると、"Specific key requires an operator"とエラーメッセージが表示されます。
# emerge sun-jdk : >>> emerge (4 of 4) dev-java/sun-jdk-1.4.2.04-r1 to / !!! j2sdk-1_4_2_04-linux-i586.bin not found in /usr/portage/distfiles. !!! jce_policy-1_4_2.zip not found in /usr/portage/distfiles. !!! dev-java/sun-jdk-1.4.2.04-r1 has fetch restriction turned on. !!! This probably means that this ebuild's files must be downloaded !!! manually. See the comments in the ebuild for more information. * Please download j2sdk-1_4_2_04-linux-i586.bin from: * http://java.sun.com/j2se/1.4.2/download.html * (SDK 32-bit/64-bit for Windows/Linux/Solaris SPARC 32-bit for Solaris x86, th en select download Linux Self-extracting. * and move it to /usr/portage/distfiles ssl * Also download jce_policy-1_4_2.zip from: * http://java.sun.com/j2se/1.4.2/download.html * Java(TM) Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files * and move it to /usr/portage/distfiles
とメッセージが表示されます。http://java.sun.com/j2se/1.4.2/download.htmlから、j2sdk-1.4.2_04-linux-i586.binとjce_policy-1_4_2.zipをダウンロードして/usr/portage/distfilesに置いてからもう一回emergeを実行します。
# emerge sun-jdk :
日本語表示を設定するには、/opt/sun-jdk-1.4.2.04/jre/lib/font.properties.jaを設定します。
変更前 | 変更後 |
---|---|
-watanabe-mincho -wadalab-gothic |
-misc-kochi mincho -misc-kochi gothic |
しかし、リモートX(CygwinのX)の上では日本語が豆腐になっていたので、以下の環境変数を設定しました。
$ export JAVA_FONT=/usr/X11R6/lib/X11/fonts/truetype:/opt/sun-jdk-1.4.2.04/jre/lib/fonts |
Javaは直接フォントをファイルから読み出す能力があるので、環境変数JAVA_FONTにフォントのあるパスを指定すればOKのよう。
さて、/usr/portage/dev-java/sun-jdk/の中を見ると、sun-jdk-1.4.2.04-r1.ebuildの他に最新版のJDK用のsun-jdk-1.5.0_beta1-r1.ebuildというファイルがあります。これをインストールするにはどうしたらよいのでしょうか?
# emerge sun-jdk-1.5.0 Calculating dependencies !!! Problem in dev-java/sun-jdk-1.5.0 dependencies. !!! "Specific key requires an operator (dev-java/sun-jdk-1.5.0) (try adding an ' =')"
と怒られます。~X86 というのが理由のキーワードらしいのですが、よく分かりません。
この場合、直接ebuildファイルを指定します。
# emerge /usr/portage/dev-java/sun-jdk/sun-jdk-1.5.0_beta1-r1.ebuild : !!! j2sdk-1_5_0-beta-linux-i586.bin not found in /usr/portage/distfiles. !!! dev-java/sun-jdk-1.5.0_beta1-r1 has fetch restriction turned on. !!! This probably means that this ebuild's files must be downloaded !!! manually. See the comments in the ebuild for more information. * Please download j2sdk-1_5_0-beta-linux-i586.bin from: * http://java.sun.com/j2se/1.5.0/download.jsp * (SDK 32-bit/64-bit for Windows/Linux/Solaris SPARC 32-bit for Solaris x86, th en select download Linux Self-extracting or Linux AMD64 self-extracting, dependi ng on your arch.) * and move it to /usr/portage/distfiles
となるので、こちらもSunのサイトからJ2SE SDK1.5.0betaを入手します。/usr/portage/distfilesに置いてからもう一回emergeを実行します。
# emerge /usr/portage/dev-java/sun-jdk/sun-jdk-1.5.0_beta1-r1.ebuild :
# emerge /usr/portage/dev-java/java-sdk-docs/java-jdk-docs-1.5.0.ebuild :
# emerge xfree :
時間はかかります。ウィンドウマネージャは、twmが含まれます。
# emerge --pretend gnome : # emerge gnome : # emerge xscreensaver : # env-update && source /etc/profile
時間はかなりかかります。
# nano -w /etc/rc.conf
XSESSION="Gnome" DISPLAYMANAGER=gdm |
# rc-update add xdm default
# /usr/X11R6/bin/xf86config
:
Press enter to continue, or ctrl-c to abord.
[Enter]
:
Enter a protocol number: 7 (IMPS/2 : ホイールマウスの場合)
:
Do you want to enable Emulate3Buttons? n (ホイールマウスの場合、ホイールが中ボタンになる)
:
Mouse device: [Enter]
:
Enter a number to choose the keyboard.
Press enter for the next page
11 (Japanese 106-key)
:
Enter a number to choose the country.
Press enter for the next page
42 (Japanese)
:
Please enter a variant name for 'jp' layout.
Or just press enter for default variant
[Enter]
:
Please answer the following question with
either 'y' or 'n'.
Do you want to select additional XKB options
(group switcher, group indicator, etc.)?
n
:
Now we want to set the specifications of
the monitor. ...
:
Press enter to continue, or ctrl-c to abort.
[Enter]
:
You must indicate the horizontal sync range
of your monitor.
:
Enter your choise (1-11): 11 (Enter your own horizontal sync range)
:
Horizontal sync range: 30-96
:
You must indicate the vertical sync range
of your monitor.
:
Enter your choise: 5 (Enter your own vertical sync range)
:
Vertical sync range: 50-160
:
Enter an identifier for your monitor definition:
FlexScanT565
:
Now we must configure video card specific
settings. ...
:
Do you want to look at the card database?
y
:
Enter a number to choose the corresponding
card definition.
Press enter for the next page, q to continue
configuration.
3 (** 3DLabs, TI (generic) [glint] -)
:
Your selected card definition:
Identifier: ** 3DLabs, TI (generic) [glint]
Chipset: -
Driver: glint
Press enter to continue, or ctrl-c to abort.
[Enter]
:
How much video memory do you have on your
video card:
:
Enter your choise: 6 (8192K)
:
Enter an identifier for your video card definition:
permedia2
:
For each depth, a list of modes (resolutions)
is defined. ...
Curently it is set to :
"1280x1024" "1024x768"
"800x600" "640x480" for
8-bit
"1280x1024" "1024x768"
"800x600" "640x480" for
16-bit
"1280x1024" "1024x768"
"800x600" "640x480" for
24-bit
Modes that cannot be supported due to monitor
or clock constraints will
be automatically skipped by the server.
:
Enter your choice: 3 (Change the modes for 24-bit colors)
:
Which modes? 942 ("1152x864" "1024x768"
"640x480")
:
Do you want a virtual screen that is larger
than the physical screen? n
:
Enter your choise: 4 (The modes are OK, continue.)
:
Enter a number to choose the default depth.
4 (16 bits ... colors)
:
Shall I write it to /etc/X11/XF86Config?
y
:
#
日本語等に対応したX上のターミナル。ktermとどちらがよいのかは?
# emerge mlterm :
フォント設定は
未
# emerge apache :
起動は、
# /etc/init.d/apache2 start
設定ファイルは、/etc/apache2/conf/apache2.conf
が読み込まれるようです。中でcommonapache2.confをIncludeしています。
デフォルトでは、DocumentRootが/var/www/localhost/htdocs、ServerRootが/usr/lib/apache2
各ユーザのホームディレクトリ直下のpublic_htmlを/~ユーザ名/のURLでアクセスできる設定にはなっています。
# emerge imagemagick :
# emerge mysql : * IMPORTANT: 22 config files in /etc need updating. * IMPORTANT: 1 config files in /usr/X11R6/lib/X11/xkb need updating. * Type emerge --help config to learn how to update config files.
となるので、続いて
# etc-update :
を実行しました。
また、この状態ではデータベース初期化が行われていないので、以下を実行します。
# /usr/bin/mysql_install_db Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /etc/init.d/mysql start (you have to start the server first!) /usr/bin/mysqladmin -u root -h hostname password 'new-password' /usr/bin/mysqladmin -u root password 'new-password' See the manual for more instructions. Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at https://order.mysql.com #
MySQLの起動方法(コマンド起動/終了)
# /etc/init.d/mysql start : # /etc/init.d/mysql stop :
MySQLを自動起動する方法
# rc-update add mysql default
動作確認(SQLコマンドライン環境)
$ mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 4.0.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +----------+ | Database | +----------+ | test | +----------+ 1 row in set (0.00 sec) mysql> use test; Database changed mysql> show tables; Empty set (0.00 sec) mysql>quit; Bye $