Linux下用VirtualBox,Win7下用VM装了两遍,都是内核装完,X Window 没有装上。
最好按照官方英文版手册安装,好多地方都不同
使用Mini CD,网络安装。
1、账户准备
passwd
useradd test
passwd test
/etc/init.d/sshd start 使得可以远程登录安装
2、网络准备
3、硬盘准备net-setup eth0 虚拟网络类型选择 NAT
不知为何,Linux的virtualbox下还需自行设定DNS服务器
nano /etc/resolve.conf
5、安装stage及portagefdisk /dev/sda
n ->p -> 1 -> 回车 - > +32M
n- >p -> 2 -> 回车 - > +512M
n ->p -> 3 -> 回车 -> 回车
新版还介绍了一种新的分区方式
parted /dev/sda
print查看分区情况 mklabel gpt 设置 rm 2 删除第二个分区
mkpart primary ext2 0 32mb
mkpart primary linux-swap 32mb 542mb
mkpart primary ext4 542mb -1s
建立文件系统
mkfs.ext2 /dev/sda1
mkfs.ext3 /dev/sda3
mkswap /dev/sda2
swapon /dev/sda2
cd /mnt/gentoo
links http://mirrors.163.com/gentoo 选择下载最新stage
tar -xvjpf stage3.-*.tar.bz2
links http://mirrors.163..com/gentoo 在snapshot中选择下载最新portage
6、设置编译选项tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
7、更换root空间CFLAGS="-O2 -march=i686 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j4" 给虚拟机分了四个核
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf选择镜像
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
8、设置Portagecp -L /etc/resolv.conf /mnt/gentoo/etc/ 复制DNS
mount -t proc none /mnt/gentoo/proc 挂载文件系统
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash 更改Root空间
env-update
>> Regenerating /etc/ld.so.cache...
source /etc/profile
export PS1="(chroot) $PS1"
emerge --sync 更新emerge
eselect profile list 列出profile
eselect profile set 3 选择一个desktop类型
nano -w /etc/portage/make.conf 更改USE
USE="-gtk -gnome qt4 kde dvd alsa cdr"
9、安装内核源文件
设置时区
安装内核源文件
Code Listing 1.1: Setting the timezone information
# ls /usr/share/zoneinfo (Suppose you want to use Europe/Brussels) # cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime (Next set the timezone) # echo "Europe/Brussels" > /etc/timezone
查看内核版本
de Listing 2.1: Installing a kernel source
# emerge gentoo-sources
Code Listing 2.2: Viewing the kernel source symlink
# ls -l /usr/src/linux lrwxrwxrwx 1 root root 12 Oct 13 11:04 /usr/src/linux -> linux-3.3.8
10、编译内核
开始是手动配置的内核
10、设置系统信息
Code Listing 3.1: Invoking menuconfig
# cd /usr/src/linux # make menuconfig
Code Listing 3.9: Compiling the kernel
# make && make modules_install
Code Listing 3.10: Installing the kernel
# cp arch/x86/boot/bzImage /boot/kernel-3.5.7-gentoo
后来发现虚拟机里显卡不好使,又用的自动工具
emerge genkernel
genkernel all
ls /boot 查看安装的内核
文件系统
nano -w /etc/fstab
机器名
Code Listing 1.3: A full /etc/fstab example
/dev/sda1 /boot ext2 defaults,noatime 0 2 /dev/sda2 none swap sw 0 0 /dev/sda3 / ext3 noatime 0 1 /dev/cdrom /mnt/cdrom auto noauto,user 0 0nano -w /etc/conf.d/hostname
hostname="test-gentoo"
网络设置
nano -w /etc/conf.d/net
config_eth0="dhcp“ 并设置为自动运行
# cd /etc/init.d # ln -s net.lo net.eth0 # rc-update add net.eth0 default账户设置
passwd
useradd ...
passwd ...
本地化
nano -w /etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GBK
zh_CN.UTF-8 UTF-8
locale-gen 更新本地信息
执行以下两步后,系统提示信息出现乱码
11、安装系统工具
Code Listing 3.8: Setting the default system locale in /etc/env.d/02locale
LANG="zh_CN.UTF-8" LC_COLLATE="C"
Code Listing 3.9: Reload shell environment
# env-update && source /etc/profile
Code Listing 1.1: Installing a system logger
# emerge syslog-ng # rc-update add syslog-ng default
Code Listing 2.1: Installing a cron daemon
# emerge vixie-cron # rc-update add vixie-cron default
Code Listing 3.1: Installing mlocate、
# emerge mlocate
Code Listing 6.1: Installing dhcpcd
# emerge dhcpcd
12、安装Grub
13、退出重启emerge grub
nano -w /boot/grub/grub.conf
title Gentoo Linux 3.3.8 root (hd0,0) kernel /boot/3.5.7 real_root=/dev/sda3 initrd /boot/initramfs-genkernel-x86-3.5.7-gentoo
Code Listing 2.5: Creating /etc/mtab
# grep -v rootfs /proc/mounts > /etc/mtab
Code Listing 2.6: Running grub-install
# grub-install --no-floppy /dev/sda
Code Listing 4.1: Unmounting all partitions and rebooting
# exit cdimage ~# cd cdimage ~# umount -l /mnt/gentoo/dev{/shm,/pts,} cdimage ~# umount -l /mnt/gentoo{/boot,/proc,} cdimage ~# reboot