How To Manually Install Arch Linux on a KVM VPS via VNC
This tutorial explains how to manually install Arch Linux on a KVM VPS via VNC. This is useful when your hosting provider doesn’t offer Arch Linux in one-click install. Arch Linux will be used as a server operating system, so I will only install basic component for a server and skip installing GUI stuff.
If you want to be able to one-click install Arch Linux, I recommend Vultr, which is a hosting company providing low-cost, high-performance VPS. With Vultr, you don’t have to do the steps below.
Before following the steps below, I recommend you get the default gateway IP of your KVM VPS first because you will need to enter this IP in a network config file during the installation. It usually ends with 1 like 192.168.0.1. To find out the exact IP address, you can first install Ubuntu or CentOS on your VPS via the one-click install function in the VPS control panel, then boot it up and issue the following command:
ip route show
The IP address after “default via” is the IP address of your gateway. You can also ask your VPS provider about the gateway IP.
Now proceed to the installation.
Step 1: Boot Your VPS from Arch Linux ISO
In your VPS control panel, find the virtual optical disk drive and insert Arch Linux ISO to it. Sometimes you may need to give the direct download link of Arch Linux to your hosting provider and ask them to mount it for you.
Then establish a VNC connection to your VPS. You can get VNC login info from your hosting provider. After that, click boot button in the control panel to boot up your VPS.
Normally you have to press a key like F12 in the VNC window. This allows you to select which device your VPS will boot from. Select optical disk drive so your VPS will boot the Arch Linux ISO image.
The default firmware for KVM virtual machines is called SeaBIOS.
Now you are greeted by the Arch Linux boot menu. Select the first option to boot into Arch Linux live environment.
Step 2: Connect To the Internet
Once you are in Arch Linux live environment, check whether you can access the Internet.
ping google.com
Proceed to step 3 if you receive reply from google server. If there’s no Internet connection, then following the below steps.
In KVM environment, your hosting provider offers you a static IP address. Your KVM VPS establishes a static ethernet connection to the gateway (KVM host) and thus it can access external Internet.
First copy the example ethernet-static network profile to /etc/netctl/
directory.
cp /etc/netctl/examples/ethernet-static /etc/netctl
Then edit this file.
nano /etc/netctl/ethernet-static
Change this file to the following. You may need to adjust red texts.
Interface=ens3 Connection=ethernet IP=static Address=('your-VPS-public-IP-address') Netmask=('255.255.255.0') Gateway=('gateway-IP') DNS=('8.8.8.8')
Save and close the file. Next, bring down the ens3 interface.
ip link set dev ens3 down
Now load ethernet-static
network profile.
netctl start ethernet-static
You should have Internet connection now.
ping google.com
Step 3: Create Partitions
If you want to have a MBR partition table on /dev/sda
, use this command:
parted /dev/sda mklabel msdos
This tutorial creates a GPT partition table:
parted /dev/sda mklabel gpt
Now create partitions on /dev/sda
parted /dev/sda
If you created GPT partition table in the previous step, you need to create a bios_grub
partition of 1MiB since the default firmware for KVM virtual machine is seaBIOS which is a free and open source BIOS implementation. Later the Grub 2 boot loader will be installed inside bios_grub partition.
Make ensure that bios_grub partition starts at least 31 KiB (63 sectors) from the start of the disk because the first 63 sectors is reserved for MBR boot code. However, it will give us performance benefit if we align partitions so the bios_grub partition might start at 1MiB from the start of the disk.
Create bios_grub partition with this command:
mkpart primary 1MiB 2MiB
Set it as a bios_grub partition
set 1 bios_grub on
Then create the second partition. 100% means it will use all the following space of the disk. This tutorial use a single root partition. If you need advanced setup, you can adjust it.
mkpart primary 2MiB 100%
Exit out of parted.
q
Now format the second partition to ext4 file system.
mkfs -t ext4 /dev/sda2
Mount the second partition in /mnt directory.
mount /dev/sda2 /mnt
Step 4: Installing Basic Stuff
First open the mirrorlist file to choose a good mirror for your software installation.
nano /etc/pacman.d/mirrorlist
To choose a mirror, just copy the address of your preferred mirror to the beginning of the file then save and close this file.
Now use pacstrap to install the base system onto the second partition mounted under /mnt
directory.
pacstrap -i /mnt base
After that, generate a fstab
file.
genfstab -U -p /mnt >> /mnt/etc/fstab
Chroot into the base system.
arch-chroot /mnt
Generate locale.
nano /etc/locale.gen
Find the en_US.UTF-8 UTF-8 line and remove the # sign from this line. Save this file.
Generate /etc/locale.conf
file and set en_US.UTF-8
as the default locale.
echo LANG=en_US.UTF-8 > /etc/locale.conf export LANG=en_US.UTF-8
Set your server’s time zone. I set it to New York.
ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
The core, extra and community repository is good enough for an Arch Linux server and they are enabled by default, so normally you don’t have to configure repositories. If for any reason you have to configure it, use nano text editor to edit /etc/pacman.conf
file.
nano /etc/pacman.conf
After that, set a password for root user.
passwd root
Install Grub and os-prober.
pacman -S grub os-prober
Install Grub boot loader to the first disk. Since we are using BIOS firmware, so the target should be i386-pc.
grub-install /dev/sda --target=i386-pc
Generate Grub boot menu.
grub-mkconfig -o /boot/grub/grub.cfg
Exit out of chroot environment.
exit
Reboot your KVM VPS.
shutdown -r now
Step 5: Post-installation
Now your KVM VPS is rebooted, connect to it again via VNC. Login as root. Run the following command:
ping google.com
Your new Arch Linux server is probably not connected to the Internet.
So we have to create a static Ethernet connection to the KVM host (gateway). Here, we have to make a little modification to the ethernet-static
network profile.
First copy the example ethernet-static
network profile to /etc/netctl/
directory.
cp /etc/netctl/examples/ethernet-static /etc/netctl
Then edit this file.
nano /etc/netctl/ethernet-static
Make the following changes.
Description="A basic static ethernet connection" Interface=ens3 Connection=ethernet IP=static Address=('your-vps-public-IP-address/24') #Routes=('192.168.0.0/24 via 192.168.1.2') Gateway=('your-gateway-IP') DNS=('8.8.8.8')
The default Ethernet interface in Arch Linux is named ens3
, you can use ip address
command to find out. Add /24
to your VPS public IP address. The /24 is equivalent to 255.255.255.0. You must use CIDR notation here.
Save and close the this file. Bring down the ens3 interface.
ip link set dev ens3 down
Load ethernet-static
network profile.
netctl start ethernet-static
To automatically load the profile at next boot, run:
netctl enable ethernet-static
You should now be able to access the Internet from your Arch Linux server.
ping google.com
Now create a user and add it to wheel, storage, power group.
useradd -m -g users -G wheel,storage,power -s /bin/bash <username>
Set password for this user.
passwd <username>
Install sudo utility.
pacman -S sudo
Edit /etc/suoders
file.
EDITOR=nano visudo
Find this line:
# %wheel ALL=(ALL) ALL
Remove # sign and save the file. This means allowing members of the wheel group to use sudo.
Install SSH server
pacman -S openssh
Edit sshd_config
file.
sudo nano /etc/ssh/sshd_config
Add these two lines at the end of this file. Adjust the username.
AllowUsers <username>
PermitRootLogin no
The first line means allowing your newly created user to ssh into Arch Linux server. The second disable root ssh login. This is a basic requirement of Linux server security. Save and close this file.
Start SSH server
systemctl start sshd
Enable SSH server auto-start when Arch Linux is booted up
systemctl enable sshd
Now open a SSH client on your own computer, and try to SSH into your Arch Linux server. You should be able to ssh login as the normal user and should not be able to ssh login as root user.
Once you ssh into your server, update Arch Linux.
sudo pacman -Syu
Here are some tools you may want to install.
sudo pacman -S wget unzip parted htop
Enable NTP network time synchronization.
sudo timedatectl set-ntp true
Check NTP status
timedatectl status
Congrats! You just installed an Arch Linux on KVM VPS. And lastly, it’s a good idea to subscribe to Arch Linux latest news feed because there might be some important changes and you need to follow those instructions in order to update software packages.
As always, if you found this post useful, then please subscribe to our free newsletter or follow us on Google+, Twitter or like our Facebook page. Thanks for visiting!
Thank you, the tutorial worked perfectly for me.
Thanks for this tutorial!
You have a lil’ typo on the command for flag assignation:
set 1 biso_grub on -> set 1 bios_grub on
The typo was corrected. Thanks for pointing it out.
How would I get VNC information from Linode for the one-click-install Arch VPS?
With Linode one-click install Arch Linux, the installation is done automatically, just like other Linux distributions like Ubuntu or CentOS. So you don’t need to manually install the OS via VNC.
If you would like to manually install it, you can lunch the glish or weblish console in Linode control panel to log into the server. The weblish or glish will establish a secure VNC connection to the server.