一、为什么要用Gentoo:
Linux?在这里:http://www.linuxsir.com/bbs/showthread.php?s=&threadid=15399 有一个讨论。对我个人而言,我是一个软件的“版本狂”,只要有什么新的我喜欢的软件或软件版本出来,我都会马上去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
好了,这又是一个漫长的过程