前些時(shí)間在VMware上安裝了Gentoo Linux,用了當(dāng)前最新版的Gentoo,安裝過(guò)程記錄下來(lái)了,但一直沒(méi)有整理到blog上。今天重新整理一下,寫(xiě)出來(lái)與大家分享和備用。接觸Gentoo不久,對(duì)這個(gè)版本還不是很熟。
與其他Linux發(fā)行版相比,Gentoo確實(shí)有其優(yōu)勢(shì)的地方,如內(nèi)核基于源代碼編譯,可以自動(dòng)優(yōu)化與定制,升級(jí)方便等!
關(guān)于Gentoo發(fā)行版的介紹請(qǐng)看:全球最受歡迎的十大Linux發(fā)行版(圖)
Host機(jī)環(huán)境:Win2008 + VMware 7.1
下載安裝包
下載安裝 CD 和 stage3 包:
http://www.gentoo.org/main/en/where.xml
我用的是 x86平臺(tái)的:
http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/
wget -c http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/install-x86-minimal-20100216.iso
wget -c http://distfiles.gentoo.org/releases/x86/autobuilds/current-iso/stage3-i686-20100216.tar.bz2
wget -c http://distfiles.gentoo.org/snapshots/portage-20100617.tar.bz2
最新的stage3包在這里:http://distfiles.gentoo.org/releases/x86/autobuilds/current-stage3/
開(kāi)始安裝
將安裝 CD 插入虛擬機(jī),默認(rèn)引導(dǎo)進(jìn)入終端。
先配置好網(wǎng)絡(luò),之后的操作可以全部通過(guò) ssh 連接來(lái)操作。
ifconfig eth0 192.168.80.133(我這里VM已經(jīng)自動(dòng)分配了這個(gè)內(nèi)網(wǎng)IP了。)
echo nameserver 8.8.8.8 > /etc/resolv.conf
echo nameserver 8.8.4.4 > /etc/resolv.conf
設(shè)置 root 用戶密碼:
passwd root
啟動(dòng) sshd 服務(wù):
/etc/init.d/sshd start
在windows上用SecureCRT或PuTTY連接虛擬機(jī)操作。
磁盤(pán)分區(qū)
先分區(qū),建議使用cfdisk,先查看分區(qū)情況:
cfdisk /dev/sda
我的分區(qū)表(/boot分區(qū)我單獨(dú)分出來(lái)),/dev/sda2是/根分區(qū),/dev/sda3是swap分區(qū):
格式化分區(qū):
mkfs.ext3 /dev/sda1
mkfs.ext3 /dev/sda2
mkswap /dev/sda3
激活swap交換分區(qū):
swapon /dev/sda3
將分區(qū)信息寫(xiě)入fstab配置文件:(注:gentoo-minimal沒(méi)帶vi編輯器,只帶有nano編輯器。)
nano -w /etc/fstab
寫(xiě)入下面的分區(qū)信息:
/dev/sda1 /boot ext3 noauto,noatime 1 2
/dev/sda2 / ext3 noatime 0 1
/dev/sda3 none swap sw 0 0
解壓 stage3 和 portage
創(chuàng)建基本目錄結(jié)構(gòu):
mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
cd /mnt/gentoo
使用WinSCP或CuteFTP 上傳 stage3 軟件包到 /mnt/gentoo下,然后解壓:
(注:上面標(biāo)簽的地址之前沒(méi)改過(guò)來(lái),實(shí)際地址是192.168.80.133)
tar jxvf stage3-i686-20100608.tar.bz2
rm -f stage3-i686-20100608.tar.bz2
上傳 portage 包到 /mnt/gentoo/usr,然后解壓:
tar jxvf portage-20100617.tar.bz2
rm -f portage-20100617.tar.bz2
切換系統(tǒng)
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
主機(jī)域名設(shè)置
cd /etc
echo “127.0.0.1 gentoo.at.home gentoo localhost” > hosts
sed -i -e ’s/HOSTNAME.*/HOSTNAME=”gentoo”/’ conf.d/hostname
hostname gentoo
編譯安裝內(nèi)核
lsmod
找到網(wǎng)卡驅(qū)動(dòng)模塊:
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
下載源碼,配置內(nèi)核:
emerge –sync
emerge gentoo-sources
cd /usr/src/linux
make menuconfig
在配置界面輸入/e1000,搜索 e1000,找到驅(qū)動(dòng)所在位置:
| Symbol: E1000 [=y]
| Prompt: Intel(R) PRO/1000 Gigabit Ethernet support
| Defined at drivers/net/Kconfig:2020
| Depends on: NETDEVICES && NETDEV_1000 && PCI
| Location:
| -> Device Drivers
| -> Network device support (NETDEVICES [=y])
| -> Ethernet (1000 Mbit) (NETDEV_1000 [=y])
(這里一定要注意,選對(duì)內(nèi)核的網(wǎng)卡驅(qū)動(dòng)!)
虛擬機(jī)的硬盤(pán)使用的 SCSI 適配器為 LSI Logic。
需要增加對(duì) Fusion MPT base driver 的支持(見(jiàn) dmesg 日志):
Device Drivers —>
— 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
必須添加這個(gè)驅(qū)動(dòng),否則系統(tǒng)啟動(dòng)時(shí)可能出現(xiàn)類似以下錯(cuò)誤:
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device “sda2”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)
增加對(duì) ext4文件系統(tǒng)的支持:
File systems —>
<*> Second extended fs support
[*] Ext4 extended attributes
[*] Ext4 POSIX Access Control Lists
[*] Ext4 Security Labels
[*] Ext4 debugging support
開(kāi)始編譯內(nèi)核:
make -j2
make modules_install
cp arch/x86/boot/bzImage /boot/kernel
安裝配置 grub
emerge grub
grub
> root (hd0,0)
> setup (hd0)
> quit
編輯啟動(dòng)配置文件grub.conf:
nano -w /boot/grub/grub.conf
grub.conf 內(nèi)容如下:
default 0
timeout 9title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda2
系統(tǒng)配置
文件系統(tǒng)掛載點(diǎn):
nano -w /etc/fstab
/dev/sda1 /boot ext3 noauto,noatime 1 2
/dev/sda2 / ext3 noatime 0 1
/dev/sda3 none swap sw 0 0
網(wǎng)絡(luò)設(shè)置:
echo ‘config_eth0=( “192.168.80.133″ )’ >> /etc/conf.d/net
echo ‘routes_eth0=( “default via 192.168.80.2″ )’ >> /etc/conf.d/net
SSH服務(wù)設(shè)置:
rc-update add sshd default
時(shí)區(qū)設(shè)置:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
nano -w /etc/conf.d/clock
設(shè)置 root 密碼:
passwd root
重啟,完成安裝
exit
umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
reboot
如圖,Gentoo啟動(dòng)成功:
OK,完成!
附 make.conf



















參考文檔 http://www.gentoo.org/doc/zh_cn/handbook/handbook-amd64.xml
參考:http://www.ha97.com/