Gentoo 安装记录systemd+merge-usr+kde5 2023最新

有疑问加入gentoo爱好者 qq群交流:87709706 www.gentoo.site管理团队的秘密基地

 

安装gentoo分为三个大步骤,分别是更新@word,编译内核,安装自己要用的软件/桌面

我选择的是清华源的stage3 包目录是/gentoo/releases/amd64/autobuilds/current-stage3-amd64-desktop-systemd-mergedusr/

由于我安装的是kde桌面,所以我最终选择的是stage3-amd64-desktop-systemd-mergedusr-*.tar.xz

2023年底systemd 将取消支持没有合并到/usr目录的发行版使用systemd,要用systemd请务必选择带mergedusr的stage3包

我使用的是archlinux作为安装live辅助

开始吧!

 

 

请注意archlinx由于更新速度快,其格式化的文件系统会有新的特性,如果使用arch格式化的ext4等文件系统。在gentoo安装完内核引导程序后,有可能启动时报错,用中文来说就是文件系统出错。因此,尽量使用旧版(指软件包不是最新的)的linux进行文件系统格式化操作,我个人建议使用diskgenius(win下)进行ext4的格式化操作,以下格式化命令仅做参考

mkfs.vfat -F 32 /dev/nvme0n1p1 ##efi分区

mkfs.ext4 /dev/nvme0n1p2 ##根目录分区

 

 

将stage3下载到本地,默认是下载到 /home/user/Downloads/ ##此处user是你的用户名

sudo mkdir -p /mnt/gentoo

sudo mount /dev/nvme0n1p2 /mnt/gentoo

sudo mkdir -p /mnt/gentoo/boot

sudo mount /dev/nvme0n1p1 /mnt/gentoo/boot

sudo cp /home/user/Downloads/stage3.*.tar.xz /mnt/gentoo/

确保只有自己需要的分区

cd /mnt/gentoo/

sudo -s #切换到root用户

tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner

 

 

sudo genfstab -U /mnt/gentoo >> /mnt/gentoo/etc/fstab

#使用arch aur上得到的命令,或者使用archlivecd来完成,请务必检查fstab内容,

 

 

配置make

nano -w /mnt/gentoo/etc/portage/make.conf

在末尾追加以下内容

#start#

GENTOO_MIRRORS="https://mirrors.tuna.tsinghua.edu.cn/gentoo/" #使用清华源

ACCEPT_LICENSE="*"

MAKEOPTS="-j12" #此处请根据你的cpu线程数和你的实际内存来确定,我是i9-8950hk(12线程) 32GB的memory

GRUB_PLATFORMS="efi-64" #使用amd64平台的grub进行引导

USE="-split-usr" #使用合并到/usr标记的软件

UNINSTALL_IGNORE="/bin /lib /lib64 /sbin"

VIDEO_CARDS="intel i965 iris nvidia" ##显卡支持配置

#end#

 

 

配置全局ebulid软件仓库

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

nano /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

把原来的sync-uri这一行注释

添加sync-uri = rsync://rsync.mirrors.tuna.tsinghua.edu.cn/gentoo-portage/

 

开始chroot

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

mount --bind /run /mnt/gentoo/run

mount --make-slave /mnt/gentoo/run

chroot /mnt/gentoo /bin/bash

##chroot后

source /etc/profile

export PS1="(chroot) ${PS1}"

 

更新数据库

emerge-webrsync

eselect profile list

我选的这个

[11] default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr (stable)

eselect profile set 11

 

emerge --ask app-portage/cpuid2cpuflags

cpuid2cpuflags

出现以下内容,我的机子,仅供参考

CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3

稍作修改,将以下内容添加到/etc/portage/make.conf里

CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3"

 

emerge --ask ccache aria2

mkdir -p /var/cache/ccache

chown root:portage /var/cache/ccache -R

chmod 2775 /var/cache/ccache -R

在make.conf添加以下内容

#start#

FEATURES="ccache -test"

CCACHE_DIR="/var/cache/ccache"

FETCHCOMMAND="/usr/bin/aria2c -d \${DISTDIR} -o \${FILE} --allow-overwrite=true --max-tries=5 --max-file-not-found=2 --max-concurrent-downloads=5 --connect-timeout=5 --timeout=5 --split=5 --min-split-size=2M --lowest-speed-limit=20K --max-connection-per-server=9 --uri-selector=feedback \${URI}"

