Arch Linux is liked by many people but not that friendly to new users of Linux. Kvm is a light virtual machine, which is contained in most of Linux distributors. This article will show you how to install Arch Linux on Kvm step by step.
Setting Ssh
- [ Arch ] Enable ssh-server
systemctl enable sshd
systemctl start sshd
- [ Arch ] Check sshd status
systemctl status sshd
- [ Arch ] Show guest OS IP address
ip addr
- [ Arch ] Set password for root
passwd root
- [ Host OS ] Connect to Kvm
ssh root@ipaddress
Partition the disk
- List your devices
fdisk -l
/dev/vda will be shown
- Check whether you are using UEFI
ls /sys/firmware/efi/efivars
( In fact, there is no need checking, as KVM doesn’t support UEFI )
- Create root patition
fdisk /dev/vda
input n → choose p → continue press Entre → input w to save
Make filesystem
- If you choose ext4
mkfs.ext4 /dev/vda1
- If you choose btrfs
mkfs.btrfs /dev/vda1
Choose mirror
Reflector is a good tool to use, however, if you live in China, you’d better choose mirror by hand.
- Archive the former list first
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.save
- Change the mirror
vim /etc/pacman.d/mirrorlist
- Within the vim
You can use input the code below to comment all Server
:%s/Server/# Server/g
The use this to search for your country
( I take China as an example )
/China
You can uncommet the server you like, still if you live in China, I recommend the two below
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
- Save and quit
:wq
- Refresh the pacman sourve
pacman -Syy
- Update the key
pacman -S archlinux-keyring
Install to your device
- Mount
mount /dev/vda1 /mnt
- Install basic software
pacstrap /mnt base linux linux-firmware vim networkmanager dhcpcd sudo htop openssh
Configure installed system
- Generate fstab file, which defines the disk parition, block devices etc.
genfstab -U /mnt >> /mnt/etc/fstab
- Entre mounted disk as root
arch-chroot /mnt
- Set timezone
timedatectl set-timezone Asis/Taipei
- Set location
locale-gen
echo LANG=en_GB.UTF-8 > /etc/locale.conf
export LANG=en_GB.UTF-8
- Change hostname
echo hostname > /etc/hostname
- Create hosts file
vim /etc/hosts
Write these below into it
127.0.0.1 localhost
::1 localhost
127.0.1.1 hostname
( You should replace hostname with your own hostname above )
- Set root passwd
passwd
- Start networkmanager
systemctl enable NetworkManager.service
- Enable sshd
systemctl enable sshd
systemctl start sshd
Grub install and configure
- Install grub
pacman -S grub
- Configure grub
grub-install /dev/vda
grub-mkconfig -o /boot/grub/grub.cfg
( Attention! /vda is the device name not partition name )
Common user
Using root to operate a computer is dangerous, so we need to create a new personal account
- Create user
useradd -m username
- Set password
passwd username
- Add new user to sudo list
vim /etc/sudoers
Add the sentence below after finding the Root
username ALL=(ALL) ALL
- Save and quit
:wq
Graphical interface (Optional)
- KDE plasma
pacman -S xorg plasma plasma-wayland-session kde-applicationssystemctl enable sddm.service
- Gnome
pacman -S xorg gnomesystemctl start gdm.service
systemctl enable gdm.service
Exit
- Exit chroot
exit
- Shutdown
poweroff