Gentoo Linux : Install on Vmware and LAMP & FTP
Contents
GentooをLVM,systemdでインストール
「Gentooのダウンロード」「VMwareマシンの設定」は前ページを参照
UEFI GPT でインストール
インストールプロセスの開始
途中でkey mapの選択では Key map : jp
SSH接続を有効化して、Teraterm等で作業できるようにする
|
1 2 3 4 5 6 7 8 9 10 11 12 |
rootパスワードを変更する livdcd~# passwd root ssh設定ファイル変更 livdcd~# vi /etc/ssh/sshd_config PasswordAuthentication yes sshdサービス起動 livdcd~# /etc/init.d/sshd start サーバーIP確認 livdcd~# ip a |
TeraTermで接続
Host : server IP
SSH : 22
Use name : root
Passphrase : 上記で変更したパスワード
ディスクとパーティションセットアップ
1.ディスクの確認
|
1 2 3 4 5 6 7 8 9 10 11 12 |
livdcd~# fdisk -l Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop0: 511.46 MiB, 536309760 bytes, 1047480 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes |
2.gdiskでパーティションを作成
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
livecd ~ # gdisk /dev/sda GPT fdisk (gdisk) version 1.0.10 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries in memory. Command (? for help): o This option deletes all partitions and creates a new protective MBR. Proceed? (Y/N): Y EFI Bootパーティションを作成 Command (? for help): n Partition number (1-128, default 1): First sector (34-125829086, default = 2048) or {+-}size{KMGTP}: Last sector (2048-125829086, default = 125827071) or {+-}size{KMGTP}: +512M Current type is 8300 (Linux filesystem) Hex code or GUID (L to show codes, Enter = 8300): EF00 Changed type of partition to 'EFI system partition' swap,rootパーティションの為のLVMパーティションを作成。 残り全て、ファイルタイプは8E00 Command (? for help): n Partition number (2-128, default 2): First sector (34-125829086, default = 1050624) or {+-}size{KMGTP}: Last sector (1050624-125829086, default = 125827071) or {+-}size{KMGTP}: Current type is 8300 (Linux filesystem) Hex code or GUID (L to show codes, Enter = 8300): 8E00 Changed type of partition to 'Linux LVM' パーティション確認 Command (? for help): p Disk /dev/sda: 125829120 sectors, 60.0 GiB Model: VMware Virtual S Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): C9F8422A-E65C-49AE-AEB1-714283C05ABD Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 125829086 Partitions will be aligned on 2048-sector boundaries Total free space is 4029 sectors (2.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB EF00 EFI system partition 2 1050624 125827071 59.5 GiB 8E00 Linux LVM パーティション書き込み Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully. |
3.パーティションフォーマット、マウント
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
livecd ~ # mkfs.vfat -F32 /dev/sda1 mkfs.fat 4.2 (2021-01-31) livecd ~ # pvcreate /dev/sda2 Physical volume "/dev/sda2" successfully created. livecd ~ # vgcreate vg01 /dev/sda2 Volume group "vg01" successfully created livecd ~ # lvcreate -L 4G -n swap vg01 Logical volume "swap" created. livecd ~ # lvcreate -l 100%FREE -n root vg01 Logical volume "root" created. livecd ~ # mkswap /dev/mapper/vg01-swap Setting up swapspace version 1, size = 4 GiB (4294963200 bytes) no label, UUID=1c64d870-8f00-40b4-9709-3905c74532fc livecd ~ # mkfs.xfs /dev/vg01/root meta-data=/dev/vg01/root isize=512 agcount=4, agsize=3636992 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=1 inobtcount=1 nrext64=0 data = bsize=4096 blocks=14547968, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=16384, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 livecd ~ # mount /dev/vg01/root /mnt/gentoo livecd ~ # swapon /dev/vg01/swap |
4.stage tarballのダウンロード、展開
Downloadsのページで「Stage3 systemd」を選択
|
1 2 3 4 |
livecd ~ # cd /mnt/gentoo livecd /mnt/gentoo # wget https://gentoo.osuosl.org/releases/amd64/autobuilds/20250406T165023Z/stage3-amd64-systemd-20250406T165023Z.tar.xz livecd /mnt/gentoo # tar -xvf stage3-amd64-systemd-20250406T165023Z.tar.xz |
5.コンパイル時のオプション
|
1 2 3 4 5 6 7 8 9 10 |
livecd /mnt/gentoo # nano -w /mnt/gentoo/etc/portage/make.conf # 下記に変更 COMMON_FLAGS="-march=native -O2 -pipe" #次の行を追加 MAKEOPTS="-j3" #次の行を追加 ACCEPT_LICENSE="* -@EULA" |
6.高速ミラーの選択 jpを選択
|
1 |
livecd /mnt/gentoo # mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf |

