Gist Github Com Miliarch
Gist Github Com Miliarch
in Sign up
miliarch / install-arch-in-virtual-machine.md
Star 1
Fork 0
install-arch-in-virtual-machine.md Raw
Video tutorial
A video is available that introduces Arch Linux and covers OS configuration steps if you would prefer that format:
References
I used the following references to learn how to install Arch Linux in a virtual machine:
Table of contents
Pre-install steps
Download and verify Arch Linux media
Create Virtual Machine
Boot system to Arch Linux live distro
Install steps
Check system capabilities
Verify boot mode
Verify network availability
Sync network time
Configure storage
Write partition table
Create primary partitions
Create LVM volumes
Format partitions and enable swap
Mount filesystems
Install packages and chroot into system
Install essential packages
Update system's filesystem table
Chroot into system
Configure System
Set root password
Set time zone and synchronize time
Set localization
Configure networking
Set hostname and hosts aliases
Update initial ramdisk hooks
Generate boot image and configure boot loader (GRUB)
Update initial ramdisk
Install GRUB
Configure GRUB
Post-install steps
Reboot into system
Pre-install steps
There are a handful of VM settings that really matter for this gist:
Aside from the above, configure the virtual machine to your liking.
Install steps
ls /sys/firmware/efi/efivars
If you get an error indicating that the directory does not exist, the system did not boot using UEFI, and you need to
enable UEFI boot in VM settings.
ip link
ip addr
Example output:
root@archiso ~ # ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1
link/ether 00:0c:29:98:d8:51 brd ff:ff:ff:ff:ff:ff
altname enp2s1
root@archiso ~ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
altname enp2s1
Your interface name will vary depending on factors, but lo is not the one you're looking for - if that's the only interface
you see, you'll need to troubleshoot. Some common primary interface names are eth0 , ens33 , ens160 , and enp0s3 .
The default in VMware Workstation 15 is ens33 .
Ensure the system clock is synced (this is important for encrypted connections to succeed):
Configure storage
In this step we'll use fdisk to write a GUID partition table (GPT) to local disk (/dev/sda).
Launch fdisk :
fdisk /dev/sda
The g command stages the change to GPT for the disk, the w command writes it.
In this step we'll use parted to create, name, and set options against the primary partitions required to boot the system
and define LVM volumes.
Launch parted :
parted /dev/sda
name 1 efi
name 2 boot
name 3 lvm
set 1 boot on
set 3 lvm on
quit
The mkpart command creates a new partition. The EFI partition is the first partition we define, and it has an ESP type,
will have a fat32 filesystem, and has a 512 MiB total size (starting at the 1MiB offset, ending at the 513MiB offset). The
next partition is our boot partition, type primary , size 512 MiB. The last partition is our LVM partition, type primary ,
filling the remaining portion of the disk.
With the above explanation, name should be evident - these are labels that will be useful when managing partitions on
the system, and describe the function of each partition.
We then set the boot flag to on for the EFI partition (partition 1 ), and the lvm flag to on for the LVM partition
(partition 3 )
root@archiso ~ # parted -l
Disk Flags:
root@archiso ~ # lsblk
pvcreate /dev/sda3
Next, run the vgcreate command to create a volume group on our new physical volume:
Last, run the following sequence of lvcreate commands to create logical volumes on our new volume group:
arch : The name of the volume group to create the logical volume on
You can use the pvs , vgs , lvs , and lsblk commands to verify these changes:
root@archiso ~ # pvs
root@archiso ~ # vgs
root@archiso ~ # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root@archiso ~ # lsblk
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/arch/root
mkfs.ext4 /dev/arch/var
mkfs.ext4 /dev/arch/home
swapon /dev/arch/swap
--------------------------------------------------------------------------------------------------------------
/dev/sda3 LVM2_member (in use) yjpORe-gJ4d
/dev/sr0 iso9660 ARCH_202008 /run/archiso/bootmnt 2020-08-01-
/dev/loop0 squashfs /run/archiso/sfs/airootfs
Mount filesystems
Create directories for the efi , boot , var , and home filesystems:
root@archiso ~ # mount|tail -n 5
root@archiso ~ # lsblk
Run the following commands to install essential packages into the mounted partitions:
Don't worry about any localization related errors you may receive - these will be resolved by future steps.
While the installation guide only includes the base , linux and linux-firmware packages in this command, these
packages are the minimum required to progress with installation. The extra packages specified in this guide are:
These are the same packages that would install using pacman -S packagename . You may want to install additional
packages - go for it!
Update system's filesystem table
Use the following command to generate fstab format mount entries and append those entries to the new system's
/etc/fstab file:
arch-chroot /mnt
Configure System
Change the root user's password so login is possible on first boot into the new system:
passwd
Additional time zones can be found in /usr/share/zoneinfo , just look around with ls to find the most relevant one.
hwclock --systohc
Set localization
Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and other needed locales (source).
locale-gen
Create /etc/locale.conf and save the following line (or your preferred locale) to it:
LANG=en_US.UTF-8
Configure networking
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1
link/ether 00:0c:29:98:d8:51 brd ff:ff:ff:ff:ff:ff
altname enp2s1
[Match]
Name=ens33
[Network]
DHCP=yes
If you would prefer to set static addressing, or have multiple network interfaces, I recommend reviewing the systemd-
networkd documentation in the Arch Wiki.
Edit /etc/hostname and save the following line (or your preferred hostname) to it:
arch.localdomain
Edit /etc/hosts and save the following lines to it (modifying hostname as needed):
127.0.0.1 localhost
::1 localhost
The mkinitcpio program generates the initial ramdisk (initramfs) image based on configuration specified in
/etc/mkinitcpio.conf . Because this gist uses LVM partitions, we need to include lvm2 (the name of our LVM package)
to HOOKS , before filesystems is specified (these hooks load in order).
In order for the /etc/mkinitcpio.conf change to apply on system boot, we need to update our initial ramdisk (initramfs).
mkinitcpio -P
Install GRUB
Run the following command to install the GRUB with an EFI target system/directory:
Configure GRUB
grub-mkconfig -o /boot/grub/grub.cfg
grub-mkconfig -o /efi/EFI/arch/grub.cfg
Post-install steps
kendofriendo
commented on Aug 6, 2022
Thanks!
© 2023 GitHub, Inc. Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About