注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Install/zh-tw

From Funtoo
Revision as of 17:55, August 20, 2018 by Bh2142 (talk | contribs) (Created page with "{{f|/etc/localtime}}是用來指定你的電腦該使用哪個時區,預設值是UTC,如果你希望Funtoo Linux使用本地時間,把{{f|/etc/localtime}},改成你想...")
Jump to navigation Jump to search

Install Funtoo Linux

Other languages:
Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎slovenčina • ‎Ελληνικά • ‎русский • ‎українська • ‎հայերեն • ‎עברית • ‎ไทย • ‎中文(中国大陆)‎ • ‎中文(台灣)‎ • ‎日本語 • ‎한국어
   {{{title}}}
{{{body}}}

介紹

這份教學能幫助你在PC相容系統上以最簡單的步驟安裝Funtoo Linux。

如果你有Gentoo Linux的安裝經驗,你可能會對安裝流程感到十分熟悉,但是因為兩者之間仍有許多不同,所以還是建議你閱讀整份文件。如果你是第一次安裝Gentoo系發行版或甚至是第一次接觸Linux,我們都非常歡迎你的加入,我們會盡量讓純新手也能看懂這份教學。

   Note

如果你想在ARM架構上安裝Funtoo Linux,請參閱Funtoo Linux Installation on ARM 以了解不同之處

概要

安裝Funtoo的基本步驟:


  1. 下載並啟動live CD
  2. 準備硬碟
  3. 建立掛載檔案系統
  4. 安裝Stage3
  5. Chroot到新系統
  6. 下載Portage樹
  7. 系統網路設定
  8. 安裝內核.
  9. 安裝啟動程式
  10. 收尾
  11. 重啟並享受Funtoo

Live CD

要安裝Funtoo Linux,首先你需要一個Linux的Live CD或是隨身碟來啟動你的電腦。我們推薦Gentoo系的System Rescue CD ,因為它附有很多工具而且同時支援32和64位元的系統。你可以將它燒錄進CD/DVD或是安裝在隨身碟裡。在這裡可以下載他們:



   Important

沒有畫面: 在使用UEFI開機時System Rescue CD 可能沒有正確初始化顯示卡 (參閱 FL-2030) 如果碰到這種情況,在System Rescue CD啟動進入GRUB目錄時按下 e 編輯GRUB啟動項目並加入insmod all_video 然後重新啟動。 這個Bug已經回報給System Rescue CD的開發者了。


   Note

如果你正在使用舊版本的System Rescue CD, 欲安裝64位元的系統,請確認你在啟動時選擇了rescue64 的內核,System Rescue CD在預設的情況下會以32位元模式啟動,但在最新的版本中 系統會嘗試自動偵測64位元的處理器。

連接網路

如果你已經成功啟動System Rescue CD務必確認是否已經連上網路,因為安裝Funtoo Linux必須要用到網路。

root # ping www.google.com
PING www.google.com (216.58.217.36) 56(84) bytes of data.
64 bytes from den03s10-in-f4.1e100.net (216.58.217.36): icmp_seq=1 ttl=57 time=30.1 ms

如果你成功的ping通了(看到64 bytes的訊息)這代表你成功的連上了網路,按Control-C來停下ping程序。

如果你需要設定WiFi連接網路,那麼你會需要用到System Rescue CD的桌面環境。輸入startx來啟動圖形使用者介面。

(譯註: 在新的英文頁面提供了不使用圖形介面的方法-nmtui,但受限於翻譯系統,我們目前無法翻譯,請自行前往英文頁面以了解更多)

root # startx
caption

然後使用NetworkManager程式 (在工具列右下方的小圖示)來連接WiFi網路。接著開啟桌面環境裡的終端機來完成接下來的步驟。

遠端安裝

你也可以透過SSH來遠端登入System Rescue CD來從其他的電腦上安裝,這樣安裝Funtoo Linux可能更加的方便。

如果想要遠端安裝Funtoo,首先你需要去認System Rescue CD已經成功連上網路,然後你會需要設定一組System Rescue CD的root密碼。

root # passwd
New password: ********
Retype new password: ********
passwd: password updated successfully

設定完密碼後,你還會需要知道System Rescue CD的ip位址來ssh它。輸入ifconfig來取得System Rescue CD的ip位址:

root # ifconfig

其中一個網路介面應該要擁有一組ip位址(包含字串inet addr:),你可以從區域網路中的其他電腦遠端連接到System Rescue CD並使用現有的作業系統來完成安裝的工作。在像是MacOS或是Linux等你想用來遠端操作的系統上輸入(將1.2.3.4替換為System Rescue CD的ip位址):

(remote system) $ ssh root@1.2.3.4
Password: **********
   Note

如果想從Microsoft Windows連接 你需要下載一個SSH客戶端,例如:PuTTY

在透過SSH登入System Rescue CD之後你就能遠端的執行下列的安裝步驟了。

準備硬碟

在這個項目中,我們將會學到好幾種Funtoo Linux從硬碟上啟動的方式,"Boot"代表著Linux在你按下電源鍵之後的啟動程序,你可以將"booting"想成一個透過韌體來尋找並啟動Linux內核的程序,再由內核來識別所有的硬體而後啟動系統。

