http://mirrors.ustc.edu.cn/gentoo/snapshots/
jlive@MacBook-Pro:gentoo $ll
total 1111352
-rw-r--r--@ 1 jlive staff 254803968 1 1 09:01 install-amd64-minimal-20151231.iso
-rw-r--r--@ 1 jlive staff 64247324 1 4 08:46 portage-latest.tar.xz
-rw-r--r--@ 1 jlive staff 249954591 1 1 09:01 stage3-amd64-20151231.tar.bz2
2.修 改/etc/ssh/sshd_config
PermitRootLogin yes
三.分区,格式化,挂载
这里创建gpt磁盘
Partition | Filesystem | Size | Description |
/dev/sda1 | (bootloader) | 2M | BIOS boot partition |
/dev/sda2 | ext2 (or vfat) | 128M | Boot partition |
/dev/sda3 | (swap) | 512M or higher | Swap partition |
/dev/sda4 | ext4 | Rest of the disk | Root partition |
parted /dev/sda mklabel gpt
parted /dev/sda unit mib
parted /dev/sda mkpart primary 1 3
parted /dev/sda name 1 grub
parted /dev/sda set 1 bios_grub on
parted /dev/sda mkpart primary 3 131
parted /dev/sda name 2 boot
parted /dev/sda mkpart primary 131 643
parted /dev/sda
parted /dev/sda set 2 boot on
jlive ~ # parted /dev/sda print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1049kB 3146kB 2097kB grub bios_grub
2 3146kB 131MB 128MB xfs boot 启动, esp
3 131MB 643MB 512MB linux-swap(v1) swap
4 643MB 42.9GB 42.3GB xfs rootfs
mkfs.ext4 -T small /dev/sda1
mkfs.xfs /dev/sda2
mkfs.xfs /dev/sda4
mkswap /dev/sda3
swapon /dev/sda3
3.挂载
mkdir /mnt/gentoo
mount /dev/sda4 /mnt/gentoo/
mkdir -p /mnt/gentoo/boot
mount /dev/sda2 /mnt/gentoo/boot
四.安装stage
1.解压stage
scp stage3-amd64-20150820.tar.bz2 root@192.168.130.140:/root
2.修改CFLAGS和CXXFLAGS
样例:/mnt/gentoo/usr/share/portage/config/make.conf.example
sed -i '/^CFLAGS/c CFLAGS="-march=native -O2 -pipe"' /mnt/gentoo/etc/portage/make.conf
sed -i '/^CXXFLAGS/a MAKEOPTS="-j4"' /mnt/gentoo/etc/portage/make.conf
五.安装gentoo base system
1.设置source code站点和rsync站点
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
2.配置DNS
cp /etc/resolv.conf /mnt/gentoo/etc/
3.挂载必需的文件系统
mount -t 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/
注意:--make-rslave参数是支持systemd必需的
五.配置portage
1.解压portage
scp portage-latest.tar.xz root@192.168.130.140:/root
2.chroot到/mnt/gentoo
chroot /mnt/gentoo/ /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
3.配置USE变量
/usr/portage/profiles/use.desc
可以先保持默认
4.配置时区
ls /usr/share/zoneinfo/
echo "Asia/Shanghai" >/etc/timezone
emerge --config sys-libs/timezone-data
或者
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
5.配置语言
所有支持的语言/usr/share/i18n/SUPPORTED
cat >> /etc/locale.gen <<HERE
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_CN.GBK GBK
zh_CN.UTF-8 UTF-8
zh_CN GB2312
zh_HK.UTF-8 UTF-8
zh_HK BIG5-HKSCS
zh_SG.UTF-8 UTF-8
zh_SG.GBK GBK
zh_SG GB2312
zh_TW.EUC-TW EUC-TW
zh_TW.UTF-8 UTF-8
zh_TW BIG5
HERE
locale-gen
jlive ~ # locale-gen
* Generating 14 locales (this might take a while) with 1 jobs
* ( 1/14) Generating en_US.ISO-8859-1 ... [ ok ]
* ( 2/14) Generating en_US.UTF-8 ... [ ok ]
* ( 3/14) Generating zh_CN.GB18030 ... [ ok ]
* ( 4/14) Generating zh_CN.GB2312 ... [ ok ]
* ( 5/14) Generating zh_CN.GBK ... [ ok ]
* ( 6/14) Generating zh_CN.UTF-8 ... [ ok ]
* ( 7/14) Generating zh_HK.BIG5-HKSCS ... [ ok ]
* ( 8/14) Generating zh_HK.UTF-8 ... [ ok ]
* ( 9/14) Generating zh_SG.GB2312 ... [ ok ]
* (10/14) Generating zh_SG.GBK ... [ ok ]
* (11/14) Generating zh_SG.UTF-8 ... [ ok ]
* (12/14) Generating zh_TW.BIG5 ... [ ok ]
* (13/14) Generating zh_TW.EUC-TW ... [ ok ]
* (14/14) Generating zh_TW.UTF-8 ... [ ok ]
* Generation complete
eselect locale list
env-update && source /etc/profile
六.配置Linux Kernel
A.安装内核源码
emerge sys-kernel/gentoo-sources
B.编译内核及initramfs
方式一:源码编译
1.编译内核
cd /usr/src/linux
make menuconfig
make -j4 && make -j4 modules_install && make -j4 install
mkdir -p /boot/efi/boot
cp /boot/vmlinuz-* /boot/efi/boot/bootx64.efi
2.编译
initramfsemerge genkernel
genkernel --install initramfs
genkernel --lvm --mdadm --install initramfs
livecd / # ls /boot/
initramfs-genkernel-x86_64-4.1.12-gentoo System.map-genkernel-x86_64-4.1.12-gentoo
kernel-genkernel-x86_64-4.1.12-gentoo
emerge sys-kernel/linux-firmware
提示:可以把vim(emerge vim)先安装上,后面很多需要修改配置文件的地方,当然,不介意nano的跳过
七./etc/fstab
https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/System
/dev/sda2 /boot xfs defaults,noatime 0 2
/dev/sda3 none swap sw 0 0
/dev/sda4 / xfs noatime 0 1
八.网络
参考/usr/share/doc/netifrc-*/net.example.bz2
1.主机名/etc/conf.d/hostname
2.域名/etc/conf.d/net
nis_domain_eno16777736="example.com"
3.网络/etc/conf.d/net
emerge --noreplace net-misc/netifrc
vim /etc/conf.d/net
config_eno16777736="192.168.130.140 netmask 255.255.255.0 brd 192.168.130.255"
routes_eno16777736="default via 192.168.130.2"
dns_servers_eno16777736="114.114.114.114 8.8.8.8"
动态获取只需修改config_eno16777736="dhcp"
添加网络开机自启动
ln -s /etc/init.d/net.lo /etc/init.d/net.eno16777736
rc-update add net.eno16777736 default
4.hosts表/etc/hosts
emerge app-admin/{sysklogd,logrotate}
rc-update add sysklogd default
2.Cron daemon
emerge sys-process/cronie
rc-update add cronie default
crontab /etc/crontab
3.File indexing
emerge sys-apps/mlocate
4.Sshd
rc-update add sshd default
#serial console
sed -i '/s0/s/^#//' /etc/inittab
sed -i '/s1/s/^#//' /etc/inittab
5.Filesystem
Filesystem | Package |
Ext2, 3, and 4 | |
XFS | |
ReiserFS | |
JFS | |
VFAT (FAT32, ...) | |
Btrfs |
emerge sys-fs/{e2fsprogs,xfsprogs,dosfstools}
6.Networking Tools
emerge dhcpcd ppp
十一.Bootloader
https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader
emerge grub
grub2-install /dev/sda
grub2-mkconfig -o /boot/grub/grub.cfg
十二.用户
passwd root
注意:请修改chroot下的root密码
十三.额外软件包
emerge sys-block/parted app-misc/screen app-portage/mirrorselect
最后退出chroot环境后,重启
exit
umount -a
reboot
jlive ~ # whoami
root
jlive ~ # uname -a
Linux jlive 4.1.12-gentoo #1 SMP Wed Jan 6 07:00:38 CST 2016 x86_64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz GenuineIntel GNU/Linux
jlive ~ # screenfetch
-/oyddmdhs+:.
-odNMMMMMMMMNNmhy+-` root@jlive
-yNMMMMMMMMMMMNNNmmdhy+- OS: Gentoo 2.2
`omMMMMMMMMMMMMNmdmmmmddhhy/` Kernel: x86_64 Linux 4.1.12-gentoo
omMMMMMMMMMMMNhhyyyohmdddhhhdo` Uptime: 53m
.ydMMMMMMMMMMdhs++so/smdddhhhhdm+` Packages: 295
oyhdmNMMMMMMMNdyooydmddddhhhhyhNd. Shell: bash
:oyhhdNNMMMMMMMNNNmmdddhhhhhyymMh CPU: Intel Core i7-4870HQ CPU @ 2.50GHz
.:+sydNMMMMMNNNmmmdddhhhhhhmMmy RAM: 822MB / 7957MB
/mMMMMMMNNNmmmdddhhhhhmMNhs:
`oNMMMMMMMNNNmmmddddhhdmMNhs+`
`sNMMMMMMMMNNNmmmdddddmNMmhs/.
/NMMMMMMMMNNNNmmmdddmNMNdso:`
+MMMMMMMNNNNNmmmmdmNMNdso/-
MNNNNNNNmmmmmNNMmhs+/-`
/hMMNNNNNNNNMNdhs++/-`
`/ohdmmddhys+++/:.`
`-//:--.