GentooLinux1.4 RC2硬碟安裝參考指南(第二修訂版)(轉)

post0發表於2007-08-09
GentooLinux1.4 RC2硬碟安裝參考指南(第二修訂版)(轉)[@more@]

你可以從任何一個Linux發行版下安裝Gentoo。

硬碟安裝Gentoo,只要下載一個stage3的tbz2包就行了(你是什麼CPU的就下相應的包).

×注:以下具體的資料都以你自己機器的實際情況為主×

用現有的Linux啟動登入至字元介面 (原有Linux啟動時root=/bin/bash引數可不加,經本人試驗,完全沒問題)

1.首先,開啟硬碟的DMA,用事先分好的區來安裝Gentoo Linux系統

#hdparm -c 1 -d 1 /dev/hda

我們把root分割槽格式化為reiserfs 檔案系統

#mkreiserfs /dev/hda8 (如果沒有mkreiserfs命令,那可能是你沒裝reiserfsprogs,可從這裡下載後編譯安裝 或從這裡下載

#mkswap /dev/hda10

#swapon /dev/hda10

2.掛裝分割槽到新建的目錄:

#mkdir /mnt/gentoo

#mount /dev/hda8 /mnt/gentoo

3.解壓stage3.放到gentoo的根分割槽也就是/mnt/gentoo (假設原stage3放在Mandrake根分割槽)

#cp /stage3-athlon-1.4_rc2.tbz2 /mnt/gentoo

#cd /mnt/gentoo

#tar -xvjpf stage3--athlon-1.4_rc2.tbz2(我用的是Duron你是什麼CPU的就下相應的包).

4.掛裝/proc分割槽以及cp resolv.conf檔案到Gentoo

Linux系統)

#mount -o bind /proc /mnt/gentoo/proc

#cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

5.進入chroot環境,升級Portage軟體列表及全面更新系統

#chroot /mnt/gentoo /bin/bash

#env-update

#source /etc/profile (真正進入Gentoo環境)

#emerge rsync (下載Portage軟體列表)

#nano -w /etc/make.conf (編輯make.conf ,最佳化Portage相關引數,主要是以下幾項)

a修改編譯針對CPU的編譯最佳化引數

# Host and optimization settings

# ==============================

#

# For optimal performance, enable a CFLAGS setting appropriate for your CPU

#

# -mcpu= means optimize code for the particular type of CPU without

# breaking compatibility with other CPUs.

#

# -march= means to take full advantage of the ABI and instructions

# for the particular CPU; this will break compatibility with older CPUs (for

# example, -march=athlon-xp code will not run on a regular Athlon, and

# -march=i686 code will not run on a Pentium Classic.

#

# CPU types supported in gcc-3.2 and higher: athlon-xp, athlon-mp, athlon-4,

# athlon-tbird, athlon, k6, k6-2, k6-3, i386, i486, i586 (Pentium), i686

# (PentiumPro), pentium, pentium-mmx, pentiumpro, pentium2 (Celeron), pentium3,

# and pentium4. Note that Gentoo Linux 1.4 and higher include at least gcc-3.2.

#

# CPU types supported in gcc-2.95*: k6, i386, i486, i586 (Pentium), i686

# (Pentium Pro), pentium, pentiumpro Gentoo Linux 1.2 and below use gcc-2.95*

#

# Decent examples:

#

CFLAGS="-mcpu=athlon-tbird -O3 -pipe"

CFLAGS="-march=athlon-tbird -O3 -pipe"(這是我的最佳化引數,你可以根據自己的CPU型別選擇不同的引數,詳情請參考下表)

×Safe flags to use for gentoo-1.4

Those flags are for gcc-3.x and alike (mostly gcc-3.0, gcc-3.1.1 and gcc-3.2), you may check which gcc you're using with the following command :

How to know your gcc version

#gcc --version

You can know which CPU you have with the following command :

How to know your CPU type

cat /proc/cpuinfo

This page is for those who don't want to experiment, want a stable system, but still optimized for their processor. Be careful, by using those flags, binaries from your system might not work on another one. So if you compiled with those flags optimized for p4, you cant send a tbz2 or share a hard disk with a friend who only has a pentium MMX.

i386 (Intel), do you really want to install gentoo on that ?