背景知識

   Note

如果你從未接觸過Linux, 跳過這個章節也許能夠避免太多的困惑,該用哪個?

以前,要啟動PC相容的電腦只有一種方法,所有的個人電腦和伺服器都擁有一個標準的韌體"PC BIOS"我們所有的硬碟都在首個磁區使用"主開機紀錄(MBR)",PC BIOS能夠識別出能夠加載LInux的啟動代碼以及磁碟的 多個分割區,而我們都喜歡這種方法!

後來出現了EFI和UEFI,一種全新的開機導引,以及能夠定義大於2.2TB硬碟的的GPT分割表。突然,我們就擁有了一大堆安裝和啟動Linux系統的選擇了,同時也將事情弄得更複雜。

接著我們花一些時間來了解一些能夠用來啟動Funtoo Linux的硬碟設置,這份教學採用並推薦使用MBR的舊式方法,在幾乎所有的電腦上都能運作,只要你的硬碟小於2TB他都不會影響到電腦的使用。

但是在某些狀況下舊式的方法並不是最好的,如果你有一顆大於2TB的硬碟,MBR分割會導致你無法完整使用整顆硬碟空間,還有一個情況是有一些新的主機板強迫你使用UEFI而不再支援舊式的BIOS開機,所以本篇文章也提供了UEFI的教學。

不過除非不得已,我們還是推薦你使用舊的方法。這份教學使用GRUB加載Linux,這種在PC相容機器上啟動Linux的傳統方法被叫做BIOS + GRUB (MBR)

如果你需要使用UEFI來開機,我們建議你完全不要使用MBR,只有少數的系統容許你使用MBR又使用UEFI,我們推薦使用UEFI來啟動GRUB來加載LInux,這種方法被稱為UEFI + GRUB (GPT)

當然還有其他的方法,這些方法我們收錄在Boot Methods頁面,我們曾經推薦使用BIOS + GRUB (GPT),但他不再被大部分的硬體支援了。

該用哪個?

問題是該選哪一種呢? 這就是答案:

一、舊式方法
如果你能使用System Rescue CD開機,而且開機後能看到一個藍色選單,這表示System Rescue CD使用BIOS開機,也就是Funtoo也能使用舊式的方法來啟動,選擇舊式方法吧,除非你有像是有超過2.2TB的硬碟等等的理由,那麼看看方法二,也許你的電腦支援UEFI開機。
二、新式方法
如果你能正確啟動System Rescue CD而且看到了一個黑底白字的選單,恭喜,你的電腦支援UEFI開機,當然他也可能支援BIOS開機,但是你可以先試一試並花一點時間研究一下新的方法。


   Note

高手可能想問: 舊式和新式方法最大的不同是什麼: 如果你使用舊式的MBR分割,/boot 分割區會採用ext2檔案系統,而要建立新的MBR分割區需要使用的工具是fdisk,如果你使用的是新式的GPT分割,/boot分割區會採用vfat檔案系統,這樣UEFI才能正確識別,而要創建新的GPT分割區則需要使用gdisk,GRUB的安裝過程也會有些許的不同,接下來會碰到的差異大概就只有這些,希望能滿足你的好奇心。

如果要透過新的UEFI方法來安裝Funtoo Linux,首先必須要使用UEFI來啟動System Rescue CD,如果成功了,你會看到一個黑底白字的選單來選擇你想啟動的模式,但如果是一個藍底黑字的選單,這表示你無法使用UEFI來完成接下來的安裝程序。

   Note

某些主機板可能支援UEFI,某些則不,事前做些研究,舉例來說 我的Gigabyte GA-990FXA-UD7 rev 1.1主機板裡的Award BIOS可以透過UEFI來啟動CD/DVD,但這不表示你能透過UEFI從硬碟中啟動Funtoo Linux ,UEFI必須要同時支援移動式硬體(這樣才能啟動System Rescue CD)和固定式硬體(才能從硬碟中啟動Funtoo), 結果只有更新的版本(rev 3.0)才完整的支援UEFI啟動。這也點出了第三個要點,完全了解你的硬體。

舊式方法 (BIOS/MBR)

   Note

這方法適用於使用BIOS來開機的情況,而使用BIOS啟動電腦你會看到一個藍色的選單,如果你想使用新式方法啟動 , 點擊轉跳到UEFI/GPT章節

首先,你需要找到正確的硬碟來進行分割,使用這個指令來確認/dev/sda是你要用來分割的硬碟。

root # fdisk -l /dev/sda

Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt

root #         Start          End    Size  Type            Name
 1         2048   1250263694  596.2G  Linux filesyste Linux filesystem

接著我們建議你清除硬碟上所有的MBR或GPT分割表,否則BIOS在啟動時可能會發生一點錯誤,我們使用sgdisk來完成這項工作:Template:注意

root # sgdisk --zap-all /dev/sda

Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

如果出現了這個訊息也不需要擔心,指令仍然是成功的:

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

接著使用fdisk來創建MBR分割表和分割區:

root # fdisk /dev/sda

fdisk中依照下列指示操作:

清空分割表:

Command (m for help): o ↵

建立分割區1: (boot)

