本文最后更新于:2023年3月18日 上午
1 准备工作 1.1 下载
下载最小化安装镜像 , 名称为: install-amd64-minimal-{日期}.iso
下载合适的stage3 ,以日期为路径: 20220703T170542Z/stage3-amd64-desktop-systemd-20220703T170542Z.tar.xz
1.2 网络 基操忽略
1.3 分区挂载 基操忽略
1.4 ssh连接最小化安装系统 编辑 sshd
服务配置文件 /etc/ssh/sshd_config
, 重启服务 rc-server sshd restart
1 2 PermitRootLogin yes PasswordAuthentication yes
2 安装 2.1 解压基本系统 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 livecd ~ /dev/sdb: UUID="e09609d8-0b90-4f34-aad1-8e5b37495f52" BLOCK_SIZE="4096" TYPE="ext4" /dev/sr0: BLOCK_SIZE="2048" UUID="2022-07-03-19-01-40-00" LABEL="Gentoo amd64 20220703T170542Z" TYPE="iso9660" PTUUID="5e426e6b" PTTYPE="dos" loop0: TYPE="squashfs" /dev/sda2: UUID="14077ead-3683-4354-95eb-a106c52350e9" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="4af31142-0ead-0644-b34c-c01b7c0944e1" /dev/sda1: UUID="831A-6EDD" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="733a54ad-b3d7-3842-8cc8-21b15d29e82d" livecd ~ livecd ~ livecd ~ livecd ~ livecd /mnt/gentoo boot lost+found livecd /mnt/gentoo --2022-07-05 08:09:54-- https://mirrors.bfsu.edu.cn/gentoo/releases/amd64/autobuilds/20220703T170542Z/stage3-amd64-desktop-systemd-20220703T170542Z.tar.xz Resolving mirrors.bfsu.edu.cn... 39.155.141.16, 2001:da8:20f:1003::fe55:2840 Connecting to mirrors.bfsu.edu.cn|39.155.141.16|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 516402028 (492M) [application/octet-stream] Saving to: ‘stage3-amd64-desktop-systemd-20220703T170542Z.tar.xz’ stage3-amd64-desktop-systemd- 100%[=================================================>] 492.48M 11.3MB/s in 46s 2022-07-05 08:10:40 (10.6 MB/s) - ‘stage3-amd64-desktop-systemd-20220703T170542Z.tar.xz’ saved [516402028/516402028] livecd /mnt/gentoo ……
2.2 镜像源与chroot 配置一个速度较快的镜像源服务器地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 mirrorselect -i -o >>/mnt/gentoo/etc/portage/make.conf echo 'GENTOO_MIRRORS="https://mirrors.tuna.tsinghua.edu.cn/gentoo"' >>/mnt/gentoo/etc/portage/make.confcp -L /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 --make-rslave /mnt/gentoo/sys mount --make-rslave /mnt/gentoo/devchroot /mnt/gentoo . /etc/profile PS1=(chroot )$PS1
2.3 portage仓库 1 2 3 4 emerge-webrsync emerge --ask app-editors/vim
2.4 profile选择 1 2 3 (chroot )livecd / (chroot )livecd / (chroot )livecd /
2.5 安装内核、固件
2.6 配置引导 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (chroot )livecd / (chroot )livecd / Installing for x86_64-efi platform. Installation finished. No error reported. (chroot )livecd / Installing for x86_64-efi platform. Installation finished. No error reported. (chroot )livecd / Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.15.48-gentoo-dist Found initrd image: /boot/initramfs-5.15.48-gentoo-dist.img Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. Adding boot menu entry for UEFI Firmware Settings ...done
2.7 时区、字符集配置 1 2 3 4 5 6 7 8 9 10 11 echo 'Asia/Shanghai' > /etc/timezonerm /etc/localtime emerge --config sys-libs/timezone-data vim /etc/locale.gen locale-gendd if =/dev/zero of=/swapfile bs=1M count=8192 status=progresschmod 600 /swapfile mkswap /swapfile swapon /swapfileecho "/swapfile none swap defaults 0 0" >> /etc/fstab
2.8 virtualbox 虚拟机配置 1 2 3 4 5 6 7 8 9 10 useradd -m -g wheel -G usb,users ,audio -s /bin/bash -N miloo gpasswd -a miloo vboxguest gpasswd -a miloo vboxsf emerge --ask app-emulation/virtualbox-guest-additions systemctl enable --now virtualbox-guest-additions
3 USE 3.1 make.conf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 COMMON_FLAGS="-march=native -O2 -pipe" CFLAGS="${COMMON_FLAGS} " CXXFLAGS="${COMMON_FLAGS} " FCFLAGS="${COMMON_FLAGS} " FFLAGS="${COMMON_FLAGS} " MAKEOPTS="-j25" PORTDIR="/var/db/repos/gentoo" DISTDIR="/var/cache/distfiles" PKGDIR="/var/cache/binpkgs" LC_MESSAGES=C GENTOO_MIRRORS="https://mirrors.ustc.edu.cn/gentoo/" ACCEPT_LICENSE="*" ACCEPT_KEYWORDS="amd64" AUTO_CLEAN="yes" 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} " FEATURES="ccache -test" CCACHE_DIR="/var/cache/ccache" GRUB_PLATFORMS="efi-64" ABI_X86="64" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" VIDEO_CARDS="amdgpu radeonsi vmware" L10N="en-US zh-CN en zh" LINGUAS="en-US zh-CN en zh" SYSME="-test -doc systemd" GNOME="-kde -games -help -extras X gtk gnome" USE="${SYSME} ${GNOME} "
3.2 USE 个人 USE
使用说明:
/etc/portage/make.conf
仅添加必要 flag
且尽量仅添加排除项。1 2 3 SYSME="-test -doc systemd" GNOME="-kde -games -help -extras X gtk gnome" USE="${SYSME} ${GNOME} "
/etc/portage/package.accept_keywords
文件夹中创建文件,添加需要开启 ~amd
(测试) 属性的包1 app-office/wps-office ~*
/etc/portage/package.use
文件夹中创建文件,添加与 /etc/portage/make.conf
中 USE
相悖或者仅对该包生效的 flag
1 2 3 app-emulation/qemu spice QEMU_SOFTMMU_TARGETS: x86_64 QEMU_USER_TARGETS: x86_64 net-dns/dnsmasq script net-misc/spice-gtk usbredir
4.1 包管理 4.1.1 app-portage/eix 1 2 3 app-portage/eix app-portage/gentoolkit app-portage/layman
4.2 文件系统 4.2.1 sys-fs/lvm2
4.2.2 ntfs
4.3 DE 4.3.1 gnome
一定要有swap分区,否则编译不会通过 make.conf 中 MAKEOPTS=”-j4” 此条不存在编译也会失败
1 2 3 gnome-base/gnome gnome-base/gconf gnome-extra/gnome-tweaks
4.4 vitual 4.4.1 virtualbox 1 2 3 4 5 app-emulation/virtualbox app-emulation/virtualbox-additions app-emulation/virtualbox-extpack-oracle app-emulation/virtualbox-modules app-emulation/virtualbox-guest-additions
4.4.2 kvm 1 2 3 4 app-emulation/qemu app-emulation/libvirt app-emulation/virt-manager net-misc/bridge-utils
1 2 3 4 usermod -a -G libvirt miloo usermod -a -G kvm miloo systemctl enable libvirtd systemctl enable virtlogd-admin.socket
5 系统迁移 5.1 权限备份与恢复 1 2 getfacl -R ./ > acl.txt setfacl --restore=acl.txt
5.2 用户组 1 用户id =1001(miloo) 组id =100(users ) 组=100(users ),10(wheel),11(floppy),18(audio),19(cdrom),27(video),85(usb),78(kvm),272(plugdev),172(pulse-access),304(vboxusers),79(libvirt)