github twitter email rss
ArchLinux 安装与配置
Aug 27, 2014
2 minutes read

检查需要配置网络的接口名(interface)

ip link

输出如下:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp2s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:11:25:31:69:20 brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT qlen 1000
    link/ether 01:02:03:04:05:06 brd ff:ff:ff:ff:ff:ff

配置有线网络,如果为dhcp自动分配或无线网络的这里略过详细

ip addr add 192.168.0.100/24 dev enp2s0f0
ip route add default via 192.168.0.1
vi /etc/resolv.conf
#填入dns
nameserver 114.114.114.114

用fdisk分区,分出一个swap及一个ext3/ext4分区

fdisk /dev/sda
o   #创建一个新的分区表
n   #创建新分区
p   #主分区
2   #分区2,用作swap,大小与内存相等及可
enter #这里默认即可
+1G #大小1G
n   #创建新分区
p   #主分区
1   #分区1,用作系统区
enter #这里默认即可
enter #默认剩余的所有空间
w   #写入分区表
mkfs.ext3 /dev/sda1     #格式化分区
mkswap /dev/sda2
swapon /dev/sda2

挂载分区,更改源

mount /dev/sda1 /mnt
vi /etc/pacman.d/mirrorlist

国内源如下:

##
## Arch Linux repository mirrorlist
## Generated on 2014-08-26
##

## China
#Server = http://mirrors.163.com/archlinux/$repo/os/$arch
#Server = http://mirror.bjtu.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.hust.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.hustunique.com/archlinux/$repo/os/$arch
#Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
#Server = http://run.hit.edu.cn/archlinux/$repo/os/$arch
#Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch

开始安装

pacstrap -i /mnt base base-devel

生成fstab

genfstab -U -p /mnt >> /mnt/etc/fstab
vi /mnt/etc/fstab #确认下看看有没有错误

chroot 并配置系统

arch-chroot /mnt /bin/bash

语言配置

vi /etc/locale.gen
#将en_US.UTF-8 UTF-8 前面的#号去掉
...
#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
#en_US ISO-8859-1
...
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8

时区

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc --utc

加载必要的内核模块

vi /etc/modules-load.d/virtio-net.conf 

以下模块为qemu 虚拟机必须

# Load 'virtio-net.ko' at boot. 

virtio-net

主机名

echo myhostname > /etc/hostname
vi /etc/hosts
#
# /etc/hosts: static lookup table for host names
#

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	localhost	myhostname
::1		localhost.localdomain	localhost

# End of file

网络配置

systemctl stop dhcpcd.service
systemctl disable dhcpcd.service
cd /etc/netctl
cp examples/ethernet-static my_network
netctl enable my_network
vi my_network  #将其中的接口 地址 网关 dns 等修改成对应的值

Create an initial ramdisk environment

vi /etc/mkinitcpio.conf
...
MODULES="virtio virtio_blk virtio_pci virtio_net"
...
mkinitcpio -p linux

设定root密码

passwd

安装bootloader

pacman -S syslinux
syslinux-install_update -iam

编辑/boot/syslinux/syslinux.cfg, 将其中的/dev/sda3 改成你实际的root分区

重启, 进行最后配置,安装些常用的软件

systemctl disable dhcpcd.service
pacman -S vim openssh

done! enjoy~

quote from ArchLinux


Back to posts


comments powered by Disqus