Gentoo ebuild リポジトリ
|
1 2 |
livecd /mnt/gentoo # mkdir --parents /mnt/gentoo/etc/portage/repos.conf livecd /mnt/gentoo # cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf |
7.DNSを設定
|
1 |
livecd /mnt/gentoo # cp --dereference /etc/resolv.conf /mnt/gentoo/etc/ |
8.ファイルシステムのマウント
|
1 2 3 4 5 6 7 |
livecd /mnt/gentoo # mount --types proc /proc /mnt/gentoo/proc livecd /mnt/gentoo # mount --rbind /sys /mnt/gentoo/sys livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/sys livecd /mnt/gentoo # mount --rbind /dev /mnt/gentoo/dev livecd /mnt/gentoo # mount --make-rslave /mnt/gentoo/dev livecd /mnt/gentoo # mount --bind /run /mnt/gentoo/run livecd /mnt/gentoo # mount --make-slave /mnt/gentoo/run |
9.新環境へ移行
chrootを使用して、ルートロケーションを/(インストールメディア上)から/mnt/gentoo/(パーティション上)に変更します。
|
1 2 3 4 |
livecd /mnt/gentoo # chroot /mnt/gentoo /bin/bash livecd / # source /etc/profile livecd / # export PS1="(chroot) ${PS1}" (chroot) livecd / # |
10.ブートパーティションをマウント
|
1 2 3 |
(chroot) livecd / # mkdir -p /boot (chroot) livecd / # mkdir -p /boot/efi (chroot) livecd / # mount /dev/sda1 /boot/efi |
11.Portage設定
|
1 |
(chroot) livecd / # emerge-webrsync |
12.プロファイルを選択
選択中のプロファイルを表示する。
|
1 |
(chroot) livecd / # eselect profile list |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Available profile symlink targets: [1] default/linux/amd64/17.1 (exp) [2] default/linux/amd64/17.1/selinux (exp) [3] default/linux/amd64/17.1/hardened (exp) [4] default/linux/amd64/17.1/hardened/selinux (exp) [5] default/linux/amd64/17.1/desktop (exp) [6] default/linux/amd64/17.1/desktop/gnome (exp) [7] default/linux/amd64/17.1/desktop/gnome/systemd/merged-usr (exp) [8] default/linux/amd64/17.1/desktop/plasma (exp) [9] default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr (exp) [10] default/linux/amd64/17.1/desktop/systemd/merged-usr (exp) [11] default/linux/amd64/17.1/developer (exp) [12] default/linux/amd64/17.1/no-multilib (exp) [13] default/linux/amd64/17.1/no-multilib/hardened (exp) [14] default/linux/amd64/17.1/no-multilib/hardened/selinux (exp) [15] default/linux/amd64/17.1/no-multilib/systemd/merged-usr (exp) [16] default/linux/amd64/17.1/no-multilib/systemd/selinux/merged-usr (exp) [17] default/linux/amd64/17.1/systemd/merged-usr (exp) [18] default/linux/amd64/17.1/systemd/selinux/merged-usr (exp) [19] default/linux/amd64/17.1/clang (exp) [20] default/linux/amd64/17.1/systemd/clang/merged-usr (exp) [21] default/linux/amd64/23.0 (stable) [22] default/linux/amd64/23.0/systemd (stable) * [23] default/linux/amd64/23.0/desktop (stable) [24] default/linux/amd64/23.0/desktop/systemd (stable) |
今回インストールするのは既に選択されている
[22] default/linux/amd64/23.0/systemd (stable) *
もし、設定されていなければ次のようにして22を指定する
|
1 |
(chroot) livecd / # eselect profile set 22 |
13.@worldのセットを更新
make.confを編集
|
1 2 3 |
(chroot) livecd / # nano /etc/portage/make.conf 下記を追記する USE="device-mapper" |
@worldセットの更新
|
1 2 |
(chroot) livecd / # emerge --ask --verbose --update --deep --newuse @world (chroot) livecd / # emerge --depclean |
14.タイムゾーンの設定
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
(chroot) livecd / # ls /usr/share/zoneinfo Africa Cuba GMT+0 Kwajalein Poland Zulu America EET GMT-0 Libya Portugal iso3166.tab Antarctica EST GMT0 MET ROC leap-seconds.list Arctic EST5EDT Greenwich MST ROK leapseconds Asia Egypt HST MST7MDT Singapore tzdata.zi Atlantic Eire Hongkong Mexico Turkey zone.tab Australia Etc Iceland NZ UCT zone1970.tab Brazil Europe Indian NZ-CHAT US zonenow.tab CET Factory Iran Navajo UTC CST6CDT GB Israel PRC Universal Canada GB-Eire Jamaica PST8PDT W-SU Chile GMT Japan Pacific WET # timezoneを日本にする (chroot) livecd / # echo "Japan" > /etc/timezone #タイムゾーンの再設定 (chroot) livecd / # emerge --config sys-libs/timezone-data |
15.ロケールの設定(英語表記にする)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
(chroot) livecd / # nano -w /etc/locale.gen #下記追記または該当行コメント外す en_US ISO-8859-1 en_US.UTF-8 UTF-8 反映させる (chroot) livecd / # locale-gen 言語をen_US.utf8に設定する (chroot) livecd / # eselect locale list Available targets for the LANG variable: [1] C [2] C.utf8 [3] POSIX [4] en_US [5] en_US.iso88591 [6] en_US.utf8 [7] C.UTF8 * [ ] (free form) (chroot) livecd / # eselect locale set 6 Setting LANG to en_US.utf8 ... Run ". /etc/profile" to update the variable in your shell. (chroot) livecd / # env-update && source /etc/profile && export PS1="(chroot) ${PS1}" |
16.fstabの設定
「/dev/mapper/vg01-root」と「/dev/mapper/vg01-swap」のUUIDを確認する
|
1 2 3 4 5 6 7 8 |
device fs_type label mount point UUID ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /dev/sr0 iso9660 Gentoo-amd64-20250119 (in use) 2025-01-19-18-06-14-00 /dev/mapper/vg01-root xfs / c5a15ae8-87d6-4e05-821c-ebe7fd9234fe /dev/loop0 squashfs (in use) /dev/mapper/vg01-swap swap [SWAP] f4e74133-e90b-4db1-a0f4-4fee6adc781c /dev/sda2 LVM2_member (in use) djPMi2-SLVR-PsWd-1gwH-Xy44-VSII-u3jseU /dev/sda1 vfat /boot/efi E00A-385B |
「/dev/mapper/vg01-root」のUUIDは「c5a15ae8-87d6-4e05-821c-ebe7fd9234fe」
「/dev/mapper/vg01-swap」のUUIDは「f4e74133-e90b-4db1-a0f4-4fee6adc781c」
fstabファイルに下記のように追記
|
1 2 3 4 5 |
(chroot) livecd / # nano /etc/fstab /dev/sda1 /boot/efi vfat noauto,noatime 0 2 UUID=c5a15ae8-87d6-4e05-821c-ebe7fd9234fe / ext4 noatime 0 1 UUID=f4e74133-e90b-4db1-a0f4-4fee6adc781c none swap sw 0 0 /dev/cdrom /mnt/cdrom auto noauto,ro 0 0 |
17.firmware、pciutilsのインストール
|
1 2 |
(chroot) livecd / # emerge -a linux-firmware (chroot) livecd / # emerge -a pciutils |
18.カーネルのセットアップ:genkernelの使用
|
1 2 3 4 5 6 7 8 9 10 11 12 |
(chroot) livecd / # emerge -avt gentoo-sources (chroot) livecd / # emerge --ask sys-kernel/genkernel (chroot) livecd / # nano -w /etc/genkernel.conf 下記のように変更 #MENUCONFIG="no" MENUCONFIG="yes" 下記のように変更 #LVM="no" LVM="yes" 下記コメントアウトして、その下に追加 # DEFAULT_KERNEL_SOURCE="/usr/src/linux" DEFAULT_KERNEL_SOURCE="/usr/src/linux-6.12.21-gentoo" |
menu configが表示されればESCキーを2回押して、インストールを進める
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
(chroot) livecd / # genkernel all #/bootディレクトリ配下にカーネルが展開される(時間がかかる) * Kernel compiled successfully! * * --no-bootloader set; Skipping bootloader update ... * * Required kernel parameter: * * root=/dev/$ROOT * * Where $ROOT is the device node for your root partition as the * one specified in /etc/fstab * If you require Genkernel's hardware detection features, you MUST * tell your bootloader to use the provided initramfs file '/boot/initramfs-6.12.21-gentoo-x86_64.img'. * WARNING... WARNING... WARNING... * Additional kernel parameters that *may* be required to boot properly: * - Add "dolvm" for LVM support * Do NOT report kernel bugs as genkernel bugs unless your bug * is about the default genkernel configuration... * * Make sure you have the latest ~arch genkernel before reporting bugs. |
|
1 2 |
(chroot) livecd / # ls /boot/vmlinu* /boot/initramfs* /boot/initramfs-6.12.21-gentoo-x86_64.img /boot/vmlinuz-6.12.21-gentoo-x86_64 |
シンボリックリンクの作成
|
1 |
(chroot) livecd / # ln -sf /proc/self/mounts /etc/mtab |
lvmをインストール
|
1 |
(chroot) livecd / # genkernel --lvm initramfs |
make.confファイルを編集
|
1 2 3 |
(chroot) livecd / # nano /etc/portage/make.conf 下記を追記します。 GRUB_PLATFORMS="efi-64" |
19.dhcpcd, sysklogd, cronie, mlocateをインストール
|
1 2 3 4 |
(chroot) livecd / # emerge -a dhcpcd (chroot) livecd / # emerge -a sysklogd (chroot) livecd / # emerge -a cronie (chroot) livecd / # emerge -a mlocate |
20.rootパスワードを設定
|
1 |
(chroot) livecd / # passwd |
21.grubのセットアップ
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
(chroot) livecd / # emerge -a grub:2 /etc/default/grubファイルを編集 (chroot) livecd / # nano /etc/default/grub 下記を追記 GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd dolvm rd.lvm.vg=vg01 rd.lvm.lv=vg01/root rd.lvm.lv=vg01/swap" GRUBをインストール (chroot) livecd / # grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable (chroot) livecd / # grub-mkconfig -o /boot/grub/grub.cfg システムを再起動 (chroot) livecd / # exit (chroot) livecd / # cd (chroot) livecd / # umount -l /mnt/gentoo/dev{/shm,/pts,} (chroot) livecd / # umount -R /mnt/gentoo (chroot) livecd / # reboot |
再起動するとGentoo Linuxにログインできる
Gentoo Linuxインストール後の設定
dhcpcd及びsshdの起動及び自動起動設定
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
dhcpcdの起動と自動起動設定 localhost ~# systemctl start dhcpcd localhost ~# systemctl enable dhcpcd ssh設定ファイル変更 localhost ~# nano /etc/ssh/sshd_config 下記に変更 PermitRootLogin yes PasswordAuthentication yes sshサービスの再起動及び自動起動設定 localhost ~# systemctl restart sshd localhost ~# systemctl enable sshd |
サーバーIPアドレス確認して
Teratermで接続
|
1 |
localhost ~# ip a |
デフォルトのエディタをvimにする
|
1 2 3 4 5 6 7 8 9 10 11 12 |
インストール localhost ~# emerge --ask app-editors/vim localhost ~# eselect editor list Available targets for the EDITOR variable: [1] nano [2] ex [3] vi [4] vim [ ] (free form) localhost~# eselect editor set 4 localhost~# . /etc/profile |
一般ユーザの追加とsudoの導入
①一般ユーザを追加してパスワードを設定する(今回は一般ユーザーhuongを作成)
|
1 2 3 4 5 |
localhost ~# LANG='C' useradd -m -G users,portage,wheel -s /bin/bash huong localhost ~# LANG='C' passwd huong Enter new password: Retype new password: passwd: password updated successfully |
➁sudoをインストール
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
ログアウトして一般ユーザでログインしなおす。 # exit # exit localhost login: huong Password: huong@localhost ~ $ suでrootになり、sudoをインストールする。 huong@localhost ~ $ su - Password: (rootパスワードを入力) localhost ~ # emerge -av sudo visudoでsudoを設定する。 localhost ~# visudo 125行目コメント解除 %wheel ALL=(ALL:ALL) ALL suをぬけてsudoを試してみる。 # exit huong@localhost ~ $ sudo echo huong Password: (huongのパスワードを入力する) huong |
ホスト名変更
ホスト名をLepardに変更
|
1 2 |
localhost ~# hostnamectl hostname Lepard localhost ~# reboot |
固定IPアドレス設定
192.168.11.83に設定する場合
まずインターフェース名確認
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Lepard ~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:af:d6:8a brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.11.44/24 brd 192.168.11.255 scope global dynamic noprefixroute ens33 valid_lft 172774sec preferred_lft 151174sec inet6 fe80::c56f:768a:7b1:d6bb/64 scope link valid_lft forever preferred_lft forever |
インターフェース名はens33であり、現状ではDHCPで192.168.11.44に割り当てられている
dhcpcd.confファイルを編集し、dhcpcdを再起動する
|
1 2 3 4 5 6 7 |
Lepard ~# vi /etc/dhcpcd.conf static ip_address=192.168.11.83/24 static routers=192.168.11.1 static domain_name_servers=192.168.11.1 再起動 Lepard ~# systemctl restart dhcpcd |
Apache MySQL PHP PhpMyAdminについては前ページ参照
12
