首页 > 操作系统 > Linux专区 > Gentoo 安装记录
2010
10-27

Gentoo 安装记录

晚上在虚拟机上重新装了下 gentoo,用了当前最新版的 gentoo,把安装过程记录下来备用。


下载安装包


下载安装 CD 和 stage3 包:


http://www.gentoo.org/main/en/where.xml


我用的是 amd64 平台的:


http://mirrors.kernel.org/gentoo/releases/amd64/autobuilds/current-iso/



wget http://mirrors.kernel.org/gentoo/releases/amd64/autobuilds/current-iso/install-amd64-minimal-20091203.iso



wget http://mirrors.kernel.org/gentoo/releases/amd64/autobuilds/current-iso/stage3-amd64-20091203.tar.bz2



wget http://distfiles.gentoo.org/snapshots/portage-20100116.tar.bz2


开始安装



将安装 CD 插入虚拟机,引导后进入命令行。



先配置好网络,之后的操作可以全部通过 ssh 连接来操作。



ifconfig eth0 192.168.1.12/24
route add default gw 192.168.1.1
echo nameserver 192.168.1.1 > /etc/resolv.conf


设置 root 用户密码:



passwd


启动 sshd 服务:



/etc/init.d/sshd start


用 SecureCRT 连接:


image


磁盘分区



fdisk /dev/sda


分区如下:



Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3df1b937



nano -w /etc/fstab
/dev/sda1 /boot ext2 noauto,noatime 1 2
/dev/sda3 / ext3 noatime 0 1
/dev/sda2 none swap sw 0 0


格式化分区:



mke2fs /dev/sda1
mke2fs -j /dev/sda3
mkswap /dev/sda2


启动交换分区:



swapon /dev/sda2


解压 stage3 和 portage


创建基本目录结构:



mount /dev/sda3 /mnt/gentoo
lmkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
cd /mnt/gentoo


使用 SecureFX 上传 stage3 包到 /mnt/gentoo,然后解压:



tar jxf stage3-amd64-20091203.tar.bz2
rm -f stage3-amd64-20091203.tar.bz2


上传 portage 包到 /mnt/gentoo/usr,然后解压:



tar jxf portage-20100116.tar.bz2
rm -f portage-20100116.tar.bz2


切换系统



cd /
mount -t proc proc /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile


主机域名设置



cd /etc
echo “127.0.0.1 gentoo.at.home gentoo localhost” > hosts
sed -i -e ‘s/HOSTNAME.*/HOSTNAME=”gentoo”/’ conf.d/hostname
hostname mybox


编译安装内核



lsmod


找到网卡驱动模块:



floppy 55736 0
rtc 7960 0
tg3 103228 0
libphy 24952 1 tg3
e1000 114636 0
fuse 59344 0
jfs 153104 0
raid10 20648 0


下载源码,配置内核:



emerge gentoo-sources
cd /usr/src/linux
make menuconfig


在配置界面输入/,搜索 e1000,找到驱动所在位置:



| Symbol: E1000 [=y]
| Prompt: Intel(R) PRO/1000 Gigabit Ethernet support
| Defined at drivers/net/Kconfig:1997
| Depends on: NETDEVICES && NETDEV_1000 && PCI
| Location:
| -> Device Drivers
| -> Network device support (NETDEVICES [=y])
| -> Ethernet (1000 Mbit) (NETDEV_1000 [=y])


虚拟机的硬盘使用的 SCSI 适配器为 LSI Logic。


需要增加对 Fusion MPT base driver 的支持(见 dmesg 日志):



— Fusion MPT device support
<*> Fusion MPT ScsiHost drivers for SPI
<*> Fusion MPT ScsiHost drivers for FC
<*> Fusion MPT ScsiHost drivers for SAS
(128) Maximum number of scatter gather entries (16 – 128)
<*> Fusion MPT misc device (ioctl) driver


必须添加这个驱动,否则系统启动时可能出现类似以下错误:



VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device “sda3”or unknown-block(2,0)
Please append a correct “root=” boot option; here are the available partitions:
0b00        1048575 sr0 driver: sr
Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(2,0)


增加对 ext2 文件系统的支持:



<*> Second extended fs support
[*] Ext2 extended attributes
[*] Ext2 POSIX Access Control Lists
[*] Ext2 Security Labels
[*] Ext2 execute in place support



make -j2
make modules_install
cp arch/x86_64/boot/bzImage /boot/kernel


安装配置 grub



emerge grub
grub
> root (hd0,0)
> setup (hd0)
> quit
nano -w /boot/grub/grub.conf


grub.conf 内容如下:



default 0
timeout 10


title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3


系统配置


文件系统挂载点:



nano -w /etc/fstab
/dev/sda1 /boot ext2 noauto,noatime 1 2
/dev/sda3 / ext3 noatime 0 1
/dev/sda2 none swap sw 0 0


网络设置:



echo ‘config_eth0=( “192.168.1.12/24″ )’ >> /etc/conf.d/net
echo ‘routes_eth0=( “default via 192.168.1.1″ )’ >> /etc/conf.d/net


服务设置:



rc-update add sshd default


时区设置:



cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
nano -w /etc/conf.d/clock


设置 root 密码:



passwd


重启,完成安装



exit umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
reboot


 

coolker2010-10-27 11:06:12


留下一个回复