Gentoo安装详解(一) -- 安装基本系统
前期准备
启动盘(Boot media)
Gentoo Linux installation media
- Minimal installation CD
- Admin CD
- SystemRescue
Creating bootable LiveUSB drives under Windows
Rufus
Stage archives
- stage3-openrc
- stage3-systemd
远程登录
-
开启ssh服务:
rc-service sshd start
or
/etc/init.d/sshd start
-
设置密码:
passwd
以便使用securecrt、ssh client远程登录上传stage等(有时在线下载很慢,而局域网上传很快)
配置网络
网卡检测
- ifconfig 命令
- ip 命令
自动配置网络
- DHCP
root #dhcpcd eth0
net-setup
root # net-setup eth0
pppoe-setup
root # pppoe-setup
root # pppoe-start
无线网络
准备磁盘
查看是否支持uefi
root@archiso ~ # ls /sys/firmware/efi
config_table efivars fw_platform_size fw_vendor runtime runtime-map systab
fdisk分区
fdisk /dev/sda
- GPT for UEFI (-g)
/dev/sda1 : /boot 256M EFI (-t 1)
/dev/sda2 : / 100G ext4
/dev/sda3 : /home 20G ext4
/dev/sda4 : /swap 1G (-t 19)
(内存< 512 MB,分区分配2倍内存大小的空间;> 1024 MB,可以分配较少的空间甚至不需要swap 分区。) -t 82
- MBR for BIOS (-o)
/dev/sda1 : /boot 100M(32-100M) 设启动标记 -a
/dev/sda2 : / 20G
/dev/sda3 : /home 20G
/dev/sda4 : /swap 1G (内存< 512 MB,分区分配2倍内存大小的空间;> 1024 MB,可以分配较少的空间甚至不需要swap 分区。) -t 82
创建文件系统
mkfs.vfat -F 32 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3
mkswap /dev/sda4
挂载分区
mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount /dev/sda3 /mnt/gentoo/home
swapon /dev/sda4
安装基本系统
安装stage3
正确设置日期/时间
-
显示时间
date
-
手动设置
date 100313162021
如果显示的日期/时间不正确,可以使用date MMDDhhmmYYYY命令
- 自动设置
ntpd -q -g
安装stage
- 下载Stage3
cd /mnt/gentoo
links http://www.gentoo.org/main/en/mirrors.xml
选择国内速度较快的镜像,进入releases/amd64/autobuilds/目录里。你将会看到所有适合你的计算机体系结构的stage文件(它们也可能放在各个独立的子体系名称的子目录里)。选择一个,然后按D来下载。下载完以后,再按Q退出浏览器。
或使用SSH Secure Shell登录上传stage3文件
- 解压Stage3
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
配置编译选项
nano -w /mnt/gentoo/etc/portage/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
# EMERGE_DEFAULT_OPTS is set automatically by livecd-tools autoconfig during first live boot.
# This should be equal to number of processors, see "man emerge" for details.
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --jobs=4 --load-average=4"
MAKEOPTS="-j5"
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}" # 两个变量使用相同的设置
MAKEOPTS="-j5" #MAKEOPTS定义在安装软件的时候同时可以产生并行编译的数目,CPU数目加一是个不错的选择
- 查看cpu信息:
cat proc/cpuinfo
Chrooting
- 选择镜像站点:
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
- 拷贝DNS信息:
cp -L /etc/resolv.conf /mnt/gentoo/etc/
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
- 挂载必要的文件系统:
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
- 进入新的系统环境:
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
- 挂载boot分区
mount /dev/sda1 /boot
配置Portage
安装ebuild repository snapshot
fetch the latest snapshot (which is released on a daily basis) from one of Gentoo's mirrors and install it onto the system:
emerge-webrsync(fetch the latest portage snapshot)
- 可选 下载解压快照
Gentoo镜像snapshots/目录:
portage-latest.tar.bz2
tar -xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /var/db/repos/gentoo
- 可选 更新portage树:
emerge --sync (Updating the Portage tree)
or
emerge --sync --quiet
选择合适的Profile
eselect profile list
eselect profile set ×
Updating the @world set
emerge --ask --verbose --update --deep --newuse @world
配置USE
- default USE
The default USE settings are placed in themake.defaults
files - description
A full description on the available USE flags can be found on the system in/var/db/repos/gentoo/profiles/use.desc
. - currently active USE
The easiest way to check the currently active USE settings is to run emerge --info and select the line that starts with USE:
root #emerge --info | grep ^USE
USE="X acl alsa amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri ..."
设置时区
ls /usr/share/zoneinfo
echo "Asia/Shanghai" > /etc/timezone
emerge --config sys-libs/timezone-data
设置locale
nano -w /etc/locale.gen
locale-gen
eselect locale list
eselect locale set x
- 更新环境变量:
env-update && source /etc/profile
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)