歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> GentooLinux1.4 RC2硬盤安裝參考指南(第二修訂版)

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

日期:2017/2/27 14:18:35   编辑:更多Linux
  你可以從任何一個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,可從這裡下載後編譯安裝 http://www.namesys.com/pub/reiserfs...gs-3.6.4.tar.gz 或從這裡下載 http://rpmseek.com/download/mandrak...l=com&nid=11766 ) #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=<cpu-type> means optimize code for the particular type of CPU without # breaking compatibility with other CPUs. # # -march=<cpu-type> 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=<proxy>" and "export http_proxy=<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 # <fs> <mountpoint> <type> <opts> <dump/pass> # 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 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 Gentoo



Copyright © Linux教程網 All Rights Reserved