Command (m for help): n ↵
Partition type (default p): 
Partition number (1-4, default 1): 
First sector: 
Last sector: +128M ↵

建立分割區2 (swap):

Command (m for help): n ↵
Partition type (default p): 
Partition number (2-4, default 2): 
First sector: 
Last sector: +2G ↵
Command (m for help): t ↵ 
Partition number (1,2, default 2): 
Hex code (type L to list all codes): 82 ↵

建立root分割區:

Command (m for help): n ↵
Partition type (default p): 
Partition number (3,4, default 3): 
First sector: 
Last sector: 

驗證分割表:

Command (m for help): p

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x82abc9a6

Device    Boot     Start       End    Blocks  Id System
/dev/sda1           2048    264191    131072  83 Linux
/dev/sda2         264192   4458495   2097152  82 Linux swap / Solaris
/dev/sda3        4458496 625142447 310341976  83 Linux

將分割表寫入硬碟:

Command (m for help): w

全新的MBR分割表將會被寫入你的系統硬碟中。

   Note

你已經完成了硬碟分割了! 現在轉跳到建立檔案系統

新式方法 (UEFI/GPT)

   Note

如果你對使用UEFI來啟動很有興趣的話,可以選擇這個方法,而System Rescue CD的開機選單會是黑底白字的,如果出現的是藍色的選單,那麼這個方法則不適用於你的電腦。

請依照下列的指示使用gdisk來建立GPT分割區,雖然預設的大小就是用於大部分的使用者,但是選擇適當的分割區大小仍然很重要。啟動 gdisk:

root # gdisk /dev/sda

gdisk中依照下列指示操作:

建立一個全新的分割表 (這在寫入硬碟後將會清除硬碟上的所有資料):

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

建立分割區1: (boot)

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: EF00 ↵

建立分割區2 (swap):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +4G ↵
Hex Code: 8200 ↵

建立分割區3 (root):

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector:  (for rest of disk)
Hex Code: 

運行的過程中可以輸入"p"接著按下Enter來查看當前的分割表,如果有任何錯誤隨時能輸入"d"來刪除已經建立好的分割區,在完成所有步驟之後,輸入"w"將變更寫入硬碟之中:


將分割表寫入硬碟:

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

分割表將被寫入硬碟,而gdisk會關閉。

現在GPT/GUID分割區已經被建立好了,並且在Linux中會以"block devices"的形式出現。

  • /dev/sda1將被作為/boot分割區
  • /dev/sda2將被作為置換空間(swap space)
  • /dev/sda3則是成為/root分割


   Tip

你可以透過lsblk指令來查看所有的分割區是否正確

建立檔案系統

   Note

這個章節同時適用於"BIOS"和"UEFI",別不小心跳過他了!

在你新建立的分割區能派上用場之前,這些前一個步驟了產物需要被使用"檔案相關資料"初始化,這個步驟又被稱為"建立檔案系統",在檔案系統被建立之後,他們才能被掛載,然後用來儲存檔案。

簡單來說,如果你正在使用舊式的MBR分割區,那麼在/dev/sda1上建立一個ext2檔案系統:

root # mkfs.ext2 /dev/sda1

如果你為了使用UEFI而使用新式的GPT分割區,則在/dev/sda1上使用vfat檔案系統,這樣UEFI才有辦法讀取。

root # mkfs.vfat -F 32 /dev/sda1

接著,建立一個swap分割區,這個分割區將在Funtoo Linux上作為一個由硬碟構成的虛擬記憶體。

因為swap分割區並不是用來儲存檔案的所以你不需要為他建立一個檔案系統,但他仍需要透過mkswwap指令來初始化,接著使用swapon來讓你剛初始化好的置換空間能夠立即被live CD環境使用,以防他在接下來的安裝流程中會被使用到:

root # mkswap /dev/sda2
root # swapon /dev/sda2

現在我們需要建立一個root檔案系統,這就是Funtoo LInux安裝的地方,我們大致上推薦使用ext4或是XFS檔案系統,如果你不確定該用哪個,那就選擇ext4,以下是示範如何為root建立一個ext4檔案系統:

root # mkfs.ext4 /dev/sda3

如果你想使用XFS系統,則參考下列指示:

root # mkfs.xfs /dev/sda3

你的檔案系統(和swap)全都已經初始化好了,現在他們能被掛載(mount,連接到檔案目錄裡)並用來儲存檔案,這樣我們就能開始在這全新的檔案系統上安裝Funtoo Linux了。

Template:注意

掛載檔案系統

請依照下列指示掛載剛剛建立的檔案系統,並新增/mnt/funtoo作為安裝Funtoo Linux的掛載點:

root # mkdir /mnt/funtoo
root # mount /dev/sda3 /mnt/funtoo
root # mkdir /mnt/funtoo/boot
root # mount /dev/sda1 /mnt/funtoo/boot

如果你別的檔案系統像是/home:

root # mkdir /mnt/funtoo/home
root # mount /dev/sda4 /mnt/funtoo/home

假如你需要在分開的檔案系統上設置/tmp或是/var/tmp,請向下列操作一樣,確定你已經將掛載點的權限設定為全域可變更。

root # chmod 1777 /mnt/funtoo/tmp

