Archlinux Install
Installing ArchLinux
Considerations
One of the reasons for moving on from Gentoo was a lack of any definitive process in the community forums or documentation for setting up a RAID based system. When googling this, all of the related documentation seemed to generate hits from the Arch community docs.
This guide focuses on setting up a system using twin SSD drives in a RAID1 configuration. A step-by-step guide for doing this was found here but was incomplete, so this wiki is basically some experimentation after where this guide went south.
Moving forward, new motherboards boot using UEFI. At the time of this writing, the grub bootloader requires two boot partitions for UEFI, so an approach to simplify this into a single UEFI boot partition and an alternative bootloader is desired.
Further, previous implementations involved a RAID1 swap space. This has never been a problem, but the possibility of a corrupted swap and system crash exists in the case where one disk fails. Since the kernel stripes swap if multiple spaces exist which improves performance and adds redundancy, the swap space is no longer in a RAID configuration but spanned across the two disks.
Install Prep
Review the documentation and download the boot media
Before getting started you'll probably want to review the ArchLinux install guide and download the latest iso image. I copied the image to a USB drive mounted as /dev/sdf:
$ sudo dd if=Downloads/archlinix_install_image.iso of=/dev/sdf
After this, the USB was inserted into the motherboard, the system powered and the USB selected as the boot device via BIOS. After startup of the live image, Arch offers up a root prompt.
Confirm networking
Confirm you have network access by pinging google or something else. Use ifconfig to determine the local IP.
Enable ssh daemon
There is really no need to do an install by typing out command after command, so an ssh session is necessary and sufficient. In order to get this set up, the first step is to set the root password
# passwd
And then start the sshd service
# systemctl start sshd
You can then ssh into the system from another computer on your network, preferably one with internet access so you can copy-and-paste commands from the install guide or this wiki.
Preparing the disks
It should be noted that this guide focuses on setting up the system using a single drive, then adding the second after the install is complete, in order to have both systems running at the same time and perform a migration.
It may be necessary to stop and remove any previous RAID devices.
# cat /proc/mdstat
Stop any md devices shown in the output.
# mdadm --stop /dev/md0 # mdadm --stop /dev/md1 # mdadm --stop /dev/md2
Remove the devices.
# mdadm --remove /dev/md0 # mdadm --remove /dev/md1 # mdadm --remove /dev/md2
Blow away the mdadm superblock, if possible.
# mdadm --zero-superblock /dev/sda
Remove any boot data and partition table.
# dd if=/dev/null of=/dev/sda bs=512 count=1 # dd if=/dev/null of=/dev/sda bs=446 count=1
Create partition schema using gdisk
Identify what device has been assigned to your primary disk (usually this is /dev/sda) and open it using gdisk.
# gdisk /dev/sda
Once in the gdisk interface, you can use p to show the existing partition schema. Since we are creating a new partition schema, it makes sense to delete the current schema using d. Once complete, the partition schema should be empty:
Command (? for help): p Disk /dev/sda: 468862128 sectors, 223.6 GiB Model: KINGSTON SH103S3 Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): 0356C9E8-4FEB-4F09-A617-54F462861ABD Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 468862094 Partitions will be aligned on 2048-sector boundaries Total free space is 468862061 sectors (223.6 GiB) Number Start (sector) End (sector) Size Code Name Command (? for help):
Create the boot/UEFI partition using n. Use the default sector as its starting point (2048). I created a 512M partition using +512M when prompted. When prompted for the code for the partition, FD00 was entered as per the documentation.
Next, the swap partition was created, with a size of 1G. For this partition, the code required was 8200. Finally, the primary root partition was created. The remainder of the disk was used for the partition as per defaults. The partition type also configured as Linux RAID. The partition layout now appears as follows:
Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB FD00 Linux RAID 2 1050624 3147775 1024.0 MiB 8200 Linux swap 3 3147776 468862094 222.1 GiB FD00 Linux RAID
w was used to write this partition table to the disk.
Create the RAIDs
We now create the RAID devices with a single disk only. This is unorthodox but required while our other disk is in use to stage the install. The first drive is creating using older metadata, as noted in the documentation.
# mdadm --create /dev/md0 --metadata 1.0 --raid-devices=2 --level=1 /dev/sda1 missing
Finally, we create the root filesystem array. mdadm gives a warning here about using a recent metadata device as a boot partition. Since this isn't our boot partition, we can ignore this warning and go ahead with creating the array.
# mdadm --create /dev/md1 --raid-devices=2 --level=1 /dev/sda3 missing
Apply filesystems
The UEFI partition needs to be formatted as FAT32.
# mkfs.fat -F32 /dev/md0 mkfs.fat 4.1 (2017-01-24)
The second partition is the swap space.
# mkswap /dev/sda2 # swapon /dev/sda2
Note that after we install and configure the second disk, we'll need to configure that disk's swap space in a similar fashion. The last partition can be whatever is desired; in this case, ext4.
# mkfs.ext4 /dev/md1 mke2fs 1.43.6 (29-Aug-2017) ... Writing superblocks and filesystem accounting information: done
Mount the partitions
In order to perform the install, the newly created partitions and their filesystems need to be mounted.
# mount /dev/md1 /mnt # mkdir /mnt/boot # mount /dev/md0 /mnt/boot
Install the base system
Now that the partitions have been mounted, it's time to install the base system.
# pacstrap -i /mnt base
There will be a number of questions and prompts... simply go with defaults or press y as needed.
generate mdadm and fstab
The guide mentions updating the configuration, so let's just do that...
# mdadm --detail --scan >> /mnt/etc/mdadm.conf # genfstab -U -p /mnt >> /mnt/etc/fstab
chroot into the new environment
As one would expect, we change root to the newly configured environment.
# arch-chroot /mnt /bin/bash
configure regional settings
# ln -sf /usr/share/zoneinfo/America/Vancouver /etc/localtime # locale-gen # nano /etc/hostname (enter your host name and save the file) # nano /etc/hosts (add your hostname to the appropriate entries)
configure network
dhcpcd is simple and elegant, but networkmanager has some additional features, such as connectivity to AnyConnect and L2TP endpoints, which I require.
# pacman -S networkmanager
Configure network manager to start with the system.
# systemctl enable NetworkManager
install mdadm
This isn't included with the default packages, so for the system to work, you better install it!
# pacman -S mdadm
regenerate the initramfs
Since we are using RAID, we need to update the HOOKS section of the fancy new mkinitcpio.conf:
# nano /etc/mkinitcpio.conf
Enter the directive mdadm_udev after udev;
HOOKS="base udev mdadm_udev autodetect block filesystems usbinput fsck"
Re-generate the initramfs with the new hook.
# mkinitcpio -p linux
set the root password
Don't forget this or you'll be locked out and have to boot with install media and chroot to set it.
# passwd
configure bootloader
Gummiboot will be used in this case as an alternative to grub.
# pacman -S gummiboot
...aaaand this no longer works, fuck.
So, this was abandoned, and I decided to go with a single drive installation with the intention of RAIDing later. My adventures with Arch continue here.