您的位置:首页 > 运维架构 > Linux

Gentoo Linux安装详解--根据官方WiKi整理

2014-06-25 16:34 375 查看

1. 前期准备

远程登录:

开启ssh服务:

/etc/init.d/sshd start
设置密码:

passwd
以便使用putty、ssh client远程登录上传stage等(有时在线下载很慢,而局域网上传很快)

准备磁盘:

分区:

fdisk /dev/sda
/dev/sda1 : /boot 100M(32-100M) 设启动笔记-a
/dev/sda2 : / 20G
/dev/sda3 : /home 20G
/dev/sda5 : /swap 1G (内存< 512 MB,分区分配2倍内存大小的空间;> 1024 MB,可以分配较少的空间甚至不需要swap 分区。)-t 82创建文件系统:

mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3
mkswap /dev/sda5
挂载分区:

mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount /dev/sda3 /mnt/gentoo/home
swapon /dev/sda5

2. 安装系统

安装stage及portage:

正确设置日期/时间:

date
如果显示的日期/时间不正确,可以使用date MMDDhhmmYYYY命令下载Stage3 Tarbll:

cd /mnt/gentoo
links http://www.gentoo.org/main/en/mirrors.xml[/code]选择国内速度较快的镜像,进入releases/x86/autobuilds/目录里。你将会看到所有适合你的计算机体系结构的stage文件(它们也可能放在各个独立的子体系名称的子目录里)。选择一个,然后按D来下载。下载完以后,再按Q退出浏览器。或使用SSH Secure Shell登录上传stage3文件解开Stage3 Tarball:

tar xvjpf stage3-*.tar.bz2
下载Portage:
打开links(或者lynx)然后到我们的Gentoo镜像列表。选择一个离你最近的镜像,打开snapshots/目录。然后选择最新的Portage快照(portage-latest.tar.bz2)并按D来下载它。

links http://www.gentoo.org/main/en/mirrors.xml[/code]或使用SSH Secure Shell登录上传portage文件解压Portage:

tar -xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr (install a Portage snapshot)

编译前准备:

配置编译选项:

nano -w /mnt/gentoo/etc/portage/make.conf
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}" # 两个变量使用相同的设置
MAKEOPTS="-j3" #MAKEOPTS定义在安装软件的时候同时可以产生并行编译的数目,CPU数目加一是个不错的选择查看cpu信息:
cat proc/cpuinfo
选择镜像站点:

mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
拷贝DNS信息:

cp -L /etc/resolv.conf /mnt/gentoo/etc/

3. Chroot进入新系统环境:

Chroot:

挂载 /proc, /dev, /sys文件系统:

mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
进入新的系统环境:

chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"

新环境配置:

更新portage树:

emerge --sync (Updating the Portage tree)
或
emerge-webrsync(fetch the latest portage snapshot)
选择Profile:

eselect profile list
eselect profile set ×
设置时区:

ls /usr/share/zoneinfo
echo "Europe/Brussels" > /etc/timezone
emerge --config sys-libs/timezone-data
设置locale:

nano -w /etc/locale.gen
locale-gen
更新环境变量:

env-update && source /etc/profile

4. 编译内核:

安装内核源码:
选择内核:如gentoo-sources

emerge gentoo-sources
ls -l /usr/src/linux

手动编译内核:

cd /usr/src/linux
make menuconfig
必须启用的选项:
显卡:Xorg/Configuration
声卡:ALSA
网卡:根据具体网卡芯片型号,查看wiki。
网卡芯片驱动查询:Linux Wireless
其他选项根据需要添加,不了解保持默认即可:
编译内核与模块:

make && make modules_install
拷贝内核到启动分区:

cp arch/x86_64/boot/bzImage /boot/kernel-3.10.10-gentoo

使用genkernel编译内核:

emerge genkernel
可选:复制安装光盘上的内核配置文件:

zcat /proc/config.gz > /usr/share/genkernel/arch/x86_64/kernel-config
编译:

genkernel --menuconfig all
一旦genkernel运行完成,一个包括全部模块和initrd的内核将被建立。在后面配置引导程序时我们将会用到这个内核和initrd。请记下内核和 initrd的名字,因为您将在配置引导程序的时候用到他们。initrd将会在启动真正的系统前自动识别硬件(如同安装光盘一样)。
ls /boot/kernel* /boot/initramfs*

