Install Arch Linux in virtualbox
Pre-installation
Acquire an installation image
Arch is a “rolling release” distribution, download the .iso
file from its offical site.
Create VM
Create a vm in virtualbox, make sure enable EFI
in the motherboard. We will use use UEFI instead of the older BIOS spec to boot the VM.
Verify the boot mode
To verify the boot mode, list the efivars directory:
|
|
If the command shows the directory without error, then the system is booted in UEFI mode.
Partition the disks
We are going to use a simple partition scheme:
- an EFI system partition (ESP)
- one encrypted partition that holds our root filesystem
- a small partition for swap space
List storage device
|
|
Start the actual partitioning process, run fdisk /dev/sda
- Create a GPT table by typing
g
(then hit enter). - Create your ESP by typing
n
. - Type
t
to change the type of the new partition (partition 1) to “EFI System”. - Create your main root partition by typing
n
again. (This partition should already have the correct type, “Linux filesystem”) - Create your swap partition by typing
n
and just take all the defaults. - Type
t
to change the type of the swap partition (partition 3) to “Linux swap” - Type
p
to show the current partition table. You should see an “EFI System” partition, a “Linux filesystem” partition, and a “Linux swap” partition. - Type
w
to finally actually write the changes to disk.
Create filesystems
ESP
The ESP (EFI System Partition) has to be in a FAT format. Find ESP partition fdisk -l /dev/sda
it should be sda1
mkfs.fat -F32 /dev/sda1
to create the FAT32 filesystem.
Root partition
Root partition should be /dev/sda2
, we are going to encrypt it. Details refer Arch doc
|
|
|
|
Open the encrypted partition
|
|
Use lsblk
to see the hierarchy of these partitions, create the actual filesystem
|
|
Swap
|
|
Mount the new filesystems
|
|
Installation
For details check arch wiki
Install essential packages
|
|
Configure the system
Fstab
Generate an fstab file (use -U
or -L
to define by UUID or labels, respectively):
|
|
Chroot
|
|
vim
is not installed in the chroot by default. You can do pacman -S vim
to install it
Time zone
|
|
Run hwclock(8) to generate /etc/adjtime
:
|
|
Localization
Edit /etc/locale.gen
and uncomment en_US.UTF-8 UTF-8
and other needed locales. Generate the locales by running:
|
|
Network configuration
Create the hostname file:
|
|
Add matching entries to hosts(5):
|
|
initramfs
On Arch, there’s a system to generate initramfs, need to make sure add disk encryption support.
|
|
Run mkinitcpio -p linux
to generate the new initramfs based on the new config file.
Root password
|
|
Boot loader
Historically, GRUB has been the only reasonable choice of boot loader. with the advent of UEFI, there are lots of different good options, we will use systemd-boot.
install systemd-boot
|
|
Create a bootloader entry
|
|
Make sure replace 2b219d331-8ea6-4678-ae6b-f041ee146bd2
with the correct UUID for the encrypted /dev/sda2
partition.
|
|
Enable DHCP and SSH
|
|
Type exit
to exit the chroot and then type reboot
Config static IP (optional)
|
|
That’s all 🎉