RESUMECOMMAND="${FETCHCOMMAND}"

#end#

 

更新@word

emerge --ask --verbose --update --deep --newuse @world

etc-update --automode -3

 

设置时区

ls /usr/share/zoneinfo

ln -sf ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime

echo "en_US.UTF-8 UTF-8

zh_CN.UTF-8 UTF-8" >> /etc/locale.gen

locale-gen

 

安装内核源码和固件微代码

emerge --ask sys-kernel/linux-firmware sys-kernel/gentoo-sources sys-kernel/genkernel

eselect kernel list

eselect kernel set 1 ##默认内核啥也没有,直接设置1 刚刚下载的内核源码

cd /usr/src/linux

genkernel all ##使用genkernel锁定内核配置时间,后续可自行优化内核

 

禁用nouveau

mkdir /etc/modprobe.d/

touch /etc/modprobe.d/blacklist.conf

nano /etc/modprobe.d/blacklist.conf

#加入这些begin

blacklist nouveau

blacklist lbm-nouveau

options nouveau modeset=0

#加入这些end

 

安装显卡驱动

emerge -av x11-base/xorg-server x11-apps/xrandr x11-base/xorg-drivers media-libs/mesa x11-drivers/nvidia-drivers

 

 

 

emerge --ask sys-boot/grub sys-boot/os-prober sys-fs/ntfs3g sys-fs/btrfs-progs

nano /etc/default/grub

添加如下行,开启os探测

#srart#

GRUB_DISABLE_OS_PROBER=false

#end#

 

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Gentoo

grub-mkconfig -o /boot/grub/grub.cfg

 

 

安装kde桌面

emerge sudo layman sys-apps/dbus kde-plasma/plasma-meta kde-apps/konsole kde-apps/dolphin

systemctl enable sddm

安装networkmanager

emerge networkmanager sys-apps/mlocate

systemctl enable NetworkManager

安装键盘鼠标驱动

emerge x11-drivers/xf86-input-void x11-drivers/xf86-input-evdev

 

安装蓝牙驱动

emerge net-wireless/bluez

systemctl enable bluetooth

 

声卡

emerge media-sound/pulseaudio media-libs/pulseaudio-qt kde-apps/kmix

 

中文字体

emerge wqy-zenhei ##可以自行添加字体,我选择的是通用型

 

系统监测辅助

emerge --ask acpi

emerge --ask thermald

emerge --ask cpupower

 

 

passwd ##设定root密码

useradd --create-home semes #semes是我的用户名

passwd semes ##设定用户密码

usermod -aG wheel,users semes #添加用户到组

 

visudo

找到root ALL=(ALL:ALL) ALL

在下面添加

semes ALL=(ALL:ALL) ALL

取消 # %wheel ALL=(ALL:ALL) ALL #让wheel的用户可使用sudo,双倍保险

 

系统安装完成,可以重启了

 

 

 

 

 

配置nvidia

nano /etc/modules-load.d/nvidia.conf

#加入这些begin

nvidia

#加入这些end

systemctl start systemd-modules-load.service

 

nano /etc/modprobe.d/nvidia-drm.conf

#加入这些begin

options nvidia-drm modeset=1

#加入这些end

 

nano /etc/X11/xorg.conf

##############加入这些begin##############################

# nvidia-xconfig: X configuration file generated by nvidia-xconfig

 

 

Section "ServerLayout"

Identifier "Layout0"

Screen 0 "Screen0"

Inactive "InactiveDevice1"

Option "AllowNVIDIAGPUScreens" "true"

Option "AllowPRIMEDisplayOffloadSink" "true"

EndSection

 

Section "Files"

EndSection

 

Section "InputClass"

Identifier "libinput pointer catchall"

Driver "libinput"

MatchIsPointer "on"

MatchDevicePath "/dev/input/event*"

Option "AccelProfile" "flat" #禁用鼠标加速,玩游戏必备

Option "AccelSpeed" "0"

EndSection

 

Section "InputClass"

Identifier "libinput keyboard catchall"

Driver "libinput"

MatchIsKeyboard "on"

