2007年4月1日

安装archlinux(1)——安装基本系统

Arch Linux是一份为i686优化的轻量级Linux发行,它包含了各种软件的最新稳定版本。软件以.tar.gz格式打包并由包管理器进行跟踪维护,这样的设计使得软件升级非常容易。与其他发行相比,Arch的技术相当之先进。一些相对不大使用的东西没有保留下来(例如,info页面)。一次缺省的Arch安装带给你的是一套牢固的系统基础,你可以在此基础上增加软件包从而创建你所需要的定制安装。Arch的包系统允许你方便地创建你自己的软件包,这使得按你自己特定的配置重新编译一份新的软件包变得非常容易。Arch的另一个目标是让用户尽可能地使用到Linux的新特性。

我采用chroot方式安装——

先从ISO中提取出chroot安装需要的initrd.img:
#mount arch-0.*.iso Arch
#cp Arch/isolinux/initrd.img ~

解压缩initrd.img:
#cat initrd.img |gzip -d >initrd

挂载在~/tmp下:
#mount -o loop initrd ~/tmp

将initrd.img中的东东全部复制到目标分区上(我挂载在/mnt/distro):
#mkdir /mnt/distro/Arch
#cp -aR /root/tmp/* /mnt/distro/Arch

因为安装程序需要在/dev/vc/5记录安装信息,所以在/dev下创建它:
#cd /mnt/distro/Arch/dev
#mkdir vc
#mknod vc/5 c 4 5

将arch-0.*.iso挂载在src目录下,以备安装软件包:
#mount arch-0.7.iso /mnt/distro/Arch/src -o loop

chroot安装Arch:
#chroot /mnt/distro/Arch /bin/sh

此时已经进入chroot环境:
设置TERM为linux,这样运行setup才不会出错:
#TERM=linux

运行setup开始安装
#arch/setup

首选选择安装介质,选SRC就可以了。

"Prepare Hard Device" 略去。我可不想分区 :)
"Select Packages" 选择src,选择base,调整安装的软件包,默认即可。不过我根据自己的机器取消了一些不用的包。
"install Packages" 开始安装,所有软件包安装在/mnt。
"install kernel " 我没有安装,直接把LFS下的内cp了一个
"Configure System" 编辑系统配置文件。选择喜欢的编辑器编辑做。
"Install Bootloader" 略去。我有/boot分区,使用它管理所有的系统启动。

配置文件:
(我是ADSL上网)
# cat /etc/rc.conf

#
# /etc/rc.conf - Main Configuration for Arch Linux
# LOCALIZATION
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/unimaps
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="zh_CN.utf8"
HARDWARECLOCK="localtime"
TIMEZONE="Beijing/Asia"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

#
# HARDWARE
#
# Scan hardware and load required modules at bootup
MOD_AUTOLOAD="yes"
# Module Blacklist - modules in this list will never be loaded by udev
MOD_BLACKLIST=()
#
# Modules to load at boot-up (in this order)
# - prefix a module with a ! to blacklist it
#
MODULES=()
# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

#
# NETWORKING
#
HOSTNAME="ArchLinux"
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
# - prefix an entry in INTERFACES with a ! to disable it
# - no hyphens in your interface names - Bash doesn't like it
#
# Note: to use DHCP, set your interface to be "dhcp" (eth0="dhcp")
#
lo="lo 127.0.0.1"
eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
INTERFACES=(lo eth0)
#
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
# - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
#
# Enable these network profiles at boot-up. These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
# - set to 'menu' to present a menu during boot-up (dialog package required)
# - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network-profiles
#
#NET_PROFILES=(main)

#
# DAEMONS
#
# Daemons to start at boot-up (in this order)
# - prefix a daemon with a ! to disable it
# - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng network gpm alsa dbus hal pam adsl)
# End of file


配置/etc/fstab:

# cat /etc/fstab

#
# /etc/fstab: static file system information
#
none /dev/pts devpts defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/sda9 / ext3 defaults 0 0
/dev/sda11 swap swap defaults 0 0

基本上就可以了,退出chroot。
把chroot安装好的移到想安装的地方——
#mv /mnt/distro/Arch/mnt/* /ARCH

做一些修补工作:
1. 由于使用的是已有的内核——将原内核的/lib/modules/`uname -r`目录复制到Arch的 /lib/modules中,在/etc/rc.conf中加载需要启动的模块就可以了。实际上我全部编辑内核,直接 touch /lib/modules/`uname -r`/modules.def就可以了。

2. 修改host的grub.conf,增加:

title Arch Linux
root (hd0,8)
kernel /ARCH/boot/kernel26 root=/dev/sda9 init=/ARCH/sbin/pre-init

在sbin/下加入一个pre-init。(这是LFS hint的一个办法)

现在就可以reboot,体验Arch的风采啦。 ^_^

没有评论: