| 导读 | Arch Linux是一个通用的滚动发行版Linux,一旦系统或者软件有新版本发布,你就可以升级它们。深受DIY爱好者和Linux核心用户的欢迎。默认安装只覆盖最小的基本系统,并希望用户自行配置系统。这就是为什么安装Arch Linux本身就是一个挑战,但同时,它也是中级Linux用户的一个学习机会。 |
环境
VMware Workstation 15.0
Arch Linux 2020.05
如何下载ArchLinux
查看最新版本的系统:http://mirrors.163.com/archlinux/iso/latest/
下载地址:http://mirrors.163.com/archlinux/iso/latest/archlinux-2020.05.01-x86_64.iso
创建Arch Linux虚拟机
虚拟机的版本可以选择“其他…”
安装操作系统
引导界面,选择第一项
启动之后,可以看到,进入了Live环境。
检查一下是否连接到因特网
检查一下网卡是否获取到IP地址了:
[email protected] ~ # ip ad 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:83:ed:00 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.43.154/24 brd 192.168.43.255 scope global dynamic noprefixroute ens33 valid_lft 1706sec preferred_lft 1481sec inet6 fe80::456b:5cf2:4baa:efd8/64 scope link valid_lft forever preferred_lft forever
然后ping一下外部网络试试,能否上网:
[email protected] ~ # ping www.baidu.com PING www.a.shifen.com (180.101.49.12) 56(84) bytes of data. 64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=128 time=20.3 ms 64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=128 time=20.5 ms ^C --- www.a.shifen.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 20.252/20.391/20.531/0.139 ms
如果可以上网,就进行下一步吧!
创建分区
在这里我们分两个区,分别为:
- swap :512MB
- / :剩余所有空间
sda磁盘总容量为20GB。
[email protected] ~ # fdisk -l
创建分区:
格式化分区,并挂载分区
/dev/sda1分区,创建swap分区,并且启用。
[email protected] ~ # mkswap /dev/sda1 Setting up swapspace version 1, size = 488 MiB (511700992 bytes) no label, UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3 [email protected] ~ # swapon /dev/sda1
格式化sda2分区为xfs文件系统,并且挂载分区到/mnt目录:
[email protected] ~ # mkfs.xfs /dev/sda2 [email protected] ~ # mount /dev/sda2 /mnt
修改镜像源
进入/etc/pacman.d目录,修改mirrorlist文件,默认情况下,mirrorlist文件里面包含了许多源地址,这样会导致下载程序包速度很慢,我们只需要启用中国的源地址就可以:
[email protected] ~ # cd /etc/pacman.d [email protected] /etc/pacman.d # ll total 25 drwxr-xr-x 4 root root 320 May 6 2020 gnupg -rw-r--r-- 1 root root 495 May 6 2020 mirrorlist [email protected] /etc/pacman.d # mv mirrorlist mirrorlist.back [email protected] /etc/pacman.d # cat mirrorlist.back | grep -A1 China | grep -v '\-' > mirrorlist
安装必须软件包
[email protected] ~ # pacstrap /mnt base linux linux-firmware dhcpcd vim openssh xfsprogs man net-tools
生成fstab文件
使用genfstab命令生成配置文件。-U命令用来设置UUID。
[email protected] ~ # genfstab -U /mnt >> /mnt/etc/fstab [email protected] ~ # cat !$ cat /mnt/etc/fstab # Static information about the filesystems. # See fstab(5) for details. # <file system> <dir> <type> <options> <dump> <pass> # /dev/sda2 UUID=ed6bd242-34fe-43b6-bb0a-08af6cdb28e8 / xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 1 # /dev/sda1 UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3 none swap defaults 0 0 [email protected] ~ #
可以看到swap分区和/分区都已经写入fstab配置文件了。
更改根目录
[email protected] ~ # arch-chroot /mnt [[email protected] /]#
更改时区
更改时区为亚洲、上海。并同步时间到硬件时间。
[[email protected] /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [[email protected] /]# hwclock -w
设置本地化文本编码
编辑/etc/locale.gen添加如下内容:
[[email protected] /]# echo “en_US.UTF-8 UTF-8” >> /etc/locale.gen [[email protected] /]# echo LANG=en_US.UTF-8 > /etc/locale.conf
设置root密码
[[email protected] /]# passwd root New password: Retype new password: passwd: password updated successfully [[email protected] /]#
设置开机启动项
[[email protected] /]# systemctl enable dhcpcd [[email protected] /]# systemctl enable sshd
安装并配置grub2引导
安装grub2
[[email protected] /]# pacman -S grub –noconfirm [[email protected] /]# grub-install /dev/sda Installing for i386-pc platform. Installation finished. No error reported.
导出grub配置文件到/boot/grub/grub.cfg
[[email protected] /]# grub-mkconfig -o /boot/grub/grub.cfg
配置完成
重启系统
[[email protected] /]# exit [email protected] ~ # reboot
可以看到,重启之后已经进入系统了。
修改ssh配置文件,允许root用户ssh登录
发现使用root用户不能ssh远程登录系统,是因为配置文件里面没有允许root用户登录:
[[email protected] ~]# sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config [[email protected] ~]# systemctl restart sshd
这样就可以ssh远程登录服务器了。
安装Gnome桌面环境
# 安装提示信息,默认都回车即可。 [[email protected] ~]# pacman -S xorg xorg-server gnome [[email protected] ~]# systemctl enable gdm NetworkManager Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/gdm.service. Created symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service. Created symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service. Created symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service -> /usr/lib/systemd/system/NetworkManager-wait-online.service.
重启操作系统
[[email protected] ~]# reboot
总结
你可能已经意识到安装Arch Linux并不像安装Ubuntu那么容易。然而,只要有一点耐心,你就一定可以完成它。
原文地址:https://www.linuxprobe.com/vm-install-archlinux.html