設定日期

   Important

如果你的系統的日期和時間和現實相差太多(通常是以月或是年為單位),那麼它可能會導致Portage無法正確下載原始碼包。這是因為我們有些資源需要透過HTTPS來下載,而這些資源使用SSL證書,並標有生效日期及期限。 不過,如果您的系統時間大致上正確,則可以暫時跳過此步驟。

是時候使用date來確認日期和時間是否都已經被正確設定為UTC。

root # date
Fri Jul 15 19:47:18 UTC 2011

如果日期或是時間需要修正,使用date MMDDhhmmYYYY並記住hhmm採用24小時制,下面的例子是將日期和時間設定成"July 16th, 2011 @ 8:00PM" UTC:

root # date 071620002011
Fri Jul 16 20:00:00 UTC 2011

設定好系統時間之後,最好將之寫入硬體時鐘,這樣下次開機之後才不需要重新設定:

root # hwclock --systohc

安裝 Stage 3 壓縮包

檔案系統和系統時間都設定好之後,我們來下載Stage 3 壓縮包,Stage 3 是一個預先編譯好,並用來當作安裝Funtoo Linux出發點的系統。

為了下載符合你系統的Funtoo Linux版本,請參考Subarches頁面。Subarches是為了在特定種類的CPU上提供Funtoo Linux的最佳表現而設計的版本,同時也對各種不同CPU的指令集做了不同的優化。

Subarches頁面列出了所有針對不同CPU做優化的Funtoo Linux版本,找出適合你電腦CPU的種類,然後點擊他在第一欄的名字(像是corei7),然後你將會被導向到專用的Subarch頁面,這個頁面也會列出你能下載的stage3版本,如果你想要使用虛擬化技術來運行Funtoo,而你的虛擬機則可以轉移到不同的硬體,所以我們建議你使用針對最老的cpu指令集進行優化的stage3壓縮包或是可以同時運行在AMD及Intel處理器的通用版本。

大部分的subarches都會提供多種stage3作選擇,這個章節將會幫助你了解你該選哪個。

哪個版本?

如果你不太確定,那就選funtoo-current

Funtoo Linux 提供多種不同的 'build'(版本):


BuildDescription
funtoo-current最常被選擇的版本,且提供快速的更新,日常用途的使用者通常會選擇這個版本。
funtoo-stable套件的更新比較不頻繁,且採用最值得信賴的而非最新的版本。

哪個變種?

如果你不太確定,那就選standard

我們"常規"的stage3文件都列出了一些基於standard的變種,以下的變種版本都是可以使用的:

VariantDescription
standardFuntoo Linux的標準版
pure64一個捨棄了multilib(兼容32位元)支援的64位元版本,這會是你建立伺服器的理想選擇。
hardened包含PIE/SSP toolchain來提升安全性,PIE要求內核要使用PaX,而SSP可以在任何的內核上運作並且能提升使用者空間的安全性從而避免基於stack的漏洞,推薦專業的使用者使用。

下載 Stage3

找到你想要下載的stage3之後,使用wget指令來下載他作為你新的Funtoo LInux的基礎,壓縮包應該像下面的範例一樣被下載到/mnt/funtoo目錄之下:

root # cd /mnt/funtoo
root # wget http://build.funtoo.org/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz

注意64位元的電腦可以運行32及64位元的Stage,但是32位元的電腦只能運行32位元的Stage,且確定你選擇了適合你的CPU的Stage3版本,如果你不確定,保險起見,你可以選擇generic_64或是generic_32 stage,參考Subarches頁面以獲得更多資訊。

下載好之後,使用下列的指令來解壓縮你的Stage3文件包,記得代入你所選擇的Stage3壓縮包的真正檔名:

root # tar xpf stage3-latest.tar.xz
   Important

使用tar的"p"參數來解壓縮Stage3壓縮包非常的重要,他告訴tar保存(preserve)壓縮包裡面所有文件的權限設定,如果沒使用這個參數,你的Funtoo Linux檔案系統會產生很多權限上的錯誤。

Chroot進入Funtoo

要安裝Funtoo LInux,首先你要先使用chroot指令,這個指令可以"切換(switch into)"到新的Funtoo Linux系統,也就是說,在"chroot"指令之後的其他指令將會作用於你新解壓縮出來的Funtoo Linux系統,而非System Rescue CD。

在Chroot之前,還需要針對chroot環境作一些設定,你需要在新系統裡掛載/proc/sys/dev,使用下列的命令來完成這項工作:

root # cd /mnt/funtoo
root # mount -t proc none proc
root # mount --rbind /sys sys
root # mount --rbind /dev dev

你也會需要覆寫resolv.conf以在chroot裡面正確地解析主機名稱:

root # cp /etc/resolv.conf /mnt/funtoo/etc/

現在你能chroot進入新系統了,在chroot之前先使用env指令來確保安裝媒介的環境設定不會影響到你的新系統:

root # env -i HOME=/root TERM=$TERM chroot . bash -l
   Note

如果有人要使用64位元的live CD來安裝32位元的系統:某些軟體會使用uname -r來確認系統的版本,所以你可能會需要在chroot指令中加入linux32參數來解決這個問題,不過一般來說是不必要的。

   Important

