自己尝试安装了archlinux在虚拟机里,记录安装过程,不过现在archlinux的WIKI是描述清晰的,直接查看和参考即可。
pacman常用命令 pacman命令的常用说明:
1 2 3 4 5 6 7 8 9 [root@LiarLee ~]# pacman -Sg gnome 查看gnome软件包组下面的所有软件包 [root@LiarLee ~]# pacman -Qe openssh 查询已经安装的软件包 [root@LiarLee ~]# pacman -Qs openssh 正则查询软件包 [root@LiarLee ~]# pacman -Rs $(pacman -Qtdq) 递归删除孤立软件包 [root@LiarLee ~]# pacman -Ss 关键字:在仓库中搜索含关键字的包 [root@LiarLee ~]# pacman -Qs 关键字: 搜索已安装的包 [root@LiarLee ~]# pacman -Qi 包名:查看有关包的详尽信息 [root@LiarLee ~]# pacman -Ql 包名:列出该包的文件 [root@LiarLee ~]# pacman -Syyu 下载已经更新本地的所有软件包
安装Archlinux 1. 获取Archlinux镜像 从这个页面获取镜像: LINK HERE
2. 启动到Archlinux Live环境 在VMware中使用镜像文件直接引导Archlinux Live环境。
3. 设置Archlinux的键盘布局 默认为US键盘布局,此处未作修改。
4. 连接到Internet 使用ip link命令查看目前网卡的状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 root@ archiso ~ # ip link showtrue1 : lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 truetruelink/loopback 00 :00 :00 :00 :00 :00 brd 00 :00 :00 :00 :00 :00 true2 : ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> dmtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 truetruelink/ether 00 :0 c:29 :5 e:ea:d5 brd ff:ff:ff:ff:ff:ff true root@ archiso ~ # ifconfigtrueens33: flags=4163 <UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 truetruetrueinet 192.168 .229 .129 netmask 255.255 .255 .0 broadcast 192.168 .229 .255 truetruetrueinet6 fe80::9888 :f57a:5 c25:9 cf9 prefixlen 64 scopeid 0x20 <link> truetruetrueinet6 fd15:4 ba5:5 a2b:1008 :6e02 :ff6:feeb:c250 prefixlen 64 scopeid 0x0 <global> truetruetrueether 00 :0 c:29 :5 e:ea:d5 txqueuelen 1000 (Ethernet) truetruetrueRX packets 199 bytes 18652 (18.2 KiB) truetruetrueRX errors 0 dropped 0 overruns 0 frame 0 truetruetrueTX packets 186 bytes 23144 (22.6 KiB) truetruetrueTX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 truelo: flags=73 <UP,LOOPBACK,RUNNING> mtu 65536 truetruetrueinet 127.0 .0 .1 netmask 255.0 .0 .0 truetruetrueinet6 ::1 prefixlen 128 scopeid 0x10 <host> truetruetrueloop txqueuelen 1000 (Local Loopback) truetruetrueRX packets 0 bytes 0 (0.0 B) truetruetrueRX errors 0 dropped 0 overruns 0 frame 0 truetruetrueTX packets 0 bytes 0 (0.0 B) truetruetrueTX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 truetrue root@ archiso ~ # ping baidu.com truePING baidu.com (123.125 .114 .144 ) 56 (84 ) bytes of data. true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=1 ttl=128 time=14.8 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=2 ttl=128 time=13.6 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=3 ttl=128 time=17.1 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=4 ttl=128 time=14.1 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=5 ttl=128 time=13.9 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=6 ttl=128 time=14.7 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=7 ttl=128 time=13.5 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=8 ttl=128 time=16.2 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=9 ttl=128 time=16.9 ms true64 bytes from 123.125 .114 .144 (123.125 .114 .144 ): icmp_seq=10 ttl=128 time=14.1 ms true^C true--- baidu.com ping statistics --- true10 packets transmitted, 10 received, 0 % packet loss, time 26 ms truertt min/avg/max/mdev = 13.543 /14.895 /17.105 /1.278 ms
网络连接到此为止无需配置,可以正常访问网络。
5. 更新系统时间,硬件时间同步 使用命令查看系统时间以及硬件时间,将同步的当前时间写入硬件:
1 2 3 4 5 6 7 8 9 10 root@archiso ~ truetruetrueLocal time: Wed 2019 -04 -24 08 :55:39 UTC truetrueUniversal time: Wed 2019 -04 -24 08 :55:39 UTC truetruetruetrueRTC time: Wed 2019 -04 -24 08 :55:40 truetruetruetrueTime zone: UTC (UTC, +0000) System clock synchronized: yes truetruetrueNTP service: active truetrueRTC in local TZ: no root@archiso ~
6. 建立系统的硬盘分区 建立硬盘分区,我建立了两个分区,一个根分区和一个交换分区。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 root@archiso ~ trueDisk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors trueDisk model: VMware Virtual S trueUnits: sectors of 1 * 512 = 512 bytes trueSector size (logical/physical): 512 bytes / 512 bytes trueI/O size (minimum/optimal): 512 bytes / 512 bytes trueDisklabel type: dos trueDisk identifier: 0xba00941d trueDevice Boot Start End Sectors Size Id Type true/dev/sda1 2048 1050623 1048576 512M 82 Linux swap / Solaris true/dev/sda2 1050624 104857599 103806976 49. 5G 83 Linux trueDisk /dev/loop0: 491.2 MiB, 515084288 bytes, 1006024 sectors trueUnits: sectors of 1 * 512 = 512 bytes trueSector size (logical/physical): 512 bytes / 512 bytes trueI/O size (minimum/optimal): 512 bytes / 512 bytes
7. 已经建立分区的格式化
格式化ext4分区1 root@archiso ~ # mkfs.ext4 /dev/sda2
格式化swap分区1 2 root@archiso ~ # mkswap /dev/sda1 # 将/dev/sda1格式化为swap分区 root@archiso ~ # swapon /dev/sda1 # 将/dev/sda1启用为swap分区
8. 挂载分区 使用系统挂载点/mnt,将/dev/sda2作为系统的根目录挂载到/mnt上。 1 root@archiso ~ # mount /dev/sda2 /mnt
9. 定义安装所需的Mirrorlist 10. 安装基础的Archlinux系统组件 部署安装linux的文件系统,安装系统基础组建的软件包。 1 [root@LiarLee /]# pacstrap /mnt base
11. 新系统的相关配置 1. fstab 根据自己建立的分区自动生成系统的分区表。 1 2 3 4 5 6 7 8 9 10 11 [root@ LiarLee /]# genfstab -U /mnt >> /mnt/etc/fstab # 生成新的fstab,写入安装硬盘的/etc/fstab [root@ LiarLee ~]# cat /etc/fstab # 查看新的分区表 true# Static information about the filesystems. true# See fstab(5 ) for details. true# <file system> <dir> <type> <options> <dump> <pass> true# /dev/sda2 trueUUID=3 b61b364-b9eb-4e31 -b65a-55f dcf09c614 / ext4 rw,relatime 0 1 true# /dev/sda1 trueUUID=91987 ac9-fa6b-4 ac5-a9c5-014169 dcf058 none swap defaults 0 0
2. chroot 使用chroot命令切换根文件系统。 1 [root@LiarLee /]# arch-chroot /mnt
3. timezone chroot命令相当于直接将当前的shell切换到了新安装的系统中。 设置新的系统的时间及同步硬件时间。 1 2 [root@LiarLee /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@LiarLee /]# hwclock --systohc
4. 本地设置
5. 网络设置 配置hostname以及本地解析hosts文件的解析条目。
1 2 3 4 5 6 7 [root@ LiarLee /]# vim /etc/hostname trueYOUR_HOSTNAME.YOUR_DOMAIN [root@ LiarLee /]# vim /etc/hosts true127.0 .0 .1 localhost true::1 localhost trueIP_ADDRESS YOUR_HOSTNAME.YOUR_DOMAIN YOUR_HOSTNAME
6. 生成initramfs 为新的系统生成ramfs。 ramfs的作用是,利用ramfs的文件系统,快速驱动周边的系统设备。在ramfs的使命结束后,自动chroot到新系统的文件系统中。
1 [root@LiarLee /]# mkinitcpio -p linux
7. 设置root密码 修改root密码。
1 [root@LiarLee /]# passwd
8. 安装grub2 这里pacman命令已经可以使用了,因此直接在这个安装grub2,这样才可以在后面正确的重启到新安装好的系统。
1 2 [root@LiarLee /]# pacman -S grub2 [root@LiarLee /]# grub-mkconfig
12. 重启引导新系统 将已经安装完成的那个根分区卸载,之后就可以重启了。
1 2 3 [root@LiarLee /]# umount -R /mnt # umount 接触挂载新的根文件系统 [root@LiarLee /]# fuser /mnt # fuser 查看占用文件系统的进程,如果确认的话可以直接-k结束所有占用的进程 [root@LiarLee /]# reboot # 重启
13. 安装图形化界面 1. 安装Xorg: 安装如下的所有组件,重启就可以进入图形化环境了。 1. 运行错误 xterm:command not found [root@LiarLee /]# pacman -S xterm zlib 1. 运行报错 twm:command not found [root@LiarLee /]# pacman -S xorg-twm xorg-xclock 1. 安装鼠标驱动 [root@LiarLee /]# pacman -S xf86-input-mouse 1. 安装VMware图形驱动 [root@LiarLee /]# pacman -S xf86-video-vmware 1. 安装Xorg服务本体 [root@LiarLee /]# pacman -S xorg-server xorg-xinit 1. 安装Gnome桌面环境 [root@LiarLee /]# pacman -S gnome 1. 安装GDM - Gnome桌面管理工具,也可用其他替换 [root@LiarLee /]# pacman -S gdm
2. 安装图形化之后测试启动速度 systemd提供了命令检测启动的速度,包括内核启动速度以及用户空间的启动速度。
systemd-analyze
systemd-analyze blame
1 2 3 [root@ LiarLee ~]# systemd-analyze Startup finished in 1.892 s (kernel) + 1.182 s (userspace) = 3.075 s graphical.target reached after 1.182 s in userspace
3. 刷新国内的镜像源 1 2 3 4 5 6 7 [root@LiarLee /]# cd /etc/pacman.d/ [root@LiarLee pacman.d]# mv mirrorlist mirrorlist.bak [root@LiarLee pacman.d]# wget -O /etc/pacman.d/mirrorlist https://www.archlinux.org/mirrorlist/?country=CN [root@LiarLee pacman.d]# mv mirrorlist mirrorlist.rank [root@LiarLee pacman.d]# rankmirrors mirrorlist.rank >> mirrorlist [root@LiarLee pacman.d]# sed 's/^Server/#Server/g' ./mirrorlist >> ./mirrorlist [root@LiarLee pacman.d]# s[root@LiarLee pacman.d]# spacman -Syyu
14. 自行编译内核操作: 1 2 3 4 5 6 7 8 9 10 11 12 13 [root@LiarLee /]# pacman -S base-devel bc xmlto kmod inetutils [root@LiarLee /]# useradd -d /home/admin -p admin admin [root@LiarLee /]# chown -R admin:admin /home/admin [root@LiarLee /]# mkdir /home/admin/mk-new-kernel/ [root@LiarLee /]# su - admin [root@LiarLee /]# cd /home/admin/mk-new-kernel/ [root@LiarLee /]# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.8.tar.xz [root@LiarLee /]# tar xvf linux-5.0.8.tar.xz [root@LiarLee /]# cd linux-5.0.8/ [root@LiarLee /]# make clean && make mrproper [root@LiarLee /]# make localmodconfig [root@LiarLee /]# make nconfig [root@LiarLee /]# make
15. 一些问题
重启之后没有DHCP获取IP地址的解决方法: [root@LiarLee /]# systemctl enable dhcpcd
[root@LiarLee /]# systemctl start dhcpcd
[root@LiarLee /]# pacman -S net-tools