[GUIDE] archlinux VM with EFI


twiikker

Recommended Posts

Hello.

 

Here is my commands which i've now used multiple times to install archlinux as VM inside Unraid with EFI.

 

Currently on unraid version: 6.9.0-beta25 and on AMD system.

 

Tell me if there is any problems with it.

 

NEW: There is nowdays guided install script in latest arch isos. So you can also run archinstall and it is much simpler method.

Tested it with I440fx-5.1/Q35-5.1 and systemd-boot on archlinux-2021.10.01-x86_64.iso

 

Add VM --> Select Arch

 

Machine: I440fx-5.1 or Q35-5.1

BIOS: OVMF

Select OS Install ISO

Primary vDisk Size: 20G

Select keyboard layout!

CREATE

 

Connect to VM

 

NEW: At this point you can run command: archinstall

guided installation method. You can install minimal desktop and do GUI installation step from guide to get same lxde desktop or choose another from desktop installation method.

 

localectl list-keymaps                                #lists all keymaps

loadkeys fi                                               #your keymap fi/en/swe etc whatever you want

ls /sys/firmware/efi/efivars                       #checks if efi is enabled

ping google.com                                      #check that you have connection

timedatectl set-ntp true                          #sets ntp

 

fdisk -l                                                    #lists disks

 

gdisk /dev/vda                                           #open gdisk on your virtual drive

------------- gdisk /dev/vda ------------------
n(enter) >> enter >> enter >> +550M(enter) >> EF00(enter)     #efi partition
n(enter) >> enter >> enter >> +18G(enter) >> enter                 #linux partition 18G for 20GB vDisk 28G for 30GB vDisk etc
n(enter) >> enter >> enter >> enter >> 8200(enter)                 #swap partition, rest of disk as swap

w+y                                                                                       #writes changes

---------------------------------------------------------

 

mkfs.fat -F32 /dev/vda1                             #formats efi partition
mkfs.ext4 /dev/vda2                                  #formats linux parition
e2label /dev/vda2 "arch_os"                      #labels vda2 as arch_os
mkswap /dev/vda3                                    #formats swap partition
swapon /dev/vda3                                     #sets swap partiton

 

mount /dev/vda2 /mnt                               #mounts linux partition to /mnt

mkdir /mnt/boot                                       #makes boot folder inside /mnt


mount /dev/vda1 /mnt/boot                       #mounts efi partition to /mnt/boot

 

pacstrap /mnt base                                  #installs arch to /mnt

 

genfstab -U /mnt >> /mnt/etc/fstab           #generated fstab

 

arch-chroot /mnt                                      #changes root location to /mnt aka where just installed arch

timedatectl list-timezones                         #list available timezones

timedatectl set-timezone Europe/Helsinki    #set your zone as default

hwclock --systohc                                    #sets hardware clock

 

pacman -S nano                                      #installs nano text editor

 

nano /etc/locale.gen                                #remove comment mark (#) infront of your preferred language 

locale-gen                                                #generates locales

 

nano /etc/vconsole.conf                            #open/create file
------- /etc/vconsole.conf ----------
KEYMAP=fi                                               #sets keyboard layout, CTRL+X >> y >>  enter
---------------------------------------------------

 

nano /etc/hostname                                 #open/create file
-------- /etc/hostname ---------------
archlinux                                                #sets hostname for your machine, CTRL+X >> y >>  enter
--------------------------------------------------

 

nano /etc/hosts                                       #open/create file
------ /etc/hosts -----------------------
127.0.0.1           localhost
::1                    localhost
127.0.1.1            archlinux.workgroup    archlinux               #CTRL+X >> y >>  enter
-------------------------------------------------

 

pacman -S linux linux-firmware dhcpcd        #installs linux package, press 1 on question, linux-firmware and dhcpcd

pacman -S amd-ucode                              #intel-ucode for intel systems 

passwd                                                    #sets password for root

bootctl install                                           #installs efi bootmgr

 

nano /boot/loader/loader.conf                     #bootloader config
------ /boot/loader/loader.conf -----------------
default arch.conf
timeout 4
console-mode max
editor no                    #CTRL+X >> y >>  enter
-------------------------------------------------

 

