Continuing the Arch Linux installation on a PC or virtual machine¶
This section assumes that you have prepared your PC or virtual machine as described in Prepare a PC to develop for UBOS using Arch Linux or Prepare a VirtualBox virtual machine to develop for UBOS using Arch Linux.
Once the boot process has finished and you get a root shell, you are not done: you only managed to boot from the install disk image, you do not have a runnable system yet. In this respect, ArchLinux is different from other Linux distros.
In the shell that came up, perform the actual installation. The following steps should work. If you need more information, consult the Arch Linux installation guide:
Partition your root disk /dev/sda in a way that makes sense to you. If you are not sure, here is a somewhat complicated scheme (sorry!) that should work with dual BIOS and EFI boot. (This could be simpler if we knew more about your PC, such as whether but we don’t, and so we rather be safe.)
We start by zeroing out some bytes; sometimes there are strange leftovers from previous installs:
# dd if=/dev/zero of=/dev/sda bs=1M count=8 conv=notrunc
Clear the partition table:
# sgdisk --clear /dev/sda
Create the partition and change them to the right types:
# sgdisk --new=1::+1M /dev/sda # sgdisk --new=2::+100M /dev/sda # sgdisk --new=3:: /dev/sda # sgdisk --typecode=1:EF02 /dev/sda # sgdisk --typecode=2:EF00 /dev/sda
Make sure changes are in effect:
# sync # partprobe /dev/sda
Create filesystems for your partitions 2 and 3 (the first does not need one). Partition 2 must be a DOS partition per the UEFI spec. For the 3rd (main) partition, you could use any filesystem, but we recommend btrfs as it is tightly integrated with systemd-nspawn, the systemd container tool. This may save you a substantial amount of disk space if you might run several UBOS instances in containers later on, e.g. for testing. Execute:
# mkfs.vfat /dev/sda2 # mkfs.btrfs /dev/sda3
Mount your future root partition in a place where you can install software:
# mount /dev/sda3 /mnt
and add the /boot partition:
# mkdir /mnt/boot # mount /dev/sda2 /mnt/boot
Make sure you have a network connection:
# ip addr
will show whether you have an IP address, and which networking devices are available. If you are in VirtualBox and have trouble, here is more information on VirtualBox networking modes. By default, your machine is looking for a DHCP server to obtain an IP address from on all available network interfaces.
Perform the actual install. This will download and install a lot of packages and thus may take a while, depending on your network speed:
# pacstrap /mnt base
Create the right fstab by executing:
# genfstab -p /mnt >> /mnt/etc/fstab
Chroot into your future root disk and finish the installation:
# arch-chroot /mnt
If you chose btrfs, install the btrfs tools:
# pacman -S btrfs-progs
You also need a boot loader and sudo:
# pacman -S grub sudo
If you are on VirtualBox, also install the VirtualBox client tools:
# pacman -S virtualbox-guest-modules-arch virtualbox-guest-utils
Create a Ramdisk:
# mkinitcpio -p linux
Configure the Grub boot loader for legacy (BIOS) boot:
# grub-install --target=i386-pc --recheck /dev/sda # grub-mkconfig -o /boot/grub/grub.cfg
Configure the systemd boot loader for modern (UEFI) boot:
# bootctl --path /boot install
UEFI boot needs some more data. Create directory /boot/loader/entries if it does not exist yet:
# mkdir /boot/loader/entries
Create file /boot/loader/loader/loader.conf with content:
timer 4 default arch
Determine the UUID of the root partition (not: disk) and put it into the to-be-edited file that will need it:
# lsblk -o UUID /dev/sda3 > /boot/loader/entries/arch.conf
Now edit the created file /boot/loader/entries/arch.conf so that it looks like this, where XXX is the UUID contained in the file when you first opened it.
title Arch linux /vmlinuz-linux initrd /initramfs-linux.img options root=PARTUUID=XXX rw
(sorry, this is a bit more complicated than we’d like; thanks UEFI!)
Install a Locale. Edit /etc/locale.gen, and uncomment this line:
so it looks like this:
You can also uncomment whatever other locales you might want. Then run:
Set this locale as the system locale:
# localectl set-locale LANG=en_US.UTF-8
Exit from the chroot shell with ctrl-d.
Set up networking. There are many options. We recommend using systemd-networkd and systemd-resolved in the way UBOS does it so UBOS containers and the Arch Linux host play nicely:
# rm /mnt/etc/resolv.conf # ln -s /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf # arch-chroot /mnt systemctl enable systemd-networkd systemd-resolved
Also create file /mnt/etc/systemd/network/wired.network with the following content:
[Match] Name=en* [Network] DHCP=ipv4 IPForward=1
The IPForward setting is necessary if you plan to run or test UBOS in a Linux container, so it can reach the internet.
Shut down the machine:
# systemctl poweroff
While the machine is shut down, remove the installation medium from the drive. If you are on VirtualBox, remove the ISO file from the virtual CD/DVD drive. To do that:
- Select the virtual machine in the sidebar.
- Click “Settings”.
- Pick the “Storage” tab.
- In the “Storage Tree”, select the virtual CD/DVD drive.
- In the right pane, click the little CD icon and select “Remove disk from virtual drive” in the pop-up that comes up.
- Click OK.
Then, start the machine again and log on as root. There is no password by default. You might want to change that, by saying:
Create a non-root user (example: joe, change as needed). Use this user when developing instead of doing everything as root. Also allow the user to become root with sudo as needed, and set a password for it:
# useradd -m joe # passwd joe # cat > /etc/sudoers.d/joe joe ALL = NOPASSWD: ALL ^D # chmod 600 /etc/sudoers.d/joe
Install the desktop environment you might want to use. For example, to use KDE with the plasma desktop:
# pacman -S xorg-server sddm plasma-meta konsole # systemctl enable sddm
If you are on VirtualBox, enable the VirtualBox client tools:
# systemctl enable vboxservice