如果你看到這樣的錯誤訊息 "chroot: failed to run command `/bin/bash': Exec format error"有可能是因為你運行了32位元的內核,試著運行64位元的程式,以確認你在使用SystemRescueCD啟動時選擇了正確的內核。

在chroot裡面最好修改一下命令提示字元,以避免你在切換終端機時受到混淆,執行

root # export PS1="(chroot) $PS1"

指令,接著在chroot中測試域名解析

root # ping -c 5 google.com

,如果無法成功連上google,檢查下/etc/resolv.conf裡面有沒有像是127.0.x.x的ip位址,如果有,將127.0.x.x修改成8.8.8.8 -- Google的公開DNS位址,別忘了在系統安裝好了之後將這條置換為你選擇的DNS。


恭喜!你已經chroot進入一個Funtoo LInux系統了,是時候將Funtoo Linux正確的設定好,這樣Funtoo Linux才能在沒有手冊的協助下成功的啟動。

   Note

可以參考Installing Portage From Snapshot來了解其他替代方案。

接著來安裝一份Portage repo吧,這份repo中含有package的安裝資訊(ebuilds)以告訴portage怎麼樣編譯並安裝成千上萬種不同的軟體,在choort中運行 emerge --sync就能自動從GitHub clone一份portage樹到到電腦裡了:

(chroot) # emerge --sync
   Important

I如果你碰到了開頭帶有emerge --sync的錯誤訊息,基於git的通訊協定限制,將/etc/portage/make.confSYNC變數設定為"https://github.com/funtoo/ports-2012.git"以解決這個問題。

配置你的系統

就跟其他的Linux發行版一樣,Funtoo Linux也能進行系統配置,唯一 一個你必須修改的文件是/etc/fstab,以確保Funtoo可以正確的啟動,其他的配置則不一定需要變更。

使用Nano

nano是chroot環境裡的預設編輯器,要編輯下列的文件請依照以下的指示運行nano:

(chroot) # nano /etc/fstab

在編輯時,您可以使用方向鍵來移動光標,而backspace和delete等常用的按鍵的功能都和平時一樣。要儲存文件,按下Control-X,如果確定保存更改,則在提示"保存已修改緩衝區"時按y

配置文件

以下是你可能要編輯的完整文件列表,具體取決於你的需求:

File是否需要修改這個文件?Description
/etc/fstab YES - required 標記著所有掛載點的檔案系統,而這個檔案必須要對應到你的磁碟分割配置,在下面的章節中我們將會教你如何修該這個檔案。
/etc/localtime Maybe - recommended 時區,如果你沒有做設定的話,將會自動設為格林威治標準時間(UTC),應該指向/usr/share/zoneinfo目錄下面像是 /usr/share/zoneinfo/America/Montreal的代號。
/etc/make.conf (symlink) - 也可以是:
/etc/portage/make.conf
Maybe - recommended gcc(編譯器)、portage和make所採用的參數。而設定MAKEOPTS會是一個好主意,這這份教學之後的章節也會提到。 注意,一般來說在Funtoo Linux裡這個檔案會是空白的,因為許多的設定都已經被轉移到加強的profile系統裡了。
/etc/conf.d/hostname Maybe - recommended 用來設定系統的主機名稱。如果你擁有網域名稱的話,將hostname 設定為一個完全符合規定的名稱(有dot),像是:foo.funtoo.org,否則也可以設定成本地系統的主機名稱(沒有dot),例如:foo。預設值是 localhost
/etc/hosts No 你不再需要在這個檔案裡設定主機名稱,這個檔案由/etc/init.d/hostname自動生成。
/etc/conf.d/keymaps Optional 終端機的鍵位設定檔,如果你需要使用非英文布局鍵盤,請參考Funtoo Linux Localization來設定。
/etc/conf.d/hwclock Optional 設定系統將會以UTC還是本地時間來加載內建電池的硬體時鐘,系統在啟動時會去讀取硬體時鐘以初始化系統時間。
/etc/conf.d/modules Optional 設定要在啟動時自動加載的內核模塊,一般不需要修改。
/etc/conf.d/consolefont Optional 設定終端機所使用的字體,想要套用這個字體請先運行rc-update add consolefont來開啟consolefont服務。
profiles Optional portage的一些可能可以加快初步系統配置的設定。

如果你要安裝的是英文版的Funtoo Linux,那麼你很幸運,你幾乎不需要多加修改任何的設定檔,但如果你要使用的是其他語言,別擔心,我們會再Funtoo Linux Localization頁面帶你完成必要的的設定,如果需要,社群會提供很多有用而且友善的幫助(看看Community)

接著我們使用nano -w <name_of_file>來編輯檔案,加入"-w"參數是為了禁止長單詞自動換行,這點在編輯設定檔時非常方便,你可以直接從範例複製貼上。

   Warning

在重新啟動之前編輯/etc/fstab非常的重要!,你需要修改"fs"和"type"欄位以對應到那些使用gdisk或是fdisk建立的分割區及檔案系統。跳過這個步驟可能會導致Funtoo Linux無法啟動。

/etc/fstab

