# mkdir /mnt/gentoo/usr/portage/distfiles
--------------------------------------------------------------------------------
七、准备和配置编译
--------------------------------------------------------------------------------
# nano -w /mnt/gentoo/etc/make.conf
--------------------------------------------------------------------------------
//如果下载的stage和你的机器比较匹配,那几乎不需要改动什么的。
其他参数可以参考 /mnt/gentoo/etc/make.conf.example
选择比较快的镜像站点加入make.conf
--------------------------------------------------------------------------------
# mirrorselect -a -s4 -o >> /mnt/gentoo/etc/make.conf
--------------------------------------------------------------------------------
Copy DNS配置
--------------------------------------------------------------------------------
# cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
--------------------------------------------------------------------------------
Chroot 进入新的编译环境
一、chroot
--------------------------------------------------------------------------------
# chroot /mnt/gentoo /bin/bash
# env-update
# source /etc/profile
--------------------------------------------------------------------------------
Note : 如果 env-update 提示出错,看一下 /etc/make.conf 是不是有错,刚才, mirrorselect 会加入镜像站点地址,但是那一行上面会多出一行多余的提示信息,注释掉或删掉都可以。
二、更新 Portage
--------------------------------------------------------------------------------
# emerge sync
{如果不能完成,就用下面的命令
# emerge-webrsync }
--------------------------------------------------------------------------------
三、USE设置
--------------------------------------------------------------------------------
# nano -w /etc/make.conf
--------------------------------------------------------------------------------
加入:
USE="-gtk -gnome qt kde alsa"
四、下载必须的源码
--------------------------------------------------------------------------------
# cd /usr/portage
# scripts/bootstrap.sh -f
--------------------------------------------------------------------------------
编译它
--------------------------------------------------------------------------------
# scripts/bootstrap.sh
--------------------------------------------------------------------------------
如果有改变过 预置的环境变量,那么需要用
--------------------------------------------------------------------------------
# source /etc/profile
--------------------------------------------------------------------------------
更新一下。
续:
五、从stage2 到 stage3 (如果你是从stage3 开始的就应该可以不做了)
看看你将需要做的内容:
--------------------------------------------------------------------------------
# emerge --pretend system | less
--------------------------------------------------------------------------------
获取源码:
--------------------------------------------------------------------------------
# emerge --fetchonly system // 上周做到这里了。
--------------------------------------------------------------------------------
编译系统:
--------------------------------------------------------------------------------
# emerge system
--------------------------------------------------------------------------------
顺利的做完了这些,我们就可以编译内核了。
编译内核
一、设置时区
--------------------------------------------------------------------------------
# cd /etc
# rm localtime
# ln -sf /usr/share/zoneinfo/Asia/Shanghai localtime
# nano -w /etc/rc.conf
--------------------------------------------------------------------------------
修改使 CLOCK="PRC"
二、下载内核的源码包
使用 2.4.X 内核
--------------------------------------------------------------------------------
# emerge gentoo-sources
--------------------------------------------------------------------------------
使用 2.6.X 内核
--------------------------------------------------------------------------------
# emerge gentoo-dev-sources
--------------------------------------------------------------------------------
三、修改内核源码目录链接
--------------------------------------------------------------------------------
# ls -l /usr/src/linux
在这里你可以看到你下载的源码的目录
# rm /usr/src/linux && ln -s /usr/src/linux-2.6.7-gentoo-r8 /usr/src/linux
--------------------------------------------------------------------------------
四、配置内核编译选项
--------------------------------------------------------------------------------
# cd /usr/src/linux
# make menuconfig
--------------------------------------------------------------------------------
(因为是在VMware 上装,所以,我们只要保留默认的选项,再加上对scsi 、AMDpcnet32 、 ext2 的支持就可以了,其他的如果认为用的上也可以编译到内核里。
五、 编译内核:
--------------------------------------------------------------------------------
(For 2.4 kernel)
# make dep && make bzImage modules modules_install
(For 2.6 kernel)
# make && make modules_install
--------------------------------------------------------------------------------
copy 编译好的内核到 /boot
--------------------------------------------------------------------------------
# cp arch/i386/boot/bzImage /boot/kernel-2.4.25-gentoo
# cp System.map /boot/System.map-2.4.25-gentoo
--------------------------------------------------------------------------------
其实,我们可以用Gentoo 提供的 genkernel 来编译内核。
--------------------------------------------------------------------------------
# emerge genkernel
# genkernel all
--------------------------------------------------------------------------------
六、其它
修改启动选项
--------------------------------------------------------------------------------
#nano -w /etc/fstab
/dev/hda10 / ext3 noauto,noatime 1 1
/dev/hda9 none swap sw 0 0
--------------------------------------------------------------------------------
主机名
--------------------------------------------------------------------------------
#echo myhost > /etc/hostname
#echo mydomain > /etc/dnsdomainname
#echo myip myhost.mydomain myhost >> /etc/hosts
#rc-update add domainname default
--------------------------------------------------------------------------------
网络(修改ip地址)
--------------------------------------------------------------------------------
