不求最好,但求最快,快速安装配置Gentoo Linux,自己记录下,省得日后又重新图破,结合Gentoo手册运行,相当顺利,只需解决少量的循环依赖。
第一部分 准备安装
1、官网下载livecd镜像和stage包;
install-amd64-minimal-20120614.iso
stage3-amd64-20120614.tar.bz2
2、使用livecd启动主机;
3、使用net-setup eth0配置网络;
4、passwd root为根用户设置密码,以便远程登录操作;
5、/etc/init.d/sshd start启动ssh服务器;
6、至此可以远程操作配置该主机了;
第二部分 磁盘分区和格式化
7、fdisk /dev/sda给硬盘分区,其它类型的硬盘应该类似;
启动分区用a设置,t设置交换分区类型,w保存最后的分区结果
操作根据提示进行,创建结果如下
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux
/dev/sda2 1050624 5244927 2097152 82 Linux swap / Solaris
/dev/sda3 5244928 41943039 18349056 83 Linux
8、格式化磁盘和启用交换分区;
mkfs.ext2 /dev/sda1
mkfs.ext3 /dev/sda3
mkswap /dev/sda2
swapon /dev/sda2
9、挂接分区
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
第三部分 安装stage包
10、ntpdate xxx更新时间,xxx为时间服务器;
11、将sage包拷贝到/mnt/gentoo目录下,执行解压缩命令;
tar xvjpf stage3-*.tar.bz2
第四部分 编译准备
12、配置编译选项;
nano -w /mnt/gentoo/etc/make.conf
设置处理器类型和追加make选项:
CFLAGS="-march=core2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
USE="mmx sse sse2"
MAKEOPTS="-j2"
保存并退出
13、刷新镜像服务器列表mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf;
14、拷贝DNS配置cp -L /etc/resolv.conf /mnt/gentoo/etc/;
15、挂在proc和dev文件系统;
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
16、切换环境变量;
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1"
17、配置portage;
emerge --sync或emerge --sync --quiet
18、显示配置信息;
eselect profile list,可用eselect profile set 2之类的命令切换
19、设置USE变量
less /usr/portage/profiles/use.desc
(You can scroll using your arrow keys, exit by pressing 'q')
nano -w /etc/make.conf
USE="-x lapack" 这里去掉笨重的x,加上lapack科学计算库
20、设置时区
ls /usr/share/zoneinfo
;cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime
cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime
;echo "Europe/Brussels" > /etc/timezone
echo "Asia/Chongqing" > /etc/timezone
这里根据自己的时区设置
21、安装内核源码
emerge gentoo-sources
ls -l /usr/src/linux
22、配置内核
cd /usr/src/linux
make menuconfig
把重要的几项配置起来
Selecting processor type and features
Enabling devtmpfs support
Selecting necessary file systems
Activating SMP support
Activating USB Support for Input Devices
23、编译和安装内核
make && make modules_install
cp arch/x86_64/boot/bzImage /boot/kernel-2.6.34-gentoo-r1
版本根据实际情况设置
24、设置文件系统配置
nano -w /etc/fstab
如
/dev/sda1 /boot ext2 defaults,noatime 1 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext3 noatime 0 1
/dev/cdrom /mnt/cdrom auto noauto,user 0 0
25、配置网络
nano -w /etc/conf.d/hostname
hostname="xxx"
;nano -w /etc/conf.d/net
;dns_domain_lo="xxx"
nano -w /etc/conf.d/net
config_eth0="dhcp"或
如
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"
网络自启动
cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0 default
配置域
nano -w /etc/hosts
如
(This defines the current system)
127.0.0.1 tux.homenetwork tux localhost
(Define extra systems on your network,
they need to have a static IP to be defined this way.)
192.168.0.5 jenny.homenetwork jenny
192.168.0.6 benny.homenetwork benny
26、设置root口令
passwd
27、配置服务
nano -w /etc/rc.conf
28、配置键映射
nano -w /etc/conf.d/keymaps
29、配置日期时间
nano -w /etc/conf.d/hwclock
30、配置本地编码
nano -w /etc/locale.gen
locale-gen
31、配置全局编码
/etc/env.d/02locale
32、重新载入shell
env-update && source /etc/profile
第五部分 配置系统工具
33、系统日志
emerge syslog-ng
rc-update add syslog-ng default
34、ssh服务自动启动
rc-update add sshd default
35、dhcp客户端
emerge dhcpcd
36、配置grub
emerge grub
nano -w /boot/grub/grub.conf
示例
# Which listing to boot as default. 0 is the first, 1 the second etc.
default 0
# How many seconds to wait before the default listing is booted.
timeout 30
# Nice, fat splash-image to spice things up :)
# Comment out if you don't have a graphics card installed
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Gentoo Linux 2.6.34-r1
# Partition where the kernel image (or operating system) is located
root (hd0,0)
kernel /boot/kernel-2.6.34-gentoo-r1 root=/dev/sda3
title Gentoo Linux 2.6.34-r1 (rescue)
# Partition where the kernel image (or operating system) is located
root (hd0,0)
kernel /boot/kernel-2.6.34-gentoo-r1 root=/dev/sda3 init=/bin/bb
# The next four lines are only if you dualboot with a Windows system.
# In this case, Windows is hosted on /dev/sda6.
title Windows XP
rootnoverify (hd0,5)
makeactive
chainloader +1
在看看
title Gentoo Linux 2.6.34-r1
root (hd0,0)
kernel /boot/2.6.34-r1 real_root=/dev/sda3
initrd /boot/initramfs-genkernel-amd64-2.6.34-gentoo-r1
37、安装grub
grep -v rootfs /proc/mounts > /etc/mtab
grub-install --no-floppy /dev/sda
38、重启系统
exit
cd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -l /mnt/gentoo{/boot,/proc,}
reboot
39、增加日用用户示例
# useradd -m -G users,wheel,audio -s /bin/bash john
# passwd john
Password: (Enter the password for john)
Re-enter password: (Re-enter the password to verify)
第六部分 删除临时文件
40、删除安装过程文件
rm /stage3-*.tar.bz2*
rm /portage-latest.tar.bz2*
第七部分 日常应用
eselect list xxx 显示可选的软件配置或版本
eselect set xxx n 选用软件版本
etc-update 更新配置文件
emerge --unmerge xxx 删除软件包
emerge --sync 更新软件包信息
emerge --update world 更新所有的已安装的可用更新
/etc/portage/package.use 定义单个包的USE变量
诸多省略...