MatchDevicePath "/dev/input/event*"

EndSection

 

Section "InputClass"

Identifier "libinput touchpad catchall"

Driver "libinput"

MatchIsTouchpad "on"

MatchDevicePath "/dev/input/event*"

option "Tapping" "True"

option "TappingDrag" "True"

option "NaturalScrolling" "True"

EndSection

 

Section "Module"

Load "fb"

Load "shadow"

Load "exa"

Load "glamoregl"

Load "glx"

Load "dri3"

EndSection

 

Section "Monitor"

Identifier "Monitor0"

VendorName "Unknown"

ModelName "Unknown"

Option "DPMS"

EndSection

 

Section "Device"

Identifier "Device0"

Driver "nvidia"

VendorName "NVIDIA Corporation"

BusID "PCI:1:0:0"

Option "Accel" "true"

Option "RenderAccel" "true"

Option "NoFlip" "false"

Option "SWCursor" "false"

Option "HWCursor" "true"

Option "DamageEvents" "true"

Option "ModeDebug" "false"

Option "AllowSHMPixmaps" "false"

Option "SidebandSocketPath" "/tmp"

Option "UseSysmemPixmapAccel" "true"

Option "MultisampleCompatibility" "true"

Option "AllowEmptyInitialConfiguration" "true"

Option "ForceCompositionPipeline" "true"

Option "ForceFullCompositionPipeline" "true"

Option "AllowIndirectGLXProtocol" "false"

Option "TripleBuffer" "true" #

Option "Stereo" "0"

Option "BaseMosaic" "false"

Option "MultiGPU" "false"

Option "SLI" "false"

Option "PrimaryGPU" "yes"

EndSection

 

Section "Device"

Identifier "InactiveDevice1"

Driver "modesetting"

VendorName "Unknown"

Option "AccelMethod" "glamor"

Option "DRI" "3"

Option "TearFree" "true"

EndSection

 

Section "Screen"

Identifier "Screen0"

Device "Device0"

Monitor "Monitor0"

DefaultDepth 24

SubSection "Display"

Depth 24

EndSubSection

EndSection

 

Section "Screen"

Identifier "Screen1"

Device "InactiveDevice1"

EndSection

 

Section "ServerFlags"

Option "DontVTSwitch" "True"

Option "DontZap" "True"

EndSection

#############加入这些end###############

 

 

nano /usr/share/sddm/scripts/Xsetup

#加入这些begin

xrandr --setprovideroutputsource modesetting NVIDIA-0 #加入这一行

xrandr --auto #加入这一行

#加入这些end

chmod u+s /usr/bin/xinit

修改grub启动参数

nano /etc/default/grub

找到

#GRUB_CMDLINE_LINUX=""

改为

GRUB_CMDLINE_LINUX="nvidia-drm.modeset=1"

然后更新grub引导

grub-mkconfig -o /boot/grub/grub.cfg

 

重新启动

登陆用户

 

安装中文输入法

sudo nano /etc/environment

#start#

GTK_IM_MODULE=fcitx

QT_IM_MODULE=fcitx

XMODIFIERS=@im=fcitx

SDL_IM_MODULE=fcitx

#end#

 

sudo emerge --ask app-i18n/fcitx emerge --ask app-i18n/fcitx-rime app-i18n/kcm-fcitx app-i18n/fcitx-configtool

 

给日常用户写启动文件

nano ~/.xprofile

#start#

eval "$(dbus-launch --sh-syntax --exit-with-session)"

export XMODIFIERS="@im=fcitx"

export QT_IM_MODULE=fcitx

export GTK_IM_MODULE=fcitx

#end#

 

省电需要

换intel_GPU就改xorg.conf

 

把/etc/X11/xorg.conf的内容修改为:

##############################################################

Section "ServerLayout"

Identifier "layout"

Screen 0 "iGPU"

Option "AllowNVIDIAGPUScreens"

EndSection

 

Section "Device"

Identifier "iGPU"

Driver "modesetting"

BusID "PCI:0:2:0"

EndSection

 

Section "Screen"

Identifier "iGPU"

Device "iGPU"

EndSection

 

Section "Device"

Identifier "nvidia"

Driver "nvidia"

BusID "PCI:1:0:0"

EndSection

###################################################################

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值