安装Gentoo
目录
Gentoo 官方安装手册:amd64 handbook
备份/恢复配置脚本:AutoBackup
Gentoo 配置备份:GentooConfig
准备工作
- 准备一个 U 盘
- 下载 ubuntu 或其他发行版最新版本的 livcd/installmedia https://ubuntu.com/download/desktop
dd bs=4M if=/path/to/ubuntu.iso of=/dev/sdx status=progress oflag=sync
将 ubuntu installmedia 安装到 U 盘中- 使用 ubuntu installmedia 启动,选择 try without install,联网并打开 gentoo amd64_handbook 参考
分区
分区列表
sda1 /boot vfat >=256M #注意分区设置flags为esp sda2 / ext4,btrfs,xfs,jfs.etc remaining space
分区操作
parted -a optimal /dev/sdx # 设置gpt label (parted)mklabel gpt # 设置单位为Mib (parted)unit mib # 设置boot分区 # esp is an alias for boot on GPT (parted) mkpart primary fat32 1 257 (parted) set 1 esp on (parted) name 1 boot # 设置root分区 # For one other partition using 100% of remaining space (parted) mkpart primary btrfs 257 100% (parted) name 2 rootfs # 检查分区是否正确 (parted) print # 格式化分区 mkfs.vfat /dev/sdx1 mkfs.btrfs /dev/sdx2
安装
- 下载 stage3 并解压
# 检查并同步时间 # TODO date; ntpd -q -g # 或手动设置时间 eg:设置为2020年2月23日22点15分 # Use the MMDDhhmmYYYY syntax (Month, Day, hour, minute and Year). date 022322152020 # 挂载rootfs mkdir /mnt/gentoo mount /dev/sdx2 /mnt/gentoo # 下载stage3到/mnt/gentoo https://www.gentoo.org/downloads/ cd /mnt/gentoo; wget <PASTED_STAGE_URL> # 验证其有效性 # https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Media#Verifying_the_downloaded_files gpg --keyserver hkps://hkps.pool.sks-keyservers.net --recv-keys 0xBB572E0E2D182910 # or wget -O- https://gentoo.org/.well-known/openpgpkey/hu/wtktzo4gyuhzu8a4z5fdj3fgmr1u6tob?l=releng | gpg --import # https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage#Verifying_and_validating openssl dgst -r -sha512 stage3-amd64-<release>.tar.?(bz2|xz) openssl dgst -r -whirlpool stage3-amd64-<release>.tar.?(bz2|xz) gpg --verify stage3-amd64-<release>.tar.?(bz2|xz){.DIGESTS.asc,} # 解压stage3到/mnt/gentoo tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
- 挂载分区
# cp DNS info 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 # debian系系统需要 test -L /dev/shm && rm /dev/shm && mkdir /dev/shm mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm chmod 1777 /dev/shm mount /dev/sdx1 /boot mount .... etc # Or use init.sh script
- 进入 chroot 环境安装
chroot /mnt/gentoo /bin/bash source /etc/profile export PS1="(chroot) $PS1"
配置 gentoo
配置 make.conf
# TODO git clone git@github.com:PetrusZ/AutoBackup.git cd AutoBackup ./restore_config.sh desktop portage
Sync ebuild repos
TODO git?
emerge-websync
Choose profile
eselect profile set default/linux/amd64/17.1/desktop/systemd
配置杂项
# Timezone echo "Asia/Shanghai" > /etc/timezone emerge --config sys-libs/timezone-data # locales # Add `zh_CN ISO-8859-1` & `zh_CN.UTF-8 UTF-8` to /etc/locales.gen # And only enable `en_US.UTF-8 UTF-8` & `zh_CN.UTF-8 UTF-8` vim /etc/locale.gen locale-gen eselect locale set en_US.utf8 # reload environment env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
TODO proxy
安装/更新
emerge -avt dev-vcs/git vim ccache emerge --sync # update world前可能需要注释掉make.conf中的VIDEO_CARDS emerge -avuDN --with-bdeps=y @world dispatch-conf emerge @preserved-rebuild # 安装显卡驱动 emerge -avt nvidia-drivers
配置/安装内核
eselect kernel
, and use genkernall all
for now.
Or just install gentoo-kernel-bin
配置系统
# /etc/fstab # 详细信息可查看fstab文件中的注释和wiki https://wiki.gentoo.org/wiki/Fstab /dev/sda1 /boot vfat defaults,noatime 0 2 /dev/sda2 / btrfs noatime 0 1 /swapfile none swap defaults 0 0 # Network Use NetworkManager, it is out of box. # Use Backup4Config restore/install system configura files cd Backup4config ./restore_config.sh desktop system # Add user and set passwd passwd root # 先创建用户,然后再恢复用户配置 useradd -m -G wheel,floppy,audio,cdrom,video,docker,libvirt,usb,users,portage,wireshark <username> passwd <username> # Edit /etc/sudoers EDITOR=vim visudo ## Uncomment to allow members of group wheel to execute any command %wheel ALL=(ALL) ALL # Swapfile https://wiki.archlinux.org/index.php/swap#Swap_file fallocate -l 16G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile # TODO resume? grub? btrfs? # ssh root登陆 sudo vim /etc/ssh/sshd_config # comment `PermitRootLogin prohibit-password` # and add `PermitRootLogin yes` below # Use Backup4Config restore/install system configura files cd AutoBackup/backup_desktop ./install.sh system
配置 bootloader
# Use Backup4config to edit /etc/default/grub # bootloader使用grub:# bootloader使用grub:2 grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Gentoo grub-mkconfig -o /boot/grub/grub.cfg
User configura
su petrus # run below commands as user # Use Backup4Config restore/install user configura files cd AutoBackup ./restore_config.sh desktop user chsh -s /bin/bash <username>
Reboot
Reboot 前先检查系统:
- boot 目录是否有相应文件
- GRUB 是否正确生成配置并显示内核等文件
- fstab 是否正确无误
rm /stage3-*.tar.* umount -l /mnt/gentoo/dev{/shm,/pts,} umount -R /mnt/gentoo reboot # set hostname hostnamectl set-hostname <hostname> # set ntp & timezone timedatectl set-ntp true timedatectl set-timezone Asia/Shanghai # set keymap for virtual console localectl set-keymap personal # Use Backup4Config install vim, zsh and tmux plugin cd AutoBackup/backup_desktop ./install.sh user # Open vim and type `:PlugInstall` # Open tmux and press prefix + I (capital i, as in Install) to fetch the plugin. # 再次检查系统是否正常 # 查看wifi列表 nmcli device wifi list # 连接wifi nmcli device wifi connect <SSID> passworld <password>