前些時間在VMware上安裝了Gentoo Linux,用了當前最新版的Gentoo,安裝過程記錄下來了,但一直沒有整理到blog上。今天重新整理一下,寫出來與大家分享和備用。接觸Gentoo不久,對這個版本還不是很熟。
與其他Linux發(fā)行版相比,Gentoo確實有其優(yōu)勢的地方,如內核基于源代碼編譯,可以自動優(yōu)化與定制,升級方便等!
關于Gentoo發(fā)行版的介紹請看:全球最受歡迎的十大Linux發(fā)行版(圖)
Host機環(huán)境:Win2008 + VMware 7.1
下載安裝包
下載安裝 CD 和 stage3 包:
http://www./main/en/where.xml
我用的是 x86平臺的:
http://distfiles./releases/x86/autobuilds/current-iso/
wget -c http://distfiles./releases/x86/autobuilds/current-iso/install-x86-minimal-20100216.iso
wget -c http://distfiles./releases/x86/autobuilds/current-iso/stage3-i686-20100216.tar.bz2
wget -c http://distfiles./snapshots/portage-20100617.tar.bz2
最新的stage3包在這里:http://distfiles./releases/x86/autobuilds/current-stage3/
開始安裝
將安裝 CD 插入虛擬機,默認引導進入終端。
先配置好網絡,之后的操作可以全部通過 ssh 連接來操作。
ifconfig eth0 192.168.80.133(我這里VM已經自動分配了這個內網IP了。)
route add default gw 192.168.80.2(注:如果上不了外網,一般都是找不到這個網關地址,可以手動添加?。?br>
echo nameserver 8.8.8.8 > /etc/resolv.conf
echo nameserver 8.8.4.4 > /etc/resolv.conf

設置 root 用戶密碼:
passwd root
啟動 sshd 服務:
/etc/init.d/sshd start
在windows上用SecureCRT或PuTTY連接虛擬機操作。
磁盤分區(qū)
先分區(qū),建議使用cfdisk,先查看分區(qū)情況:
cfdisk /dev/sda
我的分區(qū)表(/boot分區(qū)我單獨分出來),/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ū)信息寫入fstab配置文件:(注:gentoo-minimal沒帶vi編輯器,只帶有nano編輯器。)
nano -w /etc/fstab
寫入下面的分區(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)建基本目錄結構:
mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
cd /mnt/gentoo
使用WinSCP或CuteFTP 上傳 stage3 軟件包到 /mnt/gentoo下,然后解壓:

(注:上面標簽的地址之前沒改過來,實際地址是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
主機域名設置
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
編譯安裝內核
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 --sync
emerge gentoo-sources
cd /usr/src/linux
make menuconfig
注:如果顯示亂碼請運行一下:export LANG=zh_CN.UTF-8

在配置界面輸入/e1000,搜索 e1000,找到驅動所在位置:

| 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])
(這里一定要注意,選對內核的網卡驅動!)
虛擬機的硬盤使用的 SCSI 適配器為 LSI Logic。
需要增加對 Fusion MPT base driver 的支持(見 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
必須添加這個驅動,否則系統(tǒng)啟動時可能出現(xiàn)類似以下錯誤:
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)
增加對 ext4文件系統(tǒng)的支持:
File systems —>
<*> Second extended fs support
[*] Ext4 extended attributes
[*] Ext4 POSIX Access Control Lists
[*] Ext4 Security Labels
[*] Ext4 debugging support
開始編譯內核:
make -j2
make modules_install
cp arch/x86/boot/bzImage /boot/kernel

安裝配置 grub
emerge grub
grub
> root (hd0,0)
> setup (hd0)
> quit
編輯啟動配置文件grub.conf:
nano -w /boot/grub/grub.conf
grub.conf 內容如下:
default 0
timeout 9
title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda2
系統(tǒng)配置
文件系統(tǒng)掛載點:
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
網絡設置:
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服務設置:
rc-update add sshd default
時區(qū)設置:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
nano -w /etc/conf.d/clock
TIMEZONE=”Asia/Shanghai”
設置 root 密碼:
passwd root
重啟,完成安裝
exit
umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
reboot
如圖,Gentoo啟動成功:

補充:如果要使用DHCP客戶端自動分配IP,請執(zhí)行以下操作:
emerge dhcpcd
rc-update add dhcpcd default
OK,完成!
參考文檔:
http://www./doc/zh_cn/handbook/handbook-x86.xml
http://www./doc/zh_cn/gentoo-x86-quickinstall.xml
|