歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> 更多Linux

Gentoo Linux實戰!

  一、為什麼要用Gentoo: Linux?在這裡:[url]http://www.linuxsir.com/bbs/showthread.PHP?s=&threadid=15399 [/url]有一個討論。對我個人而言,我是一個軟件的“版本狂”,只要有什麼新的我喜歡的軟件或軟件版本出來,我都會馬上去DOWNLOAD下來裝上試試,也因此經常為找一些關聯的包而大傷腦筋。而這個正好是GENTOO的常項,它是從網上DOWNLOAD源碼下來編譯,而且更新很快,並且它的可以自己解決包的關聯。以前我也裝過幾次,但是都不是很理想,這次決定重頭再來!!! [注:我選擇的是從別的Linux系統下安裝,關於別的安裝方法:http://www.linuxsir.com/bbs/showthread.php?s=&threadid=23311] 級別: 大天使 注冊時間: 2002-05-24 最後登錄: 2003-10-08 帖子總數: 1878 精華帖子: 32 原創精華: 2 在線狀態: ...離線... 發表於: 2003-06-11 11:06 發表主題: 二、安裝基本系統: [其過程主要參照: http://www.linuxsir.com/bbs/showthread.php?s=&threadid=11918 ] 1,下載最新的包1.4RC4: http://distro.ibiblio.org/pub/linux/distributions/gentoo/releases/1.4_rc4/x86/x86/stages/stage3-x86-1.4_rc4.tar.bz2 2,用現有的Linux啟動登錄至字符界面,打開硬盤的DMA,用事先分好的區來安裝Gentoo Linux系統 代碼: #hdparm -c 1 -d 1 /dev/hda 我們把root分區格式化為reiserfs 文件系統 #mkreiserfs /dev/hda7 [如果想用EXT3:mke2fs -j /dev/hda7] #mkswap /dev/hda3 #swapon /dev/hda3 2.掛裝分區到新建的目錄: 代碼: #mkdir /mnt/gentoo #mount /dev/hda7 /mnt/gentoo 3.解壓stage3放到gentoo的根分區也就是/mnt/gentoo (假設原stage3放在Mandrake根分區) 代碼: #cp /stage3-x86-1.4_rc4.tar.bz2 /mnt/gentoo #cd /mnt/gentoo #tar -xvjpf stage3-x86-1.4_rc4.tar.bz2 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的編譯優化參數 代碼: CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer" CXXFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer" (這是我的優化參數,你可以根據自己的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" b. emerge Gentoo Linux的最新unstable版本 [仍然是修改/etc/make.conf] 代碼: # 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"前的注釋符即可) 6,打開PROZILLA的多線程下載功能,加快下載速度: 代碼: #emerge prozilla [下載安裝prozilla] #nano -w /etc/make.conf 代碼: # 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}' #[去掉前面的#] 代碼: #nano /etc/prozilla.conf [配置prozilla,把這一行threads改為=10,十線程下載, ftpsearch=OFF (不自動搜索下載鏡像)] 7,#emerge -u world [全面更新系統,需要很長時間,好了,先休息一會吧] 遇到問題: emerge -u world報錯! 到procps時報連接錯誤,? 以前也遇到過類似問題,一般過一兩天再重新emerge rsync一下,再繼續往下做就可以了,因為GENTOO更新很快! [繼續往下走, ] 8,安裝編譯內核 代碼: #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/ChineseGB/July2002/article252.sHtml ] 我是直接從網上DOWN下來的最新內核源碼來編譯的(2.4.21-rc3) 9,安裝vcron和metalog以及update modules 代碼: #emerge vcron #rc-update add vcron default #emerge metalog #rc-update add metalog default #update-modules 11,設置時區和Host主機名 代碼: #cd /usr/share/zoneinfo/Asia #ln –sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #nano –w /etc/hostname 12,加入文件系統工具(如果是使用ext2或ext3,可以忽略這一步,系統自帶了e2fsprogs) 代碼: #emerge reiserfsprogs 在Gentoo Linux系統裡打開硬盤的DMA 代碼: #nano -w /etc/conf.d/local.start 在文件末尾加上 hdparm -c 1 -d 1 /dev/hda 設置root用戶密碼 代碼: #passwd 13.修改/etc/fstab文件,以符合你實際的分區情況,這是我的fstab文件,參考一下:) 代碼: #nano -w /etc/fstab 代碼: # /etc/fstab: static file system information. # # <file system><mount point><type><options><dump><pass> /dev/hda7/reiserfsnoatime 0 0 none /dev/pts devpts mode=0620 0 0 none /mnt/cdrom supermount dev=/dev/hdb,fs=auto,ro,--,iocharset=gb2312,codepage= 936,umask=0 0 0 none /mnt/floppy supermount dev=/dev/fd0,fs=auto,--,iocharset=gb2312,sync,codepa

