vps2arch

大部分 VPS 服务商一般不会提供 Archlinux 的服务器镜像,也不提供自定义镜像服务,但是你可以通过 vps2arch 将你的操作系统切换为 Archlinux。

项目地址 : https://gitlab.com/drizzt/vps2arch

安装

使用 SSH 连接服务器,切换为 root 用户,执行以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
wget http://tinyurl.com/vps2arch
chmod +x vps2arch
./vps2arch

# 帮助命令
./vps2arch -h
# 自定义bootloader(grub/syslinux),默认grub
./vps2arch -b syslinux
# 自定义网络管理器(systemd-networkd|netctl),默认systemd-networkd
./vps2arch -n netctl
# 自定义镜像(阿里云)
./vps2arch -m https://mirrors.aliyun.com/archlinux
# 自定义镜像(腾讯云)
./vps2arch -m https://mirrors.cloud.tencent.com/archlinux
# 自定义镜像(清华大学)
./vps2arch -m https://mirrors.tuna.tsinghua.edu.cn/archlinux

稍微等待几分钟会看到如下提示

1
2
3
4
When you are finished with your post-installation, you'll need to reboot the VM the rough way:
# sync ; reboot -f

Then you'll be able to connect to your VM using SSH and to login using your old root password (or "vps2arch" if you didn't have a root password).

这时需要你执行sync ; reoot -f来重启 VPS,重启完毕输入之前的 root 密码即可登录系统。到这里你的VPS的系统就成功切换为 Archlinux 了。

配置

ArchWiki: https://wiki.archlinux.org/title/Installation_guide

时间设置

1
2
3
4
5
# 使用 ntp
timedatectl set-ntp true
# 设置时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc

设置中文

编辑 /etc/locale.gen 在最前面添加(当然取消注释也是一样的)

1
2
en_GB.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8

执行 locale-gen应用配置,设置默认语言

1
2
3
cat << "EOF" > /etc/locale.conf
LANG=en_US.UTF-8
EOF

添加 ArchLinuxCN 源

编辑 /etc/pacman.conf ,在文件末尾添加

1
2
[archlinuxcn]
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

保存后执行

1
2
pacman -Syy
pacman -S archlinuxcn-keyring

添加用户

将以下的 Aaron 修改为你的用户名

1
useradd -m -G wheel Aaron

-m 参数代表自动创建用户的家目录,这个例子里是 /home/Aaron

-G 参数意味着用户要加入一些个的附加组,这儿即 wheel

设置用户密码

1
passwd Aaron

在 Linux 中设置密码是不显示的,输入两次一样的密码会提示成功。