Gentoo安装备忘


获取ISO

wget http://mirrors.163.com/gentoo/releases/amd64/autobuilds/current-install-amd64-minimal/install-amd64-minimal-20180415T214502Z.iso

从ISO文件引导系统

磁盘分区

parted -a optimal /dev/sda

mklabel gpt
unit mib

mkpart primary 1 3
name 1 grub
set 1 bios_grub on

mkpart primary 3 256
name 2 boot
set 2 boot on

mkpart primary 256 8448
name 3 swap

mkpart primary 8448 -1
name 4 rootfs

print

quit

mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda4

mkswap /dev/sda3
swapon /dev/sda3

mount /dev/sda4 /mnt/gentoo

安装Gentoo

cd /mnt/gentoo

wget http://mirrors.163.com/gentoo/releases/amd64/autobuilds/current-install-amd64-minimal/stage3-amd64-20180415T214502Z.tar.xz
# hardened
wget http://mirrors.163.com/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-20180517T214504Z.tar.xz
# systemd
wget http://mirrors.163.com/gentoo/releases/amd64/autobuilds/current-stage3-amd64-systemd/stage3-amd64-systemd-20180518.tar.bz2

tar xpf stage3-amd64-20180415T214502Z.tar.xz --xattrs-include='*.*' --numeric-owner

cp /mnt/gentoo/etc/portage/make.conf /mnt/gentoo/etc/portage/make.conf.bk

cat <<EOF > /mnt/gentoo/etc/portage/make.conf
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j9 -l8"
EMERGE_DEFAULT_OPTS="--jobs=8 --load-average=8 --ask --verbose --with-bdeps=y"
PORTAGE_NICENESS=15

# get by cpuid2cpuflags(emerge app-portage/cpuid2cpuflags)
CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
ACCEPT_KEYWORDS="amd64"

#GENTOO_MIRRORS="https://mirrors.tuna.tsinghua.edu.cn/gentoo/"
#GENTOO_MIRRORS="https://mirrors.163.com/gentoo/"
GENTOO_MIRRORS="http://mirrors.ustc.edu.cn/gentoo/"

L10N="en-US zh-CN"
#LINGUAS="en_US zh_CN"
LC_MESSAGES="C"

PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"

#FEATURES="ccache"
#CCACHE_SIZE="8G"

#USE="dbus policykit udisks udev consolekit X"
#VIDEO_CARDS="vmware"
#INPUT_DEVICES="keyboard mouse"
EOF

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.bk
cat <<EOF > /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
[DEFAULT]
main-repo = gentoo

[gentoo]
location = /usr/portage
sync-type = rsync
#sync-uri = rsync://rsync.gentoo.org/gentoo-portage
#sync-uri = rsync://rsync.cn.gentoo.org/gentoo-portage
sync-uri = rsync://rsync.mirrors.ustc.edu.cn/gentoo-portage/
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = no
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4

# for daily squashfs snapshots
#sync-type = squashdelta
#sync-uri = mirror://gentoo/../snapshots/squashfs
EOF

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}"

mkdir /boot
mount /dev/sda2 /boot

emerge-webrsync
emerge --sync
eselect profile list
eselect profile set default/linux/amd64/17.0/desktop/plasma
emerge --ask --update --deep --newuse @world

ls /usr/share/zoneinfo
echo "Asia/Shanghai" > /etc/timezone
emerge --config sys-libs/timezone-data

cat <<EOF >/etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GB18030
zh_CN.GBK GBK
zh_CN.GB2312 GB2312
zh_CN.UTF-8 UTF-8
EOF
locale-gen
locale -a
eselect locale list
eselect locale set en_US.utf8
env-update && source /etc/profile && export PS1="(chroot) $PS1"

配置内核

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

emerge sys-kernel/genkernel
nano -w /etc/fstab
# /dev/sda2 /boot ext2 defaults 0 2

genkernel all
# or genkernel --lvm all

ls /boot/kernel* /boot/initramfs*

emerge sys-kernel/linux-firmware

配置系统

nano -w /etc/fstab
#/dev/sda2  /boot       ext4    defaults,noatime    0 2
#/dev/sda3  none        swap    sw                  0 0
#/dev/sda4  /           ext4    noatime             0 1
#/dev/cdrom /mnt/cdrom  auto    noauto,user         0 0

cp /etc/conf.d/hostname /etc/conf.d/hostname.bk
echo "hostname=\"gentoo\"" > /etc/conf.d/hostname

emerge --noreplace net-misc/netifrc
echo "config_eno16777736=\"dhcp\"" > /etc/conf.d/net

passwd

cd /etc/init.d
ln -s net.lo net.eno16777736
rc-update add net.eno16777736 default

安装系统工具

emerge app-admin/sysklogd
rc-update add sysklogd default

emerge sys-process/cronie
rc-update add cronie default

emerge sys-apps/mlocate

rc-update add sshd default

emerge net-misc/dhcpcd
rc-update add dhcpcd default

rc-update add dbus default
rc-update add udev sysinit
rc-update add consolekit default

安装Grub

emerge sys-boot/grub:2
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

exit
cd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -R /mnt/gentoo
reboot

安装系统内核工具

emerge app-portage/eix app-portage/gentoolkit

更新系统

eix-sync
emerge -avuDN --tree world
emerge -av --depclean
revdep-rebuild -v -- --ask
dispatch-conf
eclean-dist -d
eix-test-obsolete
glsa-check -t all
glsa-check -f all

安装Xorg

emerge --ask x11-base/xorg-drivers media-libs/mesa x11-base/xorg-x11 x11-wm/twm x11-terms/xterm
startx

安装Kde

emerge --ask kde-plasma/plasma-meta
echo "DISPLAYMANAGER=\"sddm\"" >> /etc/conf.d/xdm
rc-update add xdm default

useradd -m k
passwd k
#su k
#groups
#usermod -a -G plugdev k

emerge app-portage/layman
layman -L
layman -a gentoo-zh

emerge app-i18n/fcitx app-i18n/fcitx-cloudpinyin app-i18n/kcm-fcitx
cat <<EOF >>/home/k/.xprofile
eval "$(dbus-launch --sh-syntax --exit-with-session)"
export XMODIFIERS="@im=fcitx"
export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx
EOF

#/etc/init.d/xdm restart
reboot

安装软件

emerge --ask kde-apps/kde-apps-meta
emerge --ask www-client/google-chrome

emerge --ask app-portage/pfl
# e-file = apt-file

更新系统时间

# ntp
emerge --ask net-misc/openntpd
mv /etc/ntpd.conf /etc/ntpd.conf.bk
cat <<EOF >/etc/ntpd.conf
servers 0.cn.pool.ntp.org
servers 1.cn.pool.ntp.org
servers 2.cn.pool.ntp.org
servers 3.cn.pool.ntp.org
EOF
/etc/init.d/ntpd start
rc-update add ntpd default

cp /etc/conf.d/hwclock /etc/conf.d/hwclock.bk
cat <<EOF >/etc/conf.d/hwclock
clock="local"
clock_args=""
EOF

hwclock --systohc --utc
hwclock --hctosys --localtime
date

文章作者: Kiba Amor
版权声明: 本博客所有文章除特別声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来源 Kiba Amor !
  目录