mount指令在系統啟動時會讀取/etc/fstab來確認各掛載點所使用的檔案系統,以及該如何掛載他們,為了使系統能夠正確的啟動,你必須確保/etc/fstab有對應到你的分割區配置,如果你忘記你剛剛怎麼分割硬碟的,lsblk指令也許可以幫到你。

(chroot) # nano -w /etc/fstab
   /etc/fstab - An example fstab file
# 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.
#
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# See the manpage fstab(5) for more information.
#
# <fs>	     <mountpoint>  <type>  <opts>         <dump/pass>

/dev/sda1    /boot         ext2    noauto,noatime 1 2
/dev/sda2    none          swap    sw             0 0
/dev/sda3    /             ext4    noatime        0 1
#/dev/cdrom  /mnt/cdrom    auto    noauto,ro      0 0
   Note

目前,/etc/fstab預設將/dev/sda4設為root檔案系統、swap 則是/dev/sda3,我們應該將他們分別設成/dev/sda3/dev/sda2

   Note

如果你使用UEFI開機,請將/dev/sda1那行的vfat改成ext2,同樣地/dev/sda3那行則要設成 xfsext4(決定於你先前的建立檔案系統時的設定)

/etc/localtime

/etc/localtime是用來指定你的電腦該使用哪個時區,預設值是UTC,如果你希望Funtoo Linux使用本地時間,把/etc/localtime,改成你想要用的那個符號連結。

(chroot) # ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime

The above sets the timezone to Mountain Standard Time (with daylight savings). Type ls /usr/share/zoneinfo to list available timezones. There are also sub-directories containing timezones described by location.

/etc/portage/make.conf

MAKEOPTS can be used to define how many parallel compilations should occur when you compile a package, which can speed up compilation significantly. A rule of thumb is the number of CPUs (or CPU threads) in your system plus one. If, for example, you have a dual core processor without hyper-threading, then you would set MAKEOPTS to 3:

MAKEOPTS="-j3" 

If you are unsure about how many processors/threads you have, then use nproc to help you.

(chroot) # nproc
16

Set MAKEOPTS to this number plus one:

MAKEOPTS="-j17"

USE flags define what functionality is enabled when packages are built. It is not recommended to add a lot of USE flags during installation; you should wait until you have a working, bootable system before changing your USE flags. A USE flag prefixed with a minus ("-") sign tells Portage not to use the flag when compiling. A Funtoo guide to USE flags will be available in the future. For now, you can find out more information about USE flags in the Gentoo Handbook.

LINGUAS tells Portage which local language to compile the system and applications in (those who use LINGUAS variable like OpenOffice). It is not usually necessary to set this if you use English. If you want another language such as French (fr) or German (de), set LINGUAS appropriately:

LINGUAS="fr"

/etc/conf.d/hwclock

If you dual-boot with Windows, you'll need to edit this file and change the value of clock from UTC to local, because Windows will set your hardware clock to local time every time you boot Windows. Otherwise you normally wouldn't need to edit this file.

(chroot) # nano -w /etc/conf.d/hwclock

Localization

By default, Funtoo Linux is configured with Unicode (UTF-8) enabled, and for the US English locale and keyboard. If you would like to configure your system to use a non-English locale or keyboard, see Funtoo Linux Localization.

Introducing Portage

Portage, the Funtoo Linux package manager has a command called emerge which is used to build and install packages from source. It also takes care of installing all of the package's dependencies. You call emerge like this:

(chroot) # emerge packagename

When you install a package by specifying its name in the command-line, Portage records its name in the /var/lib/portage/world file. It does so because it assumes that, since you have installed it by name, you want to consider it part of your system and want to keep the package updated in the future. This is a handy feature, since when packages are being added to the world set, we can update our entire system by typing:

(chroot) # emerge --sync
(chroot) # emerge -auDN @world

This is the "official" way to update your Funtoo Linux system. Above, we first update our Portage tree using git to grab the latest ebuilds (scripts), and then run an emerge command to update the world set of packages. The options specified tell emerge to:

  • a - show us what will be emerged, and ask us if we want to proceed
  • u - update the packages we specify -- don't emerge them again if they are already emerged.
  • D - Consider the entire dependency tree of packages when looking for updates. In other words, do a deep update.
  • N - Update any packages that have changed (new) USE settings.

You should also consider passing --with-bdeps=y when emerging @world, at least once in a while. This will update build dependencies as well.

Of course, sometimes we want to install a package but not add it to the world file. This is often done because you only want the package installed temporarily or because you know the package in question is a dependnecy of another package. If this behavior is desired, you call emerge like this:

(chroot) # emerge -1 packagename

Advanced users may be interested in the Emerge wiki page.

Updating World

Now is actually a very good time to update the entire system and it can be a good idea to do so prior to first boot.

(chroot) # emerge --sync
(chroot) # emerge -auDN @world
   Important

Make sure you read any post emerge messages and follow their instructions. This is especially true if you have upgraded perl or python.

Kernel

Starting mid-May 2015, Funtoo Linux stage3's include a pre-built debian-sources kernel to make installation faster and easier. To see if debian-sources is installed, type:

(chroot) # emerge -s debian-sources
Searching...    
[ Results for search key : debian-sources ]
[ Applications found : 1 ]

