已经弄了一天多了,还没有把funtoo装好。主要原因是
1.funtoo(以及gentoo)的安装难度比较大,需要手动从最底层的创建文件系统、下载编译内核做起;
2.对
Stage 3、
portage tree、内核源代码等概念不清楚,对grub的过程不清楚。
所以,要想在linux方面有更深入的了解,必须解决第二个问题。等下次空闲时,我会逐渐去深入学习这些概念。
=======================================================================================
从安装说起:
第一步:下载 live cd, 作为安装、引导新系统的环境;
第二步:使用gdisk对硬盘进行GPT分区
# gdisk /dev/sda
Create Partition 1 (boot):
Command: n ↵
Partition Number: 1 ↵
First sector: ↵
Last sector: +500M ↵
Hex Code: ↵
Create Partition 2 (GRUB):
Command: n ↵
Partition Number: 2 ↵
First sector: ↵
Last sector: +32M ↵
Hex Code: EF02 ↵
Create Partition 3 (swap):
Command: n ↵
Partition Number: 3 ↵
First sector: ↵
Last sector: +4G ↵
Hex Code: 8200 ↵
Create Partition 4 (root):
Command: n ↵
Partition Number: 4 ↵
First sector: ↵
Last sector: ↵ (for rest of disk)
Hex Code: ↵
Command (? for help): p
Disk /dev/sda: 234441648 sectors, 111.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): A4E5208A-CED3-4263-BB25-7147DC426931
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 234441614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 500.0 MiB 8300 Linux filesystem
2 206848 272383 32.0 MiB EF02 BIOS boot partition
3 272384 8660991 4.0 GiB 8200 Linux swap
4 8660992 234441614 107.7 GiB 8300 Linux filesystem
Command (? for help):
Write Partition Table To Disk:
Command: w ↵
Do you want to proceed? (Y/N): Y ↵
-
/dev/sda1, which will be used to hold the /boot filesystem,
-
/dev/sda2, which will be used directly by the new GRUB,
-
/dev/sda3, which will be used for swap space, and
-
/dev/sda4, which will hold your root filesystem.
第三步:在分区上创建文件系统,并挂载文件系统
# mke2fs -t ext2 /dev/sda1
# mkfs.xfs /dev/sda4
# mkswap /dev/sda3
# swapon /dev/sda3# mkdir /mnt/funtoo
# mount /dev/sda4 /mnt/funtoo
# mkdir /mnt/funtoo/boot
# mount /dev/sda1 /mnt/funtoo/boot
第四步:安装Stage 3 tarball
# cd /mnt/funtoo# wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
这里由于网络设置原因,我的wget出错不能用,于是我先在windows下把Stage 3下好,然后通过远程工具Bitvise SSH Client将压缩包导到/mnt/funtoo下。
# tar xJpf stage3-latest.tar.xz
这时,funtoo文件下出现linux的文件系统(bin,boot,dev,proc,etc....),以后再研究Stage 3究竟有什么用?
第五步:Chroot into Funtoo
# cd /mnt/funtoo
# mount --bind /proc proc
# mount --bind /dev dev
# cp /etc/resolv.conf etc
# env -i HOME=/root TERM=$TERM chroot . bash -l
# export PS1="(chroot) $PS1"
第六步:下载Portage树
(chroot) # emerge --sync
SYNC="https://github.com/funtoo/ports-2012.git"
第七步: 配置系统
很重要:
(chroot) # vi /etc/fstab
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# See the manpage fstab(5) for more information.
#
# <fs> <mountpoint> <type> <opts> <dump/pass>
/dev/sda1 /boot ext2 noatime 1 2
/dev/sda3 none swap sw 0 0
/dev/sda4 / xfs noatime 0 1
#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
其他的:
MAKEOPTS="-j3" //处理器数目+1 grep "processor" /proc/cpuinfo | wc -l
(chroot) # cd /usr/portage/profiles/funtoo/1.0/linux-gnu/
(chroot) # ls
arch/ eapi make.defaults package.use/ packages.build use.force
build/ flavor/ mix-ins/ package.use.mask/ parent
(chroot) # cat flavor/desktop/parent
../workstation
../../mix-ins/print
(chroot) # cat flavor/workstation/parent
../core
../../mix-ins/X
../../mix-ins/audio
../../mix-ins/dvd
../../mix-ins/media
../../mix-ins/console-extras
(chroot) #
To view installed profiles:
(chroot) # eselect profile list
To change the profile flavor:
(chroot) # eselect profile set-flavor 7
To add a mix-in:
(chroot) # eselect profile add 10
Remember if you add by string; add a 'gentoo:' to the beginning of the profile name ie:
(chroot) # eselect profile add gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras
第八步:配置内核
(chroot) # time emerge gentoo-sources
(chroot) # cd /usr/src/linux
(chroot) # make menuconfig //这里我用的是旧版本的config文件
(chroot) # make //由于用的是旧版本的配置文件,所以在make时还需配置一些东西
(chroot) # make modules_install
(chroot) # cp arch/x86_64/boot/bzImage /boot/kernel
第九步:安装grub工具
(chroot) # emerge boot-update
修改 /etc/boot.conf:
boot {
generate grub
default "Funtoo Linux genkernel"
timeout 3
}
"Funtoo Linux" {
kernel bzImage[-v]
# params += nomodeset
}
"Funtoo Linux genkernel" {
kernel kernel[-v]
initrd initramfs[-v]
params += real_root=auto
# params += nomodeset
}
(chroot) # grub-install --no-floppy /dev/sda
(chroot) # boot-update
修改/boot/grub/grub.cfg有问题,将real_root改为root。
第十步:安装系统工具
(chroot)# time emerge syslog-ng vixie-cron //安装系统日志和cron守护进程
(chroot)# rc-update add dhcpcd default //添加dhcp服务默认启动
第十一步:reboot
(chroot) # exit
# cd /
# umount /mnt/funtoo/boot /mnt/funtoo/dev /mnt/funtoo/proc /mnt/funtoo
# reboot
time emerge gentoo-sources
real 16m36.575s
user 1m32.565s
sys 1m30.620s
make
real 10m27.394s
user 15m56.620s
sys 2m41.541s
Kernel Panic - not syncing :VFS: Unable to mount root fs on unknown-block(0,0)
可能有两种原因:1.配置内核时,相关磁盘驱动没有选中或者分区不正确或者/etc/fstab设置问题;2.grub有问题。这里是/boot/grub/grub.cfg有问题,将real_root改为root,即可正常启动。