注意
本人使用
install-amd64-minimal-20220123T170538Z.iso
stage3-amd64-desktop-systemd-20220116T170534Z.tar.xz
配置信息
CPU: Intel i5-8300H (8) @ 4.000GHz
GPU: NVIDIA GeForce GTX 1060 Mobile 6GB
Host: OMEN by HP Laptop 15-dc0xxx
安装目标
amd64/UEFI/systemd/gnome/gentoo 达到日常使用目的
格式化磁盘
fdisk /dev/nvme0n1
g
n
1
+256M
n
2
+16G
n
3
全选
//形如
/dev/nvme0n1p1 2048 526335 524288 256M EFI 系统
/dev/nvme0n1p2 526336 34080767 33554432 16G Linux swap
/dev/nvme0n1p3 34080768 250069646 215988879 103G Linux 文件系统
//格式化
mkfs.ext4 /dev/nvme0n1p3
mkfs.vfat /dev/nvme0n1p1
mkswap /dev/nvme0n1p2
swapon /dev/nvme0n1p2
//挂载
mount /dev/nvme0n1p3 /mnt/gentoo
连网
net-setup
SSID 你的手机热点/WIFI名称,可以用手机usb开网络共享连入,更加方便
密码
同步NTC时间 必要!
ntpd -q -g
下载stage3
links mirrors.tuna.tsinghua.edu.cn
解压stage3
cd /mnt/gentoo
tar xpvf stage3-*.tar.bz2 --xattrs-include='*.*' --numeric-owner
配置编译选项
nano -w /mnt/gentoo/etc/portage/make.conf
//八个核心并行编译 看你自己核心数量
MAKEOPTS=“-j8”
//接受所有软件许可证
ACCEPT_LICENSE="*"
//只安装AMD64稳定分支软件
ACCEPT_KEYWORDS="amd64"
同步镜像
//镜像选择
mirrorselect -i -o >> /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
//需要编辑
vi /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
sync-uri = rsync://rsyncl.cn.gentoo.org/gentoo-portage
复制DNS信息
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
挂载必要的文件系统
root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
root #mount --bind /run /mnt/gentoo/run
root #mount --make-slave /mnt/gentoo/run
进入新环境
root #chroot /mnt/gentoo /bin/bash
root #source /etc/profile
root #export PS1="(chroot) ${PS1}"
挂载
mount /dev/nvme0n1p1 /boot
选择正确的配置文件
root #eselect profile list
Available profile symlink targets:
[1] default/linux/amd64/17.1 *
[2] default/linux/amd64/17.1/desktop
[3] default/linux/amd64/17.1/desktop/gnome
[4] default/linux/amd64/17.1/desktop/kde
选择对应配置文件
root #eselect profile set x
更新
emerge --ask --verbose --update --deep --newuse @world
安装软件
emerge --ask linux-firmware genkernel gentoo-sources networkmanager
时区
ln -sf ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime
语言
vim -w /etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GBK
zh_CN.UTF-8 UTF-8
eselect locale list
eselect locale set x
//选择 en_US UTF.8
现在重新加载环境:
env-update && source /etc/profile && export PS1=“(chroot) ${PS1}”
安装内核
//软连接
ln -s /usr/src/gentoo-linux /usr/src/linux
//复制genkernel的config文件
cp /usr/share/genkernel/arch/x86_64/generated-config /usr/src/linux/.config
cd /usr/src/linux
make menuconfig
//删除openrc 开启linux config next
//编译
make -j8 && make modules_install -j8 && make install
//生成initramfs文件
genkernel --install initramfs
内核方法2 (推荐)(自动生成initramfs)
genkernel all
fstab 文件
vim /etc/fstab
//挂载所有硬盘,形如这样即可
//注意 末尾标识符 /采用1 其他用2
/dev/sda1 /boot ext2 defaults,noatime 0 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext4 noatime 0 1
网络
emerge --ask net-misc/dhcpcd
systemctl enable --now dhcpcd
systemd-networkd系统守护进程管理网络配置
要配置systemd-networkd,在/etc/systemd/network路径下创建一个文件:
/etc/systemd/network/50-dhcp.network
[Match]
Name=en*
[Network]
DHCP=yes
root #systemctl enable systemd-networkd.service
root #systemctl start systemd-networkd.service
systemd-networkd resolv.conf默认不会自动更新,要systemd管理DNS设置,替换resolv.conf为一个符号连接并启动到systemd-resolved。
root #ln -snf /run/systemd/resolve/resolv.conf /etc/resolv.conf
root #systemctl enable systemd-resolved.service
root #systemctl start systemd-resolved.service
systemctl enable --now NerworkManager
更改密码
//gentoo密码有复杂性要求
passwd
grub uefi
root #echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
root #emerge --ask sys-boot/grub:2
当grub-mkconfig 被使用时, 增加 init 这一行 GRUB_CMDLINE_LINUX:
/etc/default/grubGRUB2 systemd 配置示例
//Append parameters to the linux kernel command line
GRUB_CMDLINE_LINUX="init=/lib/systemd/systemd"
grub-install --target=x86_64-efi --efi-directory=/boot
grub-mkconfig -o /boot/grub/grub.cfg
配置引导和启动
systemd-firstboot --prompt --setup-machine-id
systemctl preset-all
添加日常用户
比如,创建一个叫作larry的wheel、users和audio组的成员用户,首先作为root登录(只有root能创建用户)并运行useradd:
Login:root
Password: (输入root 密码)
root #useradd -m -G users,wheel,audio -s /bin/bash larry
root #passwd larry
Password: (输入larry的密码)
Re-enter password: (重复输入密码)
重启
root #exit
cdimage ~#cd
cdimage ~#umount -l /mnt/gentoo/dev{/shm,/pts,}
cdimage ~#umount -R /mnt/gentoo
cdimage ~#reboot
中文汉字
sudo emerge media-fonts/wqy-zenhei wqy-bitmapfont wqy-microhei wqy-unibit
sudo eselect fontconfig list #查看系统中的所有字体
sudo eselect fontconfig enable X X X #选择所有开头带有“wqy”的字体
ibus中文输入法
emerge --ask app-i18n/ibus ibus-libpinyin
vim ~/.xprofile or ~/.xinitrc
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
Use `xim` in case some apps (like Chromium) refuse to work with IBus
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim
ibus-daemon -drx
进入gnome在全局搜索ibus即可更改设定,super+空格即可切换输入法
layman第三方包
sudo emerge layman
sudo layman -L
sudo layman -a gentoo-zh
sudo layman -a deepin
sudo layman -s ALL
flatpak第三方包
Install Flatpak
To install Flatpak, enable the ~amd64 keyword for sys-apps/flatpak, acct-user/flatpak and acct-group/flatpak:
echo 'sys-apps/flatpak ~amd64\nacct-user/flatpak ~amd64\nacct-group/flatpak ~amd64\ndev-util/ostree ~amd64' >> /etc/portage/accept_keywords/flatpak
Then, install Flatpak:
emerge sys-apps/flatpak
emerge sys-apps/flatpak
Add the Flathub repository
Flathub is the best place to get Flatpak apps. To enable it, run:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Restart
To complete setup, restart your system. Now all you have to do is install some apps!
国内flatpak上海交大镜像源
sudo flatpak remote-modify flathub --url=https://mirror.sjtu.edu.cn/flathub
安装软件
//安装x服务与n卡驱动
emerge --ask gnome xorg-drivers xorg-servers nvidia-drivers
nvidia驱动
为了避免在每次启动时手动加载模块,每次系统启动时都自动完成,所以编辑 /etc/modules-load.d/video.conf 并添加 nvidia给它。
安装完成后,运行 modprobe nvidia 将内核模块加载到内存中。 如果这是升级,请先删除以前的模块。
root #lsmod | grep nvidia
root #rmmod nvidia
root #modprobe nvidia
//参考的是 gentoowiki-nvidia-drivers //给予新用户权限
gpasswd -a 你的用户名 video
//连接网络并开启dm
systemctl enable NetworkManager && gdm
systemctl enable NetworkManager && gdm
声卡问题
出现gnome无声
emerge --ask alsa-utils
gpasswd -a larry audio
使用alsamixer调试是否能播出声音:
alsamixer
在这个地方MM表示静音,使用键盘M键,改为00表示出声。
测试声音:
speaker-test -t wav -c 2
ALSA
The media-plugins/alsa-plugins must be installed with the pulseaudio USE flag enabled:
root #emerge --ask media-plugins/alsa-plugin
Root can enable PulseAudio for all users:
root #systemctl --global enable pulseaudio.service pulseaudio.socket
进入gnome 完成
nvim 配置
options
local opt = vim.opt
-- 行号
opt.relativenumber = true
opt.number = true
-- 缩进
opt.tabstop = 2
opt.shiftwidth = 2
opt.expandtab = true
opt.autoindent = true
-- 防止包裹
opt.wrap = false
-- 光标行
opt.cursorline = true
-- 启用鼠标
opt.mouse:append("a")
-- 系统剪贴板
opt.clipboard:append("unnamedplus")
-- 默认新窗口右和下
opt.splitright = true
opt.splitbelow = true
-- 搜索
opt.ignorecase = true
opt.smartcase = true
-- 外观
opt.termguicolors = true
opt.signcolumn = "yes"
vim.cmd[[colorscheme tokyonight-moon]]
core
require("plugins.plugins-setup")
require("core.options")
require("core.keymaps")
-- 插件
require("plugins.lualine")
require("plugins/nvim-tree")
require("plugins/treesitter")
require("plugins/lsp")
require("plugins/cmp")
require("plugins/comment")
require("plugins/autopairs")
require("plugins/bufferline")
require("plugins/gitsigns")
require("plugins/telescope")
alacritty
配置参考
alacritty.yml
font:
# The normal (roman) font face to use.
# Style can be specified to pick a specific face.
normal:
family: Hack Nerd
style: Light
# family: "Fira Code"
# family: "Source Code Pro"
# style: Retina
# The bold font face
bold:
family: Iosevka
style: Medium
# family: "Fira Code"
# family: "Source Code Pro"
# The italic font face
italic:
family: Iosevka
style: "Light Italic"
# style: "Light Oblique"
# family: "Fira Code"
# family: "Source Code Pro"
# style: "Medium Italic"
# Point size of the font
size: 12.0
# Background opacity
window:
opacity: 0.9
# Colors
colors:
# Tomorrow (https://github.com/aarowill/base16-alacritty/blob/master/colors/base16-tomorrow.yml)
# Default colors
primary:
#background: '0xffffff'
foreground: '0x4d4d4c'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0xffffff'
cursor: '0x4d4d4c'
# Normal colors
normal:
blackA: '0xffffff'
red: '0xc82829'
green: '0x718c00'
yellow: '0xeab700'
blue: '0x4271ae'
magenta: '0x8959a8'
cyan: '0x3e999f'
white: '0x4d4d4c'
# Bright colors
bright:
black: '0x8e908c'
red: '0xf5871f'
green: '0xe0e0e0'
yellow: '0xd6d6d6'
blue: '0x969896'
magenta: '0x282a2e'
cyan: '0xa3685a'
white: '0x1d1f21'
import:
- ~/.config/alacritty/themes/themes/blood_moon.yaml
alacritty-themes
参考文件 Imports
Clone the repository, or download the theme of your choice:
# We use Alacritty's default Linux config directory as our storage location here.
mkdir -p ~/.config/alacritty/themes
git clone https://github.com/alacritty/alacritty-theme ~/.config/alacritty/themes
material-shell
gnome-looks
sweet主题 放入 /usr/share/icon
/usr/share/themes
/usr/share/cursors
对应的位置
Nerd Font
对应地址 放入/usr/share/font
zlib
效果图
参考
Gentoo安装流程分享(step by step),第二篇之KDE Plasma桌面的安装配置2020-Gentoo双系统安装指北(2)Gentoo systemd 安装参考指南Gentoo Wiki IBusUser:Sakaki/Sakaki’s EFI Install Guide/Setting up the GNOME 3 DesktopGentoo AMD64 HandbookGentoo Wiki GNOME/GDM Gentoo Wiki NVIDIA/nvidia-drivers Gentoo Wiki LaymanGentoo Wiki PulseAudio