5. 配置系统

系统信息:

文件系统信息:
创建/etc/fstab

nano -w /etc/fstab
网络信息:

Host name, Domainname, etc
nano -w /etc/conf.d/hostname
Configuring Network
nano -w /etc/conf.d/net
系统信息:

Gentoo uses /etc/rc.conf to configure the services, startup, and shutdown of your system.
nano -w /etc/rc.conf
Root Password
passwd
Gentoo uses /etc/conf.d/hwclock to set clock options.
nano -w /etc/conf.d/hwclock

安装系统工具软件:

可选:PCMCIA使用lspci查看硬件信息:

emerge pcmciautils
System Logger:

emerge syslog-ng
rc-update add syslog-ng default
可选:File Indexing:

emerge mlocate
可选:Remote Access:

rc-update add sshd default
可选:DHCP Client:

emerge dhcpcd

配置启动项:

Using GRUB2:

emerge sys-boot/grub
grub2-install /dev/sda
Generating GRUB2 configuration:
grub2-mkconfig -o /boot/grub/grub.cfg
可选:Using GRUB Legacy:

emerge sys-boot/grub:0
编辑配置文件:
nano -w /boot/grub/grub.conf
Example grub.conf:
# 默认选择哪个列表来引导。0表示第一个, 1表示第二个,以此类推。
default 0
# 引导默认列表前等待多少秒
timeout 30
# 使用漂亮、“臃肿”的spalsh图像来增加一点趣味:)
# 如果您没有安装显卡,请将这行注释掉
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo Linux 3.10.10
# 内核镜像(或者操作系统)所在分区
root (hd0,0)
kernel /boot/kernel-3.10.10-gentoo root=/dev/sda2

title Gentoo Linux 3.10.10 (rescue)
# 内核镜像(或者操作系统)所在分区
root (hd0,0)
kernel /boot/kernel-3.10.10-gentoo root=/dev/sda2 init=/bin/bb

# 接下来的四行只有在您与Windows系统进行双启动的情况下才需要。
# 本例中,windows系统位于/dev/sda6。
title Windows XP
rootnoverify (hd0,5)
makeactive
chainloader +1

#win7***释掉makeactive
Setting up GRUB using grub-install:
Creating /etc/mtab:
grep -v rootfs /proc/mounts > /etc/mtab
Install GRUB:
grub-install --no-floppy /dev/sda

重启系统:

exit
cd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -l /mnt/gentoo{/boot,/proc,}
reboot

6. 安装X桌面环境:

安装Xorg:

检测显卡信息:

dmesg | grep video
lspci  | grep -i VGA
配置INPUT_DEVICE、VIDEO_CARDS变量:
在安装Xorg之前,你需要在/etc/portage/make.conf文件中设置两个重要的变量。

(For mouse, keyboard, and Synaptics touchpad support)
INPUT_DEVICE="evdev  synaptics"
(对nVidia显卡)
VIDEO_CARDS="nvidia"
(或,对ATI Radeon显卡)
VIDEO_CARDS="radeon"
(VMware虚拟机)
VIDEO_CARDS="vmware"
(VirtualBox虚拟机)
VIDEO_CARDS="virtualbox"
安装xorg-server“

emerge -pv xorg-drivers
First of all, make sure udev is in your USE flags:
echo "x11-base/xorg-server udev" >> /etc/portage/package.use
注:现在比较新的版本的Xorg(大概是 1.5 以后的吧) 使用 evdev 替换了 keyboard 和 mouse ,确保 udev 标记在安装 xorg-server 时被启用。Next, install Xorg:
emerge -av xorg-server
更新环境变量:

env-update
source /etc/profile
使用startx:
安装 twm 和 xterm 之后 执行 startx 测试 X 是否正常。
测试正常之后可以删除 twm 和 xterm。

emerge -v twm xterm
startx

安装桌面环境:

lxde:
awesome:

本文出自 “博主:孤逐王” 博客,请务必保留此出处http://aceking.blog.51cto.com/3681913/1430801
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: