Gentoo安裝詳解(一) -- 安裝基本系統

aceking發表於2015-10-09

前期準備

遠端登入:

  • 開啟ssh服務:

/etc/init.d/sshd start

  • 設定密碼:

passwd

以便使用putty、ssh client遠端登入上傳stage等(有時線上下載很慢,而區域網上傳很快)

準備磁碟:

  • 分割槽:

fdisk /dev/sda

/dev/sda1 : /boot 100M(32-100M) 設啟動筆記-a /dev/sda2 : / 20G /dev/sda3 : /home 20G /dev/sda5 : /swap 1G (記憶體< 512 MB,分割槽分配2倍記憶體大小的空間;> 1024 MB,可以分配較少的空間甚至不需要swap 分割槽。)-t 82

  • 建立檔案系統:

mkfs.ext4 /dev/sda1 mkfs.ext4 /dev/sda2 mkfs.ext4 /dev/sda3 mkswap /dev/sda5

  • 掛載分割槽:

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

安裝系統

安裝stage及portage:

  • 正確設定日期/時間:

date

如果顯示的日期/時間不正確,可以使用date MMDDhhmmYYYY命令

  • 下載Stage3 Tarbll:

cd /mnt/gentoo links http://www.gentoo.org/main/en/mirrors.xml

選擇國內速度較快的映象,進入releases/x86/autobuilds/目錄裡。你將會看到所有適合你的計算機體系結構的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定義在安裝軟體的時候同時可以產生並行編譯的數目,CPU數目加一是個不錯的選擇

檢視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進入新系統環境:

Chroot:

  • 掛載 /proc, /dev, /sys檔案系統:

mount -t proc none /mnt/gentoo/proc mount --rbind /dev /mnt/gentoo/dev mount --rbind /sys /mnt/gentoo/sys

  • 進入新的系統環境:

chroot /mnt/gentoo /bin/bash source /etc/profile export PS1="(chroot) $PS1"

新環境配置:

  • 更新portage樹:

emerge --sync (Updating the Portage tree) 或 emerge-webrsync(fetch the latest portage snapshot)

  • 選擇Profile:

eselect profile list eselect profile set ×

  • 設定時區:

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

  • 更新環境變數:

env-update && source /etc/profile

相關文章