电脑里没有一个可以用的Linux操作系统真是不方便,打算在Vbox中安装一个ArchLinux。连续错过了好几个ArchLinux的版本,这冷安装感觉有很多不一样的地方。最明显的莫过于找不到/arch/setup这个脚本了,官方Wiki里面也没有提及,看来是增加了安装的难度。倒是看到在home目录下有一个install.txt文件。
From Installation Guide:
As of the 2012.07.15 installation media release, AIF (the Arch Installation Framework) is no longer included but instead Arch Install Scripts are provided to aid in the installation process. This article summarizes the install process using these scripts. See the Beginners' Guide instead for a walkthrough aimed at new users.
还有就是/etc/rc.conf文件不再存在了,而且引入了systemd作为initscripts的替换。RHEL和Ubuntu是用upstart来替换initscripts。
另外安装iso启动之后的这个命令行补全功能感觉有点陌生,原来是用了zsh。
安装步骤就看上面的Install Guide或者install.txt文件都可以。首先确保你的网络没有问题,否则按照Beginngers' Guide#Establish_an_internet_connection中的步骤配置好网络。
分区
接下来第一步就是分区了,分区不用搞得很复杂。在虚拟机里面我就分成根分区和Swap分区两个,可以用cfdisk或者fdisk等命令来分区,分区的命令可以查看Beginngers' Guide#Prepare_the_storage_drive。
挂载文件系统
分区完成后,需要格式化文件系统并挂载。我这边选择常用的ext4文件系统,对于其它文件系统可以参见create the new file system。
root@archiso ~ # mkfs.ext4 /dev/sda1 root@archiso ~ # mkswap /dev/sda2 root@archiso ~ # swapon /dev/sda2
然后将根分区挂载到/mnt目录:
root@archiso ~ # mount /dev/sda1 /mnt
如果给home或者boot划分独立的分区,也需要为其创建目录并挂载。分区对应的设备名称可以通过lsblk /dev/sda命令查看。
修改源
修改/etc/pacman.d/mirrorlist文件,将你觉得最快的mirror地址放到最前面,我这里选择了网易的源:
Server = http://mirrors.163.com/archlinux/$repo/os/i686
安装最小化系统
ArchLinux提供了pacstrap工具来安装最小化系统,这个有点类似于Ubuntu的bootstrap工具,抽空可以研究一这个小工具。命令如下所示:
root@archiso ~ # pacstrap /mnt base base-devel
base-devel中包括的是一些编译工具,例如make,automake等等,如果不需要用到这些则可以不安装。这个安装过程可能有点久,需要耐心等待。
生成fstab文件
使用genfstab命令可以自动生成fstab文件:
root@archiso ~ # genfstab -p /mnt >> /mnt/etc/fstab
可以指定-U或者-L参数分别使用UUID或者Label来表示磁盘分区。自动生成的fstab文件有些地方需要修改,比如将根分区对应的pass字段从2修改成1,同时可以删除data=ordered。pass字段的作用是(摘自这里):
<pass> - used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 - all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.
最终的fstab文件如下所示:
# # /etc/fstab: static file system information # # <file system> <dir> < <type> <options> <dump> <pass> tmpfs /tmp tmpfs nodev,nosuid 0 0 # UUID=5bacaba7-e316-47f5-bd88-6d5574489d56 /dev/sda1 / ext4 rw,relatime 0 1 # UUID=9029f007-b062-49dd-bbd4-ba9130082337 /dev/sda2 none swap defaults 0 0
chroot配置系统
通过chroot命令切换到新安装的最小化系统:
root@archiso ~ # arch-chroot /mnt
1. 安装locale
编辑/etc/locale.gen文件,将需要的locale前面的注释删除,我打开了en_US.UTF-8以及几个以zh_CN开头的locale。编辑好之后保存,通过locale-gen命令生成:
sh-4.2# locale-gen Generating locales... en_US.UTF-8... done zh_CN.GB18030... done zh_CN.GBK... done zh_CN.UTF-8... done zh_CN.GB2312... done Generation complete.
2. 修改终端字体
首先安装终端下的字体terminus-font,我选择terminus-font:
sh-4.2# pacman -S terminus-font
修改/etc/vconsole.conf文件,添加:
KEYMAP= FONT=ter-v16n FONT_MAP=
3. 修改时区与设置时间
sh-4.2# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
设置硬件时钟为UTC:
sh-4.2# hwclock --systohc --utc
4. 修改hostname
将hostname写到/etc/hostname文件中:
sh-4.2# echo devops > /etc/hostname
修改/etc/hosts文件:
127.0.0.1 devops localhost ::1 devops localhost
5. 配置网络为dhcpd
sh-4.2# systemctl enable dhcpcd@.servic
其它方式的网络配置,可以参考Beginnerss' Guide#Configure_the_network
6. 设置用户
sh-4.2# passwd root sh-4.2# useradd -m -s /bin/bash -G wheel,games,power,video,audio,lp,storage,optical,scanner,users kodango sh-4.2# passwd kodango
7. 安装Grub
针对bios PC:
sh-4.2# pacman -S grub-bios sh-4.2# grub-install --target=i386-pc --recheck /dev/sda sh-4.2# grub-mkconfig -o /boot/grub/grub.cfg
针对其它类型的PC可以参考Beginners' Guide。
8. 更新系统
sh-4.2# pacman -Syu
9. 安装sudo软件包
sh-4.2# pacman -S sudo
visudo修改配置文件,放开wheel组的权限。
10. yaourt安装
修改/etc/pacman.conf,在结尾处添加以下内容:
[archlinuxfr] Server = http://repo.archlinux.fr/i686
安装yaourt包:
sh-4.2# pacman -Syyu sh-4.2# pacman -S yaourt
11. 退出chroot环境
sh-4.2# exit root@archiso ~ # umount /mnt
然后重启。
安装常用软件
1. 常用软件
[kodango@devops ~]$ sudo pacman -S vim wget curl lftp unrar unzip p7zip bash-completion
2. VBox guest配置
[kodango@devops ~]$ pacman -S virtualbox-guest-utils [kodango@devops ~]$ modprobe -a vboxguest vboxsf vboxvideo
创建模块加载配置文件/etc/modules-load.d/virtualbox.conf并将以下内容添加进去:
vboxguest vboxsf vboxvideo
将用户添加到vboxsf组中:
[kodango@devops ~]$ gpasswd -a kodango voxsf
挂载共享文件夹:
[kodango@devops ~]$ mkdir ~/share/ [kodango@devops ~]$ vim /etc/fstab Share /home/admin/share vboxsf uid=user,gid=group,rw,dmode=700,fmode=600,comment=systemd.automount 0 0
参考链接
1. http://www.bestzhou.net/tech/how-to-install-archlinux20120907/
2. http://jianxi.info/blog/2012/09/13/arch-install/
3. https://wiki.archlinux.org/index.php/Arch_Install_Scripts
4. https://wiki.archlinux.org/index.php/Beginners'_Guide
您好,我在安装archlinux时根分区分的有点小了,我现在想扩大一下,问一下该咋办?