ge=936,umask=0 0 0 /dev/hda1 /mnt/win_c ntfs iocharset=gb2312,ro,umask=0 0 0 /dev/hda6 /mnt/win_d vfat iocharset=gb2312,codepage=936,umask=0 0 0 /dev/hda9 /mnt/win_e vfat iocharset=gb2312,codepage=936,umask=0 0 0 none /proc proc defaults 0 0 /dev/hda3 swap swap defaults 0 0 代碼: #mkdir /iwnc /wind /wine /winf(根據自己機器的情況加載windows分區) 代碼: 14,配置Grub,以便啟動系統。 代碼: #emerge grub #cp /usr/share/grub/i386-pc/* /boot/grub (cp升級過的grub的stage文件到/boot/grub目錄 #nano -w /boot/grub/menu.lst (建立Grub啟動列表文件) 以下是我的menu.lst 代碼: # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that #all kernel and initrd paths are relative to /, eg. #root (hd0,1) #kernel /boot/vmlinuz-version ro root=/dev/hda2 #initrd /boot/initrd-version.img #boot=/dev/hda default=1 timeout=10 splashimge=(hd0,7)/boot/grub/splash.xpm.gz title Windows XP rootnoverify (hd0,0) chainloader +1 title Mandrake Linux kernel /boot/vmlinuz ro root=/dev/hda5 initrd /boot/initrd.img title Gentoo Linux (hda8) root (hd0,7) kernel /boot/vmlinuz-2.4.21-rc3 ro root=/dev/hda8 title Gentoo Linux (hda7) root (hd0,6) kernel /boot/vmlinuz-2.4.21-rc3 ro root=/dev/hda7 代碼: #grub (配置Grub,讓Grub寫入MBR,管理整個機器裡所有系統的啟動) grub> root (hd0,7) (指定root分區位置) grub>quit (退出) 15,配置網絡 a. 首先你在編譯內核時要選擇相應的模塊,要想加載內核模塊: 代碼: #nano -w /etc/modules.autoload 這是我的 代碼: # /etc/modules: kernel modules to load at boot time. # # This file should contain the names of kernel modules that are # to be loaded at boot time, one per line. Comments begin with # a "#", and everything on the line after them are ignored. usbcore rtl8150 usbmouse usbkbd usb-uhci hid input keybdev usbnet mousedev ac97_codec i810_audio b. 編輯/etc/conf.d/net在這裡填入IP、NETMASK,BROADCAST,GATEWAY 這是我的 代碼: # /etc/conf.d/net: # $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 1 9:39:22 azarah Exp $ # Global config file for net.* rc-scripts # This is basically the ifconfig argument without the ifconfig $iface # iface_eth0="192.168.0.2 broadcast 192.168.0.255 netmask 255.255.255.0" #iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp" # For passing options to dhcpcd use dhcpcd_eth? # #iface_eth0="dhcp" #dhcpcd_eth0="..." # For adding aliases to a interface # #alias_eth0="192.168.0.3 192.168.0.4" # NB: The next is only used for aliases. # # To add a custom netmask/broadcast address to created aliases, # uncomment and change accordingly. Leave commented to assign # defaults for that interface. # #broadcast_eth0="192.168.0.255 192.168.0.255" #netmask_eth0="255.255.255.0 255.255.255.0" # For setting the default gateway # #gateway="eth0/192.168.0.1" iface_eth0="192.9.168.42 broadcast 192.9.168.255 netmask 255.255.255.0" gateway="eth0/192.9.168.83" 編輯/etc/resolv.conf在這裡填入DNS的信息: 代碼: # cat /etc/resolv.conf nameserver 192.9.168.83 代碼: #rc-update add net.eth0 default 好了,這個時候你可以重新啟動,進入你的新系統了!!! 二、安裝FTP和opessh a. 安裝openssh 代碼: emerge openssh rc-update add sshd default b. 安裝FTP: 代碼: emerge xinetd rc-update add xinetd default emerge vsftpd 編輯/etc/xinetd.d/vsftpd文件, 把最後面的disable改為no, 再加上這一行:only_from = 0.0.0.0 編輯/etc/xinetd.d/vsftpd文件, 把最後面的disable改為no, 再加上這一行:only_from = 0.0.0.0 編輯/etc/vsftpd/vsftpd.conf 最後重新啟動inetd:/etc/init.d/xinetd restart 三、桌面軟件的安裝與設置 1,安裝配置最新的XFree和Gnome 代碼: #emerge xfree gnome #xf86config (檢測配置XFree86,根據自己具體配置選擇,配置完畢會在/etc/X11/下生成XF86Config ) #echo "exec gnome-session" > ~/.xinitrc (讓我們直接用startx命令進入Gnome而不是原來的twm) 保存修改退出後,用startx命令就可以進入Gnome了。 如果要用KDE: #emerge xfree qt arts #USE="-gnome -gtk" emerge kdelibs kdebase (去掉gnome和gtk以及多余kde組件的支持,安裝最小化的KDE) #xf86config #echo "exec startkde" > ~/.xinitrc 好了,這又是一個漫長的過程!!!



