创建VM(暂时手动操作):分2个网卡,除了默认的,再加一个hostonly的
然后启动到iso的提示符号下,获取下面的脚本
# vbox中archlinux安装
# 准备源
curl -o /etc/pacman.d/mirrorlist "https://www.archlinux.org/mirrorlist/?country=CN"
sed -i 's/#Server/Server/g' /etc/pacman.d/mirrorlist
#分区, 只分一个,选dos
parted /dev/sda mklabel msdos
parted /dev/sda mkpart primary xfs 1M 100%
parted /dev/sda set 1 boot on
#文件系统
mkfs.xfs /dev/sda1
mount /dev/sda1 /mnt
# 安装
pacstrap /mnt base linux linux-firmware
#安装完成后执行
genfstab -U /mnt >> /mnt/etc/fstab
# 进入新安装的环境执行
#arch-chroot /mnt
#
#pacman -S bash-completion nano
arch-chroot /mnt pacman --noconfirm -S
networkmanager pacman-contrib sudo xfsprogs expect
virtualbox-guest-utils grub openssh
# 下面在新环境执行
arch-chroot /mnt ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#同步硬件时钟
arch-chroot /mnt hwclock -w
echo arch-host > /mnt/etc/hostname
# 编辑本地化配置文件
sed -i 's/#en_US.UTF-8/en_US.UTF-8/g' /mnt/etc/locale.gen
sed -i 's/#zh_CN.UTF-8/zh_CN.UTF-8/g' /mnt/etc/locale.gen
sed -i 's/#zh_HK.UTF-8/zh_HK.UTF-8/g' /mnt/etc/locale.gen
sed -i 's/#zh_SG.UTF-8/zh_SG.UTF-8/g' /mnt/etc/locale.gen
sed -i 's/#zh_TW.UTF-8/zh_TW.UTF-8/g' /mnt/etc/locale.gen
arch-chroot /mnt locale-gen
#arch-chroot /mnt echo LANG=en_US.UTF-8 > /etc/locale.conf # shell xxx
echo LANG=en_US.UTF-8 > /mnt/etc/locale.conf
sed -i 's/# %wheel/%wheel/g' /mnt/etc/sudoers
arch-chroot /mnt useradd -m -G wheel -s /bin/bash arch-dev
arch-chroot /mnt expect <<EOCMD
spawn passwd
while 1 {
expect {
"assword:" {
send "archpwdn"
}
eof {
exit
}
}
}
EOCMD
arch-chroot /mnt expect <<EOCMD
spawn passwd arch-dev
while 1 {
expect {
"assword:" {
send "archdevpwdn"
}
eof {
exit
}
}
}
EOCMD
#安装 GRUB 软件包
#arch-chroot /mnt pacman --noconfirm -S grub
arch-chroot /mnt grub-install --target=i386-pc --recheck /dev/sda
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
#启用网络管理器
arch-chroot /mnt systemctl enable --now NetworkManager
#禁用网络管理器的连接等待
arch-chroot /mnt systemctl disable NetworkManager-wait-online
#使用 SSH
#arch-chroot /mnt pacman --noconfirm -S openssh
arch-chroot /mnt systemctl enable sshd
#启用 NTP 同步时间服务
arch-chroot /mnt timedatectl set-ntp true
# 每周自动清理不需要的 Pacman 软件包缓存
arch-chroot /mnt systemctl enable paccache.timer
# 图形用户界面
arch-chroot /mnt pacman --noconfirm -S xfce4 xfce4-goodies
arch-chroot /mnt pacman --noconfirm -S lxdm
arch-chroot /mnt systemctl enable lxdm
# 中文字体,输入法
arch-chroot /mnt pacman --noconfirm -S wqy-microhei ttf-dejavu
arch-chroot /mnt pacman --noconfirm -S fcitx fcitx-im
cat<<EOF>/mnt/root/.xprofile
export LC_ALL=zh_CN.UTF-8
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
EOF
cp /mnt{/root,/home/arch-dev}/.xprofile
# 重新启动
umount /mnt
reboot