一、安裝方法
快速安裝方法見,不過本人沒有安裝成功,可能是光碟機有點問題。Gentoo Linux 快速安裝方法安裝
gentoo linux有幾種安裝方法,下面使用官方最小安裝的方法。安裝成功。
二、安裝步驟
1、準備啟動盤
1.1首先下載gentoo最小安裝光碟片,http://mirrors.sohu.com/gentoo/releases/x86/current-stage3/install-x86-minimal-20111129.iso
1.2. 利用UltraISO來燒錄鏡像
1.3. 插入隨身碟
1.4. 用UltralISO開啟iso檔案
1.5. 選擇啟動-> 寫入硬碟鏡像
1.6. 格式化隨身碟,再點寫入
1.7. 在BIOS中選擇從USB啟動之後就可以用隨身碟啟動系統,進行安裝了。
2、正式安裝
2.1. BIOS啟動選擇隨身碟啟動。
2.2. 啟動系統boot
2.3. 磁碟分割
使用fdisk或cfdisk磁碟管理工具對磁碟分割。
這裡本人對磁碟分割如下:
裝置 大小 掛載點
/dev/sda1 30G NFTS
/dev/sda2 300M /boot
/dev/sda3 60G /
/dev/sda5 2G swap
/dev/sda6 60G /home
fdisk詳細使用如下,摘自官方文檔Gentoo安裝過程中fdisk的使用
2.5 掛載分區
mount /dev/sda3 /mnt/gentoo/
mount /dev/sda2 /mnt/gentoo/boot
mount /dev/sda6 /mnt/gentoo/home
2.6 下載解壓stage3
cd /mnt/gentoo
然後使用
wget http://mirrors.sohu.com/gentoo/releases/x86/current-stage3/stage3-i686-20111129.tar.bz2
或者使用links命令,點擊對應的連結進行下載。
解壓
tar xvjpf stage*
2.7 安裝Portage
和上面一樣,下載http://mirrors.sohu.com/gentoo/snapshots/portage-latest.tar.bz2
並解壓
2.8 配置編譯選項
開啟make.conf檔案
nano -w /mnt/gentoo/etc/make.conf
設定CFLAGS和CXXFLAGS如下
CFLAGS="-O2 -march=nocona -pipe"
# 兩個變數使用相同的設定
CXXFLAGS="${CFLAGS}"
CHOST="i686-pc-linux-gnu"
MAKEOPTS="-j3"
USE="-gtk -gnome3 qt3qt4 kde alsa cdr"
GENTOO_MIRRORS="http://mirrors.sohu.com/gentoo"
三、安裝Gentoo基本系統
3.1 COPY DNS資訊並掛載proc和dev檔案系統
# cp -L /etc/resolv.conf /mnt/gentoo/etc/
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
3.2 進入新的Gentoo環境
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
3.3 更新Portage樹
emerge --sync
3.4 選擇profile
# eselect profile list
# eselect profile set n
3.5 設定LOCALE
# nano -w /etc/locale.gen
添加如下:
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GB18030
zh_CN.GBK GBK
zh_CN.GB2312 GB2312
zh_CN.UTF-8 UTF-8
3.6 安裝源碼
emerge gentoo-sources
3.7 配置核心
make menuconfig
這雷根據自己的電腦特點來選擇,比如本人將核心選項中的CPU類型家族改成CORE2,由於不是大記憶體(大於4G),這裡將支援大記憶體的功能刪除,將PAE功能裁剪掉,還可以根據自己的硬體類型適當修改硬體的驅動,建議如果明確可以修改,不是很明確的地方保持預設。配置核心對以後系統的效能有很大影響。
3.8 然後編譯核心和驅動,並安裝驅動
make && make modules_install
3.9 安裝核心
cp arch/x86/boot/bzImage /boot/kernel-3.0.6-gentoo
注意修改核心的名字對應自己的核心版本
四、配置系統
4.1 修改/etc/fstab
# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency). It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#
# <fs> <mountpoint> <type> <opts> <dump/pass>
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/sda2 /boot ext3 defaults,noatime 1 2
/dev/sda3 / ext3 noatime 1 1
/dev/sda5 none swap sw 0 0
/dev/sda6 /home ext3 defaults,noatime 1 2
/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
4.2 配置網路
<span style="font-size:18px;"># nano -w /etc/conf.d/hostname
(將HOSTNAME的變數值設定為主機名稱)
HOSTNAME="yan-laptop"
</span>
<span style="font-size:18px;"># nano -w /etc/conf.d/net
(設定dns_domain的變數值為你的網域名稱)
dns_domain_lo="homenetwork"
config_eth0=( "192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255" )
routes_eth0=( "default via 192.168.0.1" )
config_eth0=( "dhcp" )</span>
<span style="font-size:18px;"># cd /etc/init.d
# ln -s net.lo net.eth0
# rc-update add net.eth0 default
</span>
<span style="font-size:18px;"># nano -w /etc/hosts
127.0.0.1 localhost yan-laptop
</span>
最後安裝一個DHCP用戶端,讓機器自動設定網路
<span style="font-size:18px;">emerge dhcpcd</span>
五、安裝GRUB引導
<span style="font-size:18px;">emerge grub</span>
5.1 修改/boot/grub/grub.cfg
<span style="font-size:18px;">nano -w /etc/boot/grub/grub.cfg</span>
檔案內容如下:
<span style="font-size:18px;"># This is a sample grub.conf for use with Genkernel, per the Gentoo handbook
# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2
# If you are not using Genkernel and you need help creating this file, you
# should consult the handbook. Alternatively, consult the grub.conf.sample that
# is included with the Grub documentation.
default 0
timeout 5
#splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Gentoo Linux 3.0.6
root (hd0,1)
kernel /boot/kernel-3.0.6-gentoo root=/dev/sda3
title Windows 7
rootnoverify(hd0,0)
makeactive
chainloader +1
# vim:ft=conf:</span>
5.2 建立mtab
<span style="font-size:18px;">grep -v rootfs /proc/mounts > /etc/mtab</span>
5.3 安裝grub
<span style="font-size:18px;">grub-install --no-floppy /dev/sda</span>
重啟,選擇Gentoo,啟動成功,基本系統安裝完成。
有空將KDE案頭裝上。不過編譯得有一天的時間。這就是Gentoo的特點,高度的定製性,才能獲得高的效率。這就是Gentoo的Philosopy。
摘自 閆明--To Be a Linux Kernel Hacker