虚拟机下安装Gentoo

Linux下用VirtualBox,Win7下用VM装了两遍,都是内核装完,X Window 没有装上。

最好按照官方英文版手册安装,好多地方都不同

使用Mini CD,网络安装。

1、账户准备

passwd

useradd test

passwd test

/etc/init.d/sshd start 使得可以远程登录安装

2、网络准备

net-setup eth0 虚拟网络类型选择 NAT

不知为何,Linux的virtualbox下还需自行设定DNS服务器

nano /etc/resolve.conf

3、硬盘准备

fdisk /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

5、安装stage及portage

cd /mnt/gentoo

links http://mirrors.163.com/gentoo 选择下载最新stage

tar -xvjpf stage3.-*.tar.bz2

links http://mirrors.163..com/gentoo 在snapshot中选择下载最新portage

tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

6、设置编译选项

CFLAGS="-O2 -march=i686 -pipe"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j4" 给虚拟机分了四个核

7、更换root空间

mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf选择镜像

mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf

cp -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"

8、设置Portage

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、编译内核

开始是手动配置的内核

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 查看安装的内核

10、设置系统信息

文件系统

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 0
机器名

nano -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 更新本地信息

执行以下两步后,系统提示信息出现乱码

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

11、安装系统工具

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

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


13、退出重启

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值