*  sys-kernel/debian-sources
      Latest version available: 3.19.3
      Latest version installed: 3.19.3
      Size of files: 81,292 kB
      Homepage:      http://www.debian.org
      Description:   Debian Sources (and optional binary kernel)
      License:       GPL-2

If a version is listed under Latest version installed, then debian-sources is already pre-built for you and you can skip the rest of the Kernel section, and proceed to the Installing a Bootloader section.

Building the Kernel

If you need to build a kernel for Funtoo Linux, please follow these steps:

   Note

See Funtoo Linux Kernels for a full list of kernels supported in Funtoo Linux. We recommend debian-sources for new users.

   Important

debian-sources with binary USE flag requires at least 14GB free in /var/tmp and takes around 1 hour to build on a Intel Core i7 Processor.

Let's emerge our kernel:

(chroot) # emerge debian-sources

Once emerge completes, you'll have a brand new kernel and initramfs installed to /boot, plus kernel headers installed in /usr/src/linux, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.

   Warning

If you have a RAID in your machine, the kernel installation will pull in the mdadm tool as a dependency. It is important to edit the /etc/mdadm.conf file prior to rebooting the machine so the RAID is properly recognised and set up before the kernel attempts to mount it in the tree. Failing to do so can result in an unusable or even unbootable system! For specific details, consult the mdadm man page man mdadm or the mdadm ebuild page.

   Note

NVIDIA card users: the binary USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under /etc/modprobe.d/.

   Note

For an overview of other kernel options for Funtoo Linux, see Funtoo Linux Kernels. There may be modules that the Debian kernel doesn't include, a situation where genkernel would be useful. Also be sure to see hardware compatibility information.

Installing a Bootloader

These install instructions show you how to use GRUB to boot using BIOS (old-school) or UEFI (new-school). As of boot-update-1.7.2, now in Portage, the steps are very similar.

First, emerge boot-update. This will also cause grub-2 and efibootmgr to be merged, since they are dependencies:

(chroot) # emerge boot-update

Then, edit /etc/boot.conf using nano and specify "Funtoo Linux genkernel" as the default setting at the top of the file, replacing "Funtoo Linux".

/etc/boot.conf should now look like this:

   /etc/boot.conf
boot {
	generate grub
	default "Funtoo Linux genkernel" 
	timeout 3 
}

"Funtoo Linux" {
	kernel bzImage[-v]
}

"Funtoo Linux genkernel" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto 
} 

"Funtoo Linux better-initramfs" {
	kernel vmlinuz[-v]
	initrd /initramfs.cpio.gz
}

If you are booting a custom or non-default kernel, please read man boot.conf for information on the various options available to you.

Old School (BIOS) MBR

When using "old school" BIOS booting, run the following command to install GRUB to your MBR, and generate the /boot/grub/grub.cfg configuration file that GRUB will use for booting:

(chroot) # grub-install --target=i386-pc --no-floppy /dev/sda
(chroot) # boot-update

New School (UEFI) Boot Entry

If you're using "new school" UEFI booting, run of the following sets of commands, depending on whether you are installing a 64-bit or 32-bit system. This will add GRUB as a UEFI boot entry.

For x86-64bit systems:

(chroot) # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

For x86-32bit systems:

(chroot) # grub-install --target=i386-efi --efi-directory=/boot --bootloader-id="Funtoo Linux [GRUB]" --recheck /dev/sda
(chroot) # boot-update

First Boot, and in the future...

OK -- you are ready to boot!

You only need to run grub-install when you first install Funtoo Linux, but you need to re-run boot-update every time you modify your /etc/boot.conf file or add new kernels to your system. This will regenerate /boot/grub/grub.cfg so that you will have new kernels available in your GRUB boot menu, the next time you reboot.

Configuring your network

It's important to ensure that you will be able to connect to your local-area network after you reboot into Funtoo Linux. There are three approaches you can use for configuring your network: NetworkManager, dhcpcd, and the Funtoo Linux Networking scripts. Here's how to choose which one to use based on the type of network you want to set up.

Wi-Fi

For laptop/mobile systems where you will be using Wi-Fi, roaming, and connecting to various networks NetworkManager is strongly recommended. Since Wi-Fi cards require firmware to operate, it is also recommended that you emerge the linux-firmware ebuild:

(chroot) # emerge linux-firmware networkmanager
(chroot) # rc-update add NetworkManager default

The above command will ensure that NetworkManager starts after you boot into Funtoo Linux. Once you've completed these installation steps and have booted into Funtoo Linux, you can use the nmtui command (which has an easy-to-use console-based interface) to configure NetworkManager so that it will connect (and automatically reconnect, after reboot) to a Wi-Fi access point:

root # nmtui

For more information about NetworkManager, see the NetworkManager package page.

   Note

wpa_supplicant is also a good choice for wireless network connections. See the net-wireless/wpa_supplicant package for steps involved in setting up wpa_supplicant.

Desktop (Wired DHCP)

For a home desktop or workstation with wired Ethernet that will use DHCP, the simplest and most effective option to enable network connectivity is to simply add dhcpcd to the default runlevel:

(chroot) # rc-update add dhcpcd default

