Gentoo Base 安装
Gentoo Install
- 分区
下面的部分解释了怎样使用fdisk来创建范例分区布局,范例分区布局我们在前面已经提到过了。
Partition Description
/dev/sda1 BIOS boot partition 2M
/dev/sda2 Boot Partition 100M
/dev/sda3 Swap partition 1G
/dev/sda4 Root partition -1
Device Boot Start End Blocks Id System
/dev/sda1 1 3 5198+ ef EFI (FAT-12/16/32)
/dev/sda2 * 3 14 105808+ 83 Linux
/dev/sda3 15 81 506520 82 Linux swap
/dev/sda4 82 3876 28690200 83 Linux
# 创建EFI,如果不是用uefi启动的话,跳过这里
mkfs.fat -F32 /dev/sda1
zpool create -f -o ashift=12 -o cachefile= -O compression=lz4 -m none -R /mnt/gentoo rpool /dev/sda4
zfs create rpool/ROOT
zfs create -o mountpoint=/ rpool/ROOT/gentoo
zfs create -o mountpoint=/home rpool/HOME
zfs create -o mountpoint=/usr rpool/USR
zpool create -f -d -o ashift=12 -o cachefile= -m /boot -R /mnt/gentoo boot /dev/sda2
- 安装基础系统
tar xpvf stage*
mount /dev/sda1 /boot/efi
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.config
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
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
test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm
chmod 1777 /dev/shm
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"
emerge-webrsync
emerge --sync
eselect profile list
eselect profile set 1
# 更新系统
emerge --verbose --update --deep --newuse @world
echo 'ACCEPT_LICENSE="*"' >> /etc/portage/make.conf
echo 'MAKEOPTS="-j5"' >> /etc/portage/make.conf
echo 'VIDEO_CARDS="nvidia"' >> /etc/portage/make.conf
echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
echo "Asia/Shanghai" > /etc/timezone
emerge --config sys-libs/timezone-data
nano -w /etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GBK
zh_CN.UTF-8 UTF-8
locale-gen
eselect locale set en_US.utf8
eselect locale list
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
# 安装ZFS软件
mkdir /etc/portage/package.accept_keywords
echo "sys-fs/zfs-kmod ~amd64" >> /etc/portage/package.accept_keywords/zfs-kmod
echo "sys-fs/zfs ~amd64" >> /etc/portage/package.accept_keywords/zfs
emerge sys-fs/zfs
rc-update add zfs-import boot
rc-update add zfs-mount boot
rc-update add zfs-share default
rc-update add zfs-zed default
echo 536870912 >> /sys/module/zfs/parameters/zfs_arc_max or echo "options zfs zfs_arc_max=536870912" >> /etc/modprobe.d/zfs.conf
- 配置内核
emerge sys-apps/pciutils
emerge sys-kernel/gentoo-sources
emerge sys-kernel/genkernel
emerge vim
# 一些驱动需要先在系统上安装附加的固件才能工作。经常网络接口上会使用,特别是无线网络接口。此外,来自 AMD 、 NVidia 和 Intel 等供应商的现代视频芯片在使用开源驱动程序时,通常也需要外部固件文件。大多数固件都打包在 sys-kernel/linux-firmware 里:
emerge sys-kernel/linux-firmware
# 编译内核
cd /usr/src/linux
make menuconfig
Enable GPT partition label support if that was used previously when partitioning the disk (CONFIG_PARTITION_ADVANCED and CONFIG_EFI_PARTITION):
-*- Enable the block layer --->
Partition Types --->
[*] Advanced partition selection
[*] EFI GUID Partition support
Enable support for UEFI
Processor type and features --->
[*] EFI runtime service support
[*] EFI stub support
[*] EFI mixed-mode support
Enable support for uvesafb
Device Drivers --->
<*> Connector - unified userspace <-> kernelspace linker --->->
Graphics support --->
Frame buffer Devices --->
[*] Support for frame buffer devices --->
[*] Enable firmware EDID
<*> Userspace VESA VGA graphics support
Firmware Drivers --->
EFI (Extensible Firmware Interface) Support --->
<*> EFI Variable Support via sysfs
sys-kernel/zfs requires Zlib kernel support (module or builtin).
General Architecture Dependent Options --->
GCC plug ins --->
[ ] Randomize layout of sensitive kernel structures
Cryptographic API --->
<*> Deflate compression algorithm
Security options --->
[ ] Harden common str/mem functions against buffer overflows
Enable USB
Device Drivers --->
SCSI device support --->
## (Although SCSI will be enabled automatically when selecting USB Mass Storage,
we need to enable disk support.)
--- SCSI support type (disk, tape, CD-ROM)
<*> SCSI disk support
## (Then move back a level and go into USB support)
USB support --->
## (This is the root hub and is required for USB support.
If you'd like to compile this as a module, it will be called usbcore.)
<*> Support for Host-side USB
## (Select at least one of the HCDs. If you are unsure, picking all is fine.)
--- USB Host Controller Drivers
xHCI HCD (USB 3.0) support
EHCI HCD (USB 2.0) support
< > OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
## (Moving a little further down, we come to CDC and mass storage.)
< > USB Modem (CDC ACM) support
<*> USB Printer support
<*> USB Mass Storage support
## (If you have a USB Network Card like the RTL8150, you'll need this)
USB Network Adapters --->
<*> USB RTL8150 based ethernet device support (EXPERIMENTAL)
## (If you have a serial to USB converter like the Prolific 2303, you'll need this)
USB Serial Converter support --->
<*> USB Serial Converter support
<*> USB Prolific 2303 Single Port Serial Driver (NEW)
USB Audio
The USB Audio kernel driver must be enabled to support USB microphones, headsets and speakers to work properly. This is the case for some laptops since their microphones are connected on the USB bus.
KERNEL Enable support for SND_USB_AUDIO
Device Drivers -->
Sound card support -->
Advanced Linux Sound Architecture -->
USB sound devices -->
<*> USB Audio/MIDI driver
make && make modules_install
make install
genkernel --zfs --install initramfs
- 配置系统
vi /etc/fstab
nano -w /etc/conf.d/hostname
nano -w /etc/conf.d/net
config_eth0="dhcp"
emerge sys-apps/pcmciautils sys-kernel/linux-firmware
passwd
# 配置引导和启动 Gentoo(在使用OpenRC时)使用/etc/rc.conf配置系统的服务,启动和关闭。 打开 /etc/rc.conf并查看文件中的所有注释。 设置并根据需要进行更改。
nano -w /etc/rc.conf
# 给grub添加zfs支持
echo "sys-boot/grub:2 libzfs" >> /etc/portage/package.use
echo "sys-boot/grub:2 ~amd64" >> /etc/portage/package.accept_keywords/grub
# 安装基础的app
emerge app-admin/sysklogd
emerge sys-process/cronie
emerge app-admin/sudo
emerge net-misc/dhcpcd
emerge sys-boot/grub:2
emerge zhcon
emerge app-misc/screen
Comments