9:39:22 azarah Exp $ # Global config file for net.* rc-scripts # This is basically the ifconfig argument without the ifconfig $iface # iface_eth0="192.168.0.2 broadcast 192.168.0.255 netmask 255.255.255.0" #iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0" # For DHCP set iface_eth? to "dhcp" # For passing options to dhcpcd use dhcpcd_eth? # #iface_eth0="dhcp" #dhcpcd_eth0="..." # For adding aliases to a interface # #alias_eth0="192.168.0.3 192.168.0.4" # NB: The next is only used for aliases. # # To add a custom netmask/broadcast address to created aliases, # uncomment and change accordingly. Leave commented to assign # defaults for that interface. # #broadcast_eth0="192.168.0.255 192.168.0.255" #netmask_eth0="255.255.255.0 255.255.255.0" # For setting the default gateway # #gateway="eth0/192.168.0.1" iface_eth0="192.9.168.42 broadcast 192.9.168.255 netmask 255.255.255.0" gateway="eth0/192.9.168.83" 編輯/etc/resolv.conf在這裡填入DNS的信息: 代碼: # cat /etc/resolv.conf nameserver 192.9.168.83 代碼: #rc-update add net.eth0 default 好了,這個時候你可以重新啟動,進入你的新系統了!!! 二、安裝FTP和opessh a. 安裝openssh 代碼: emerge openssh rc-update add sshd default b. 安裝FTP: 代碼: emerge xinetd rc-update add xinetd default emerge vsftpd 編輯/etc/xinetd.d/vsftpd文件, 把最後面的disable改為no, 再加上這一行:only_from = 0.0.0.0 編輯/etc/xinetd.d/vsftpd文件, 把最後面的disable改為no, 再加上這一行:only_from = 0.0.0.0 編輯/etc/vsftpd/vsftpd.conf 最後重新啟動inetd:/etc/init.d/xinetd restart 三、桌面軟件的安裝與設置 1,安裝配置最新的XFree和Gnome 代碼: #emerge xfree gnome #xf86config (檢測配置XFree86,根據自己具體配置選擇,配置完畢會在/etc/X11/下生成XF86Config ) #echo "exec gnome-session" > ~/.xinitrc (讓我們直接用startx命令進入Gnome而不是原來的twm) 保存修改退出後,用startx命令就可以進入Gnome了。 如果要用KDE: #emerge xfree qt arts #USE="-gnome -gtk" emerge kdelibs kdebase (去掉gnome和gtk以及多余kde組件的支持,安裝最小化的KDE) #xf86config #echo "exec startkde" > ~/.xinitrc

好了,這又是一個漫長的過程!!!



Copyright © Linux教程網 All Rights Reserved