When you reboot, dhcpcd will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.

If your upstream DHCP server is dnsmasq, it can be configured to assign addresses via mac address to make servers on DHCP feasible.

Server (Static IP)

For servers, the Funtoo Linux Networking scripts are recommended. They are optimized for static configurations and things like virtual ethernet bridging for virtualization setups. See Funtoo Linux Networking for information on how to use Funtoo Linux's template-based network configuration system.

Hostname

By default Funtoo uses "localhost" as hostname. Although the system will work perfectly fine using this name, some ebuilds refuse to install when detecting localhost as hostname. It also may create confusion if several systems use the same hostname. Therefore, it is advised to change it to a more meaningful name. The hostname itself is arbitrary, meaning you can choose almost any combination of characters, as long as it makes sense to the system administrator. To change the hostname, edit

(chroot) # nano /etc/conf.d/hostname

Look for the line starting with hostname and change the entry between the quotes. Save the file, on the next boot Funtoo will use the new hostname.

   Warning

Do not use special characters in the hostname, as the shell may interpret these, leading to unpredictable results. Use the Latin alphabet: a-z, A-Z, 0-9

   Tip

Use short hostnames (up to 8 or 10 characters) to prevent the terminal screen being filled with the hostname, leaving little space for the command itself. This become particularly poignant when coding long command strings in various programming languages like Bash, Python, SQL and Perl

Finishing Steps

Set your root password

It's imperative that you set your root password before rebooting so that you can log in.

(chroot) # passwd

Restart your system

Now is the time to leave chroot, to unmount Funtoo Linux partitions and files and to restart your computer. When you restart, the GRUB boot loader will start, load the Linux kernel and initramfs, and your system will begin booting.

Leave the chroot, change directory to /mnt, unmount your Funtoo partitions, and reboot.

(chroot) # exit
root # cd /mnt
root # umount -lR funtoo
root # reboot
   Note

System Rescue CD will gracefully unmount your new Funtoo filesystems as part of its normal shutdown sequence.

You should now see your system reboot, the GRUB boot loader appear for a few seconds, and then see the Linux kernel and initramfs loading. After this, you should see Funtoo Linux itself start to boot, and you should be greeted with a login: prompt. Funtoo Linux has been successfully installed!

Profiles

Once you have rebooted into Funtoo Linux, you can further customize your system to your needs by using Funtoo Profiles. A quick introduction to profiles is included below -- consult the Funtoo Profiles page for more detailed information. There are five basic profile types: arch, build, subarch, flavors and mix-ins:

Sub-Profile TypeDescription
archTypically x86-32bit or x86-64bit, this defines the processor type and support of your system. This is defined when your stage was built and should not be changed.
buildDefines whether your system is a current, stable or experimental build. current systems will have newer packages unmasked than stable systems. This is defined when your stage is built and is typically not changed.
subarchDefines CPU optimizations for your system. The subarch is set at the time the stage3 is built, but can be changed later to better settings if necessary. Be sure to pick a setting that is compatible with your CPU.
flavorDefines the general type of system, such as server or desktop, and will set default USE flags appropriate for your needs.
mix-insDefines various optional settings that you may be interested in enabling.

One arch, build and flavor must be set for each Funtoo Linux system, while mix-ins are optional and you can enable more than one if desired. Often, flavors and mix-ins inherit settings from other sub-profiles. Use epro show to view your current profile settings, in addition to any inheritance information:

(chroot) #  epro show

=== Enabled Profiles: ===

        arch:  x86-64bit
       build:  current
     subarch:  intel64-haswell
      flavor:  desktop
     mix-ins:  gnome


=== All inherited flavors from desktop flavor: ===

                     workstation (from desktop flavor)
                            core (from workstation flavor)
                         minimal (from core flavor)

=== All inherited mix-ins from desktop flavor: ===

                               X (from workstation flavor)
                           audio (from workstation flavor)
                             dvd (from workstation flavor)
                           media (from workstation flavor)
      mediadevice-audio-consumer (from media mix-in)
                mediadevice-base (from mediadevice-audio-consumer mix-in)
      mediadevice-video-consumer (from media mix-in)
                mediadevice-base (from mediadevice-video-consumer mix-in)
        mediaformat-audio-common (from media mix-in)
          mediaformat-gfx-common (from media mix-in)
        mediaformat-video-common (from media mix-in)
                  console-extras (from workstation flavor)
                           print (from desktop flavor)

Here are some basic examples of epro usage:

DescriptionCommand
View available profiles. Enabled profiles will be highlighted in cyan. Directly enabled profiles will be in bold and have a * appended.
(chroot) # epro list
Change the system flavor.
(chroot) # epro flavor desktop
Add a mix-in.
(chroot) # epro mix-in +gnome

Next Steps

If you are brand new to Funtoo Linux and Gentoo Linux, please check out Funtoo Linux First Steps, which will help get you acquainted with your new system. We also have a category for our official documentation, which includes all docs that we officially maintain for installation and operation of Funtoo Linux.

We also have a number of pages dedicated to setting up your system. See First Steps for a list of these pages.

If your system did not boot correctly, see Installation Troubleshooting for steps you can take to resolve the problem.