nano /boot/loader/entries/arch.conf             #boot options for arch
------ /boot/loader/entries/arch.conf -----------
title Arch Linux
linux /vmlinuz-linux
initrd /amd-ucode.img                                #/intel-ucode.img for intel systems
initrd /initramfs-linux.img
options root="LABEL=arch_os" rw            #CTRL+X >> y >>  enter
-------------------------------------------------

 

exit                                                        #exits arch-chroot

reboot                                                    #reboots system


ip link                                                      #to find ethernet port

dhcpcd ens1                                           #set dhcp up

ping google.com                                      #test connection

 

-------------- GUI installation start ---------------------

pacman -S lxde                                       #installs lxde (you can install whatever GUI you want)

 

#optional apps
pacman -S firefox                                   #installs firefox
pacman -S transmission-gtk                    #installs transmission GUI
 

systemctl enable lxdm                            #enables lxdm service

nano /etc/lxdm/lxdm.conf                       #opens lxdm config
session=/usr/bin/startlxde                      #edit session to match as following (uncomment it)

reboot                                               

setxkbmap fi                                         #inside gui enviroment sets your keymapping

-------------- GUI installation end ---------------------


dhcpcd ens1                                         #if you dont have network
systemctl enable dhcpcd@ens1           #creates startup service for ens3

pacman -Syy                                        #update package list
pacman -Su                                         #install updates

 

#optional: user creation for sudoing
useradd -m -s /bin/bash arch                 #creater new user, arch is username
passwd arch                                         #sets password for arch

pacman -S sudo                                    #installs sudo package

EDITOR=nano visudo                             #edit sudo config

arch ALL=(ALL) ALL                              #add this line with your username under root ALL=(ALL) ALL and CTRL+X >> y >>  enter

 

reboot                                               #reboot

DONE

 

twiikker

Edited by twiikker
  • Like 2
  • Thanks 3
Link to comment
  • 5 months later...
  • 1 month later...
  • 2 weeks later...

Glad that it worked. Maybe you missed something from list.

"mkinitcpio -p linux" didnt work without "pacman -S linux" on latest builds and brought me on grub promt also.

 

I'll just remove those update notes from commands that they won't lead people to skip those.

 

Have to take look on that initial command.

 

Link to comment

Another slight modification:

 

Replace:

[root@archlinux]# hwclock --systohc                                    #sets hardware clock
[root@archlinux]# locale-gen                                           #generates locales

With the following:

[root@archlinux]# hwclock --systohc                                    #sets hardware clock
[root@archlinux]# nano etc/locale.gen                                  #edit locale gen file

remove comment on relevant locale line (e.g., en-US UTF-8)

[root@archlinux]# locale-gen                                           #generates locales
Link to comment
  • 4 months later...

Another change I found when installing. a new fresh arch VM

 

grub-install --target=x86_64-efi --efi-directory=/mnt/boot --boot-directory=/mnt/boot --bootloader-id=grub             #installs grub

arch-chroot /mnt                                     #back to /mnt root

pacman -S grub                                       #installs grub package to installation

the grub-install command won't be found. You need to install grub first.

Link to comment
On 7/7/2020 at 9:13 PM, tknx said:

Another change I found when installing. a new fresh arch VM

 


grub-install --target=x86_64-efi --efi-directory=/mnt/boot --boot-directory=/mnt/boot --bootloader-id=grub             #installs grub

arch-chroot /mnt                                     #back to /mnt root

pacman -S grub                                       #installs grub package to installation

the grub-install command won't be found. You need to install grub first.

Gonna take a look on this after i get my server upgrade up and running. Still waiting some extra parts :)

Link to comment
1 hour ago, BiGBaLLA said:

Thanks for keeping this updated! I really appreciate it. I feel like I'm adding a different vm every month or so.

 

Only note, you may want to update the two comments for the intel options that are pointing to amd.

 

#/intel-ucode.img for amd systems

 

Thanks! Had those ucode thigys other way around and missed rest of comment :)

Link to comment
  • 1 month later...
14 minutes ago, SavageAUS said:

I've tried installing the xf86-video-qxl to improve graphics in the vm i created but when i install that package i boot to a black screen.

Any suggestions?

I think that qxl in unraid and qxl inside VM are completely separate thing. Like qxl in unraid connects straight to KVM engine and not to the OS. And when you installed that package inside VM it distrupted the connection somehow. For fixing it you could try to boot into install media mount disks like in guide, chroot to /mnt and remove that qxl package.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.