CHOST="i386-pc-linux-gnu"

CFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=i386 -O3 -pipe -fomit-frame-pointer"

i486 (Intel), do you really want to install gentoo on that ?

CHOST="i486-pc-linux-gnu"

CFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=i486 -O3 -pipe -fomit-frame-pointer"

Pentium 1 (Intel)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium -O3 -pipe -fomit-frame-pointer"

Pentium MMX (Intel)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=pentium-mmx -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium-mmx -O3 -pipe -fomit-frame-pointer"

Pentium PRO (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentiumpro -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentiumpro -O3 -pipe -fomit-frame-pointer"

Pentium II (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"

Celeron (Mendocino), aka Celeron1 (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium2 -O3 -pipe -fomit-frame-pointer"

Pentium III (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"

Celeron (Coppermine) aka Celeron2 (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer"

Celeron (Willamette?) (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"

Pentium 4 (Intel)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"

Eden C3/Ezra (Via)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=i586 -m3dnow -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=i586 -m3dnow -O3 -pipe -fomit-frame-pointer"

quote : the ezra doesn't have any special instructions that you could optimize for, just consider is a K6-3...basically a p2 with 3dnow

K6 (AMD)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=k6 -O3 -pipe -fomit-frame-pointer"

K6-2 (AMD)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=k6-2 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=k6-2 -O3 -pipe -fomit-frame-pointer"

K6-3 (AMD)

CHOST="i586-pc-linux-gnu"

CFLAGS="-march=k6-3 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=k6-3 -O3 -pipe -fomit-frame-pointer"

Athlon (AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer"

Athlon-tbird, aka K7 (AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon-tbird -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon-tbird -O3 -pipe -fomit-frame-pointer"

Athlon-tbird XP (AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

Athlon 4(AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon-4 -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon-4 -O3 -pipe -fomit-frame-pointer"

Athlon XP (AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

Athlon MP (AMD)

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=athlon-mp -O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-march=athlon-mp -O3 -pipe -fomit-frame-pointer"

603 (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

603e (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

604 (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

604e (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

750 aka as G3 (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-mcpu=750 -O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-mcpu=750 -O3 -pipe -fsigned-char -mpowerpc-gfxopt"

Note: do not use -march=

7400, aka G4 (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-mcpu=7400 -O2 -pipe -fsigned-char -maltivec

-mabi=altivec -mpowerpc-gfxopt"

CXXFLAGS="-mcpu=7400 -O2 -pipe -fsigned-char -maltivec

-mabi=altivec -mpowerpc-gfxopt"

-fsigned-char -maltivec -mabi=altivec -mpowerpc-gfxopt"

Note: do not use -march=

Note: -O3 is unstable on G4

7450, aka G4 second generation (PowerPC)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-mcpu=7450 -O2 -pipe -fsigned-char

-maltivec -mabi=altivec -mpowerpc-gfxopt"

CXXFLAGS="-mcpu=7450 -O2 -pipe -fsigned-char

-maltivec -mabi=altivec -mpowerpc-gfxopt"

Note: do not use -march=

Note: -O3 is unstable on G4

PowerPC (If you don't know which one)

CHOST="powerpc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

CXXFLAGS="-O3 -pipe -fsigned-char -mpowerpc-gfxopt"

Sparc

CHOST="sparc-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-O3 -pipe -fomit-frame-pointer"

Sparc 64

CHOST="sparc64-unknown-linux-gnu"

CFLAGS="-O3 -pipe -fomit-frame-pointer"

CXXFLAGS="-O3 -pipe -fomit-frame-pointer"

c emerge Gentoo Linux的最新unstable版本

# Advanced Masking

# ================

#

# Gentoo is using a new masking system to allow for easier stability testing

# on packages. KEYWORDS are used in ebuilds to mask and unmask packages based

# on the platform they are set for. A special form has been added that

# indicates packages and revisions that are expected to work, but have not yet

# been approved for the stable set. '~arch' is a superset of 'arch' which

# includes the unstable, in testing, packages. Users of the 'x86' architecture

# would add '~x86' to ACCEPT_KEYWORDS to enable unstable/testing packages.

# '~ppc', '~sparc', '~sparc64' are the unstable KEYWORDS for their respective

# platforms. DO NOT PUT ANYTHING BUT YOUR SPECIFIC ~ARCHITECTURE IN THE LIST.

# IF YOU ARE UNSURE OF YOUR ARCH, OR THE IMPLICATIONS, DO NOT MODIFY THIS.

#

ACCEPT_KEYWORDS="~x86"(去掉ACCEPT_KEYWORDS="~x86"前的註釋符即可)

b開啟PROZILLA的多執行緒下載功能,加快下載速度(在做這一步之前應該先emerge prozilla,這樣才能用prozilla來下載。如果是stage1,因為沒有c++編譯器,可以先不emerge prozilla和修改下面這一步,到stage2以後再改。)

# Fetching files

# ==============

#

# If you need to set a proxy for wget or lukemftp, add the appropriate "export

# ftp_proxy=" and "export http_proxy=" lines to /etc/profile if

# all users on your system should use them.

#

# Portage uses wget by default. Here are some settings for some alternate

# downloaders -- note that you need to merge these programs first before they

# will be available.

#

# Lukemftp (BSD ftp):

#FETCHCOMMAND="/usr/bin/lukemftp -s -a -o ${DISTDIR}/${FILE} ${URI}"

#RESUMECOMMAND="/usr/bin/lukemftp -s -a -R -o ${DISTDIR}/${FILE} ${URI}"

#

# Prozilla (turbo downloader)

FETCHCOMMAND='/usr/bin/proz --no-getch -s ${URI} -P ${DISTDIR}'

(請注意,b和c最佳化項在執行完emerge -u world系統更新命令前是沒有的,你可以把上述的內容cp到make.conf檔案裡稍做修改即可)

#emerge prozilla(因為stage3解壓的基本系統裡沒有prozilla命令,如果我們要使用多執行緒下載軟體包的話,就必需先把prozilla dwon下來)

#emerge -u world(全面更新系統,需要很長時間)

6.安裝編譯核心

#emerge gentoo-sources

#cd /usr/src/linux

#make menuconfig

#make dep

#make bzImage

#make modules

#make modules_install

#cp /usr/src/linux/System.map /boot/System.map-2.4.20

#cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.20

(關於2.4核心的詳悉配置方法,請參閱以下文章 http://www.tldp.org/linuxfocus/Chin...rticle252.shtml

7.安裝vcron和metalog以及update modules

#emerge vcron

#rc-update add vcron default

#emerge metalog

#rc-update add metalog default

#update-modules

8.安裝ADSL撥號軟體。

#emerge ppp

#USE="-X" emerge rp-pppoe (因為rp-pppoe和xfree 等X軟體包存在倚賴關係,我們要先在字元環境下使用,就要用USE="-X" 引數來安裝rp-pppoe)

9.設定時區和Host主機名

#cd /usr/share/zoneinfo/Asia

#ln –sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#nano –w /etc/hostname

10.加入檔案系統工具(如果是使用ext2或ext3,可以忽略這一步,系統自帶了e2fsprogs)

#emerge reiserfsprogs

11.在Gentoo Linux系統裡開啟硬碟的DMA

#nano -w /etc/conf.d/local.start

在檔案末尾加上 hdparm -c 1 -d 1 /dev/hda

12.設定root使用者密碼

#passwd

13.修改/etc/fstab檔案,以符合你實際的分割槽情況,這是我的fstab檔案,參考一下:)

#nano -w /etc/fstab

#

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/ROOT / reiserfs noatime 0 0

/dev/SWAP none swap sw 0 0

/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,owner,ro,iocharset=cp936 0 0 0 0

proc /proc proc defaults 0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for

# POSIX shared memory (shm_open, shm_unlink). Adding the following

# line to /etc/fstab should take care of this:

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will use almost no

# memory if not populated with files)

tmpfs /dev/shm tmpfs defaults 0 0

/dev/hda1 /winc vfat defaults,rw,iocharset=cp936 0 0

/dev/hda5 /wind vfat defaults,rw,iocharset=cp936 0 0

dev/hda6 /wine ntfs defaults,rw,iocharset=cp936 0 0

/dev/hda7 /winf ntfs defaults,rw,iocharset=cp936 0 0

#mkdir /iwnc /wind /wine /winf(根據自己機器的情況載入windows分割槽)

qing兄補充道:

quote:修改/etc/fstab檔案很重要的

ROOT

BOOT

SWAP

都換成你具體的分割槽

在啟動時

若出現Activating swap [ok]

這是假相

並沒有載入swap分割槽

要出現

Activating swap xxxxxxxk -swap space [ok]

xxxxxx是具體數字,才是真的載入了swap分割槽

說這麼多的目的是,SWAP很重要

14.配置Grub,以便啟動系統。

#nano -w grub.conf (建立Grub啟動列表檔案)

以下是我的menu.lst

default 0

timeout 30

splashimage=(hd0,7) /boot/grub/splash.xpm.gz

title Mandrake Linux 9.0 (Kernel-2.4.19-16mdk)

root (hd0,8)

kernel (hd0,8) /boot/vmlinuz root=/dev/hda9 quiet devfs=mount hdc=ide-scsi vga=788

initrd (hd0,8) /boot/initrd.img

title Gentoo Linux 1.4 RC2 (Kernel-2.4.20gentoo)

root (hd0,7)

kernel /boot/vmlinuz-2.4.20gentoo ro root=/dev/hda8 hdc=ide-scsi

#cp /usr/share/grub/i386-pc/* /boot/grub (cp升級過的grub的stage檔案到/boot/grub目錄)

#grub (配置Grub,讓Grub寫入MBR,管理整個機器裡所有系統的啟動)

grub> root (hd0,7) (指定root分割槽位置)

grub> kernel /boot/vmlinuz-2.4.20gentoo ro root=/dev/hda8 hdc=ide-scsi (指定系統核心的位置以及加入其他引數選項)

grub>setup (hd0) (寫入MBR)

grub>quit (退出)

15.進入Gentoo Linux字元環境,配置ADSL。

#adsl-setup

//以下是螢幕顯示:

Welcome to the Roaring Penguin ADSL client setup. First, I will run some checks on your system to make sure the PPPoE client is installed properly...

Looks good! Now, please enter some information:

USER NAME

>>> Enter your PPPoE user name :

輸入連入寬頻網的賬號

>>> Enter the Ethernet interface connected to the ADSL modem

For Linux, it will be ethn, where 'n' is a number.

(default eth0):

輸入準備接入網際網路的網路卡名,如果是預設的就直接敲Enter鍵。

>>> Enter the demand value (default no):

直接回車。

DNS

>>> Enter the DNS information here:

輸入有服務商提供的域名伺服器地址,或輸入server,由服務商自動提供。

PASSWORD

>>> Please enter your PPPoE password:

>>> Please re-enter your PPPoE password:

輸入上網密碼。

FIREWALLING

>>> Choose a type of firewall (0-2):

選擇防火牆,選0。

** Summary of what you entered **

Ethernet Interface: eth0

User name: xxxx //你的使用者名稱

Activate-on-demand: No

DNS: server

Firewalling: NONE

>>> Accept these settings and adjust configuration files (y/n)?

最後,對上述配置進行確認。確認後的配置系統會寫入/etc/ppp/pppoe.conf檔案,熟練的使用者可直接對其進行修改。

撥號

配置完成後,就可以進行撥號了。

#adsl-start

如果螢幕上出現:“... Connected!”就說明撥號成功了。一般而言做到這一步是沒什麼問題的。這時可以用ifconfig命令檢視,結果除了原本有的eth0、lo外又增添了ppp0。

13.安裝配置最新的XFree和KDE3

#emerge xfree qt arts

#USE="-gnome -gtk" emerge kdelibs kdebase (去掉gnome和gtk以及多餘kde元件的支援,安裝最小化的KDE)

#xf86config (檢測配置XFree86,根據自己具體配置選擇,配置完畢會在/etc/X11/下生成XF86Config )

#echo "exec startkde" > ~/.xinitrc (讓我們直接用startx命令進入KDE而不是原來的twm)

儲存修改退出後,用startx命令就可以進入KDE了。

#reboot

OK,Gentoo現在就落戶你的硬碟了.Enjoy Your

Gento

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-938160/,如需轉載,請註明出處,否則將追究法律責任。

相關文章