LoginSignup
0
0

More than 3 years have passed since last update.

Gentoo Linux構築の手順 パート3

Last updated at Posted at 2021-03-10

目的

Gentoo Linuxのハンドブックをもとにgentoo linuxを開発しました
ハンドブックでは分かりづらいため、他の方が作る際に少しでも助けになればいいとおもい記事にしました。
Gentoo Linux構築の手順 パート1
Gentoo Linux構築の手順 パート2
Gentoo Linux構築の手順 パート3
Gentoo Linux構築の手順 パート4
Gentoo Linuxを構築する上での用語集

chroot する

nano -w /mnt/gentoo/etc/portage/make.conf

Gentoo ebuild リポジトリ

mkdir --parents /mnt/gentoo/etc/portage/repos.conf
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

DNS 情報をコピーする

cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

必要なファイルシステムをマウントする

mount --types proc /proc /mnt/gentoo/proc 
mount --rbind /sys /mnt/gentoo/sys 
mount --make-rslave /mnt/gentoo/sys 
mount --rbind /dev /mnt/gentoo/dev 
mount --make-rslave /mnt/gentoo/dev

新しい環境に入る

chroot /mnt/gentoo /bin/bash 
source /etc/profile 
export PS1="(chroot) ${PS1}"

export PS1="(chroot) ${PS1}"をたたいた後に
ターミナルの左側のlivecdが(chroot)livecd
となる.
これはchroot環境であることを忘れないようするために、シェルのプロンプトを変更する仕様
スクリーンショット 2021-03-13 12.51.38.png

ブートパーティションをマウントする

mount /dev/sda2 /boot

Portageを設定する

emerge-webrsync

任意自由選択: Gentoo ebuildリポジトリを更新する

emerge --sync

ニュースを読む

eselect news list
eselect news read
man news.eselect

適切なプロファイルを選ぶ

eselect profile list
eselect profile set *

*には数字を入力する
eselect profile listで表示された、no-multilibの左の数値を入力する

@worldの更新

emerge --ask --verbose --update --deep --newuse @world

更新にしばらく時間がかかる

USE変数を設定する

nano -w /etc/portage/make.conf

上記コマンドを入力して表示された画面に
USE="-gtk -gnome qt4 qt5 kde dvd alsa cdr"
を追加
crtl+xでsavaし、Enterを選択

タイムゾーン

ls /usr/share/zoneinfo

ロケールの設定

Locale generation

nano -w /etc/locale.gen

次のロケールの例では、英語と日本語を指定
C.UTF8 UTF-8
ja_JP.ECU-JP ECU-JP

Locale selection

eselect locale list
eselect locale set *

*に数値をいれる 
ここでは英語(C.utf8かen_US.utf8)を選択すること。
理由:ハンドブックではここで日本語を選択しているが、
その後の章でエラーが起きたときにエラー文字化けを起こしてしまうため。

例 文字化けしたエラー文 ■の部分が文字化けとなる
スクリーンショット 2021-03-13 10.00.49.png

例 英語に設定し、文字化けしていない場合のエラー文
スクリーンショット 2021-03-13 10.28.00.png

カーネルソースのインストール

emerge --ask sys-kernel/gentoo-sources
ls -l /usr/src/linux

デフォルト: マニュアル設定

はじめに

emerge --ask sys-apps/pciutils
cd /usr/src/linux 
make menuconfig

以降 ハンドブックに則りオプションを設定する

コンパイルおよびインストール

make && make modules_install
make install

カーネルモジュール

find /lib/modules/<kernel version>/ -type f -iname '*.o' -or -iname '*.ko' | less

は環境によって異なります。
このコマンドでは、 find で検索したファイルを パイプ「|」を通して less という表示コマンドに渡しています
less の表示画面からは「Q」キーで抜けられます。(Ctrl+Zで強制終了もできます)

の自動入力(補完)方法
find /lib/modules/ まで入力した後、 Tab キーを1~2回押す
find /lib/modules/5.4.97-gentoo-x86_64と表示
※5.4.97-gentoo-x86_64は環境によって異なる

画面を見れること確認したら「Q」キーで抜ける

mkdir -p /etc/modules-load.d
nano -w /etc/modules-load.d/network.conf

苦戦したところ

(エラーが出た際に解決の糸口になれば幸いです)

mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf

をたたいてもエラー表示
-iの-がぬけているだけだった

mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev

のところでmountをするとエラーが表示
→exitでchrootをぬけてrebootをたたく
 rebootするとマウントがすべて外れるため、mount /dev/sda4 /mnt/gentoo(ルートパーティションのマウント)をたたく
stage tarball をダウンロードする、stage tarball を展開するのところコマンドを再度行う
その後mount --types proc /proc /mnt/gentoo/proc以降できました
 (stage tarball を展開ができてなかったためにエラーが表示されていた可能性がある)

ls -l /usr/src/linux

lrwxrwxrwx 1 root root 19 Feb 27 16:12 /usr/src/linux -> linux-5.4.97-gentoo
といった表示がでない
→-l(小文字のエル)とたたくべきところを-I(大文字のアイ)とたたいていた

make && make modules_install
make instal(コンパイルおよびインストール)

のところでエラー表示
→ディレクトリがちがう(cd /usr/src/linuxをたたきわすれていた)

0
0
0

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