从现有发行版中安装Arch
From ArchWiki
| i18n |
|---|
| Русский |
| English |
| 简体中文 |
Contents |
[edit] 如何从liveCD或者现有发行版中安装Arch
[edit] 概述
Archlinux's Pacman can be configured (-r) to perform operations in any directory you like, using that as the context of "root" while running.
The pacman package available from the mirrors includes a static-linked version of the binary (pacman.static) which should run in most any modern linux environment, without the need of dependencies.
This is useful for building up new Archlinux systems from scratch from other LiveCDs or different systems running another Linux environment, creating new chroot environments on a "host" system, maintaining a "golden-master" for development & distribution, or other fun topics like rootfs-over-NFS for diskless machines.
In the case of an x86_64 host, it is even possible to use i686-pacman to build a 32-bit chroot environment. See Arch64 Install bundled 32bit system.
[edit] 设置现有系统
在现有系统中安装pacman。 最简单的方法是下载符合现有系统的最新版本的安装包。
ftp://ftp.archlinux.org/core/os/i686 (i686 系统) ftp://ftp.archlinux.org/core/os/x86_64 (x86_64 系统)
在后续的安装中将使用 pacman.static ,我们只需要下面的文件安装到现有系统中:
/etc/pacman.conf /etc/pacman.d/* /usr/bin/pacman.static
如果你没有洁癖,那可以 cd 到 /,然后直接解压你下载的 pacman.xxxx.pkg.tar.gz 。
配置一下 /etc/pacman.conf ,需要的话再设置一下 /etc/pacman.d/mirrorlist(pacman 3.0 以上版本)。
[edit] 准备好安装Arch的分区
准备好安装Arch的磁盘,并且挂载他们. 可以使用现有系统的gui工具,例如 gparted, cfdisk, 或者 mandrakes diskdrake。
要把一个分区格式化成 ext3 ,你可以使用(假设你的分区是 /dev/hdxx):
mkfs.ext3 /dev/hdxx
reiserfs:
mkreiserfs /dev/hxx
swap:
mkswap /dev/hdxx
大部分系统都有自己的mkfs,可以用tab补全一下看看。支持什么格式的系统,取决于你的现有系统。
设置好了你的文件系统,就可以挂载了。本文挂载位置是 /newarch,你可以随便往哪里挂。
mkdir /newarch mount /dev/hdxx /newarch
你也可以在现有系统的某个目录里面安装arch,安装好之后把这个系统通过网络或者其他方式传送到实际需要的地方。
[edit] 安装基本系统
更新一下 pacman 的源, 你可能需要创建一个 /newarch/var/lib/pacman 目录。
mkdir -p /newarch/var/lib/pacman pacman.static -Sy -r /newarch pacman.static -S pacman -r /newarch
安装base,会安装好基本系统。
./pacman.static -Sy base -r /newarch
[edit] 准备新系统
确认一下 /dev 里面的 nodes 已经为udev创建好了:
cd /newarch/dev mknod -m 660 console c 5 1 mknod -m 660 null c 1 3
为新系统挂载需要的文件系统:
mount /dev/ /newarch/dev/ --bind mount /sys/ /newarch/sys/ --bind mount /proc/ /newarch/proc/ --bind
还需要创建一个 /newarch/etc/resolv.conf 文件,也可以使用现有系统的 resolv.conf。
cp /etc/resolv.conf /newarch/etc/
Chroot 到新系统:
chroot /newarch
[edit] 安装剩余部分
安装你喜欢用的kernel,以及其他你想要安装的包。
注意:你或许需要编辑 /etc/mkinitcpio.conf 文件,修改 "ide" 为 "pata" ,这样你可以使用 "sda1" 来代替 "hda1" 来访问你的硬盘:
pacman -S kernel26 pacman -S kernel26beyond pacman -S kernel26mm(3个kernel包选装一个)
注意:如果pacman报磁盘空间不足的错,试试看后面 设置系统加载程序 部分的方法。 cat /proc/mounts > /etc/mtab 来修复这个错误。 如果还需要安装别的软件包,使用下面的命令:
pacman -S 包名
[edit] 配置新系统
编辑 /etc/fstab ,记得添加 /,swap 和其他你需要启动即挂载的分区。
编辑 rc.conf ,设置你的locale,时区,网络等。
编辑 /etc/locale.gen, 去掉你想要的locale的前面的#, 然后生成locale。
# locale-gen
[edit] 设置系统加载程序
编辑你喜欢的系统加载程序的配置文件,并且安装。如果使用的是grub,可以参考下面的内容:
# grep -v rootfs /proc/mounts > /etc/mtab
这么做可以让grub-install在chroot系统中正确运行。
注意:在chroot里面生成的内核 kernel26.img 文件如果启动不了,使用 kernel26-fallback.img 就可以了。
Instructions for GRUB and LILO are available on this wiki.
[edit] 安装完毕
重启系统。
[edit] Kernel Panic
启动时如果遇到下面的错误信息:
kinit: couldn't open console, no such file...
那么可能是因为你没有使用mknode创建必要的设备文件,按照上面的步骤创建即可。
[edit] Trouble Shoot: Root device '/dev/sd??' doesn't exist
If when you reboot into your new system you get a error messages like this:
Root device '/dev/sda1' doesn't exist, attempting to create it... etc.
This means the drives are showing up as "hda1" instead of "sda1" In which case change your GRUB or LILO settings to use "hd??" or try the following.
Edit /etc/mkinitcpio.conf and change "ide" to "pata" in the "HOOKS=" line. Then using pacman reinstall your kernel which will run mkinitcpio in order to apply the changes. (Make sure you have chroot'ed into the new system first.)
pacman -S kernel26