前期準備
遠程登錄:
- 開啟ssh服務:
/etc/init.d/sshd start
- 設置密碼:
passwd
以便使用putty留储、ssh client遠程登錄上傳stage等(有時在線下載很慢炮赦,而局域網(wǎng)上傳很快)
準備磁盤:
- 分區(qū):
fdisk /dev/sda
/dev/sda1 : /boot 100M(32-100M) 設啟動筆記-a
/dev/sda2 : / 20G
/dev/sda3 : /home 20G
/dev/sda5 : /swap 1G (內(nèi)存< 512 MB,分區(qū)分配2倍內(nèi)存大小的空間;> 1024 MB缕碎,可以分配較少的空間甚至不需要swap 分區(qū)缤言。)-t 82
- 創(chuàng)建文件系統(tǒng):
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3
mkswap /dev/sda5
- 掛載分區(qū):
mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount /dev/sda3 /mnt/gentoo/home
swapon /dev/sda5
安裝系統(tǒng)
安裝stage及portage:
- 正確設置日期/時間:
date
如果顯示的日期/時間不正確珍昨,可以使用date MMDDhhmmYYYY命令
- 下載Stage3 Tarbll:
cd /mnt/gentoo
links http://www.gentoo.org/main/en/mirrors.xml
選擇國內(nèi)速度較快的鏡像木蹬,進入releases/x86/autobuilds/目錄里。你將會看到所有適合你的計算機體系結(jié)構(gòu)的stage文件(它們也可能放在各個獨立的子體系名稱的子目錄里)亲怠。選擇一個所计,然后按D來下載。下載完以后团秽,再按Q退出瀏覽器主胧。
或使用SSH Secure Shell登錄上傳stage3文件
- 解開Stage3 Tarball:
tar xvjpf stage3-*.tar.bz2
- 下載Portage:
打開links(或者lynx)然后到我們的Gentoo鏡像列表。選擇一個離你最近的鏡像习勤,打開snapshots/目錄踪栋。然后選擇最新的Portage快照(portage-latest.tar.bz2)并按D來下載它。
links http://www.gentoo.org/main/en/mirrors.xml
或使用SSH Secure Shell登錄上傳portage文件
- 解壓Portage:
tar -xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr (install a Portage snapshot)
編譯前準備:
- 配置編譯選項:
nano -w /mnt/gentoo/etc/portage/make.conf
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}" # 兩個變量使用相同的設置
MAKEOPTS="-j3" #MAKEOPTS定義在安裝軟件的時候同時可以產(chǎn)生并行編譯的數(shù)目姻报,CPU數(shù)目加一是個不錯的選擇
查看cpu信息:
cat proc/cpuinfo
- 選擇鏡像站點:
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
Warning:app-portage/mirrorselect has not been updated to handle modifying the target chrootsrepos.conf/gentoo.conf file yet. Also, the SYNC variable in make.conf is deprecated and no longer used by portage. This section needs to be updated, please skip for the time being...
- 拷貝DNS信息:
cp -L /etc/resolv.conf /mnt/gentoo/etc/
Chroot進入新系統(tǒng)環(huán)境:
Chroot:
- 掛載 /proc, /dev, /sys文件系統(tǒng):
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
- 進入新的系統(tǒng)環(huán)境:
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
新環(huán)境配置:
- 更新portage樹:
emerge --sync (Updating the Portage tree)
或
emerge-webrsync(fetch the latest portage snapshot)
- 選擇Profile:
eselect profile list
eselect profile set ×
- 設置時區(qū):
ls /usr/share/zoneinfo
echo "Europe/Brussels" > /etc/timezone
emerge --config sys-libs/timezone-data
- 設置locale:
nano -w /etc/locale.gen
locale-gen
eselect locale list
eselect locale set x
- 更新環(huán)境變量:
env-update && source /etc/profile