Two Distros, One $BOOT and no /etc/fstab

OK, let's start off by saying:

No /etc/fstab

Unless you are doing something "unusual" like mounting your NAS over NFS on boot, or have $HOME on a separate disk (separate partition is good) you don't need an /etc/fstab config at all. Currently my /etc/fstab has one line for my guest account tmpfs and one for a bind mount.

systemd can automatically detect and mount the usual filesystems, as long as they have the correct metadata. Setting up the partition types is easy, we already do it for swap and $BOOT. In fdisk we need to press t to change the type, then:

Bham you can now clean up your /etc/fstab, except for anything not on the same disk, separate home drive? Keep it. NFS? Keep it.

No bootloader

UEFI is our bootloader, we don't need another bootloader like gurb, what we actually need is a "boot manager" like systemd-boot. Doing this actually means each of our dual booting distros can and should use the same $BOOT. Since it's not actually a bootloader anymore some people, including myself are now using /efi instead of /boot but I'm going to carry on calling it $BOOT.

Ideally $BOOT should be laid out like this:

$BOOT/

And that would give us 3 boot options, "Arch Linux", "Arch Linux LTS" and "Fedora" however Arch and Fedora both believe that they own $BOOT and ruin the fun.

One way to fix this is by letting the distros have there way with /boot directory in there own / and manually managing my actual boot partition mounted at /efi. However there is a cooler way to do this...

It requires use of /etc/fstab. Bind mount /efi/EFI/ArchLinux to /boot in Arch and /efi/EFI/Fedora to /boot in Fedora. Then our $BOOT is almost perfect, well good enough. We still have to manage the loader confs, but it's not that hard and allow $BOOT/EFI/*/ to be a bit messy, but I can live with that.

This is how I set up a Arch/Fedora dual boot sharing $BOOT and almost no /etc/fstab.

Using fdisk to set up the disk, I created $BOOT, Arch Root, Fedora Root, Swap and Shared Home, all with the correct types.

sudo fdisk /dev/sdb
g
n
1 (default)
2048 (default)
+2G
n
2 (default)
4196352 (default)
+10G
n
3 (default)
25167872 (default)
+10G
n
4 (default)
(default)
+16G
n
5 (default)
(default)
(default)
t
1
1
t
2
22
t
3
22
t
4
19
t
5
28
x
n
1
EFI System Partition
n
2
Arch Root
n
3
Fedora Root
n
4
Swap
n
4
Shared Home
r
w

Lets format all the filesystems,

sudo mkfs.fat -F32 /dev/sdb1
sudo mkfs.ext4 /dev/sdb2
sudo mkfs.ext4 /dev/sdb3
sudo mkswap /dev/sdb4
sudo mkfs.ext4 /dev/sdb5

Install Arch, follow the install guide, but basically, mount it at /mnt, bind mount /boot, pacstrap and write the bind mine to /etc/fstab.

sudo mount /dev/sdb2 /mnt
sudo mkdir /mnt/{efi,home}
sudo mount /dev/sdb1 /mnt/efi
sudo mount /dev/sdb5 /mnt/home
sudo mkdir /mnt/boot
sudo mkdir -p /mnt/efi/EFI/ArchLinux
sudo mount --bind /mnt/efi/EFI/ArchLinux /mnt/boot
sudo pacstrap /mnt base
sudo echo "/efi/EFI/ArchLinux	/boot	none	defaults,bind	0	0" >> /mnt/etc/fstab

Now we'll need to set up systemd-boot:

sudo bootctl --path=/mnt/efi install

But before we're done with Arch, lets create the boot entry.

/mnt/efi/loader/entries/$(cat /mnt/etc/machine-id)-4.12.8-1-ARCH.conf

title		Arch Linux
version		4.12.8-1
machine-id	{ /mnt/etc/machine-id }
options		root=PARTUUID={ blkid | grep "Arch Root" (PARTUUID) } rw
linux		EFI/ArchLinux/vmlinuz-linux
initrd		EFI/ArchLinux/initramfs-linux.img

Now it's time to install Fedora, note I'm on Arch but I have dnf installed. You could do this from Fedora but with pacstrap installed.

sudo umount -R /mnt
sudo mount /dev/sdb3 /mnt
sudo mkdir /mnt/{efi,home}
sudo mount /dev/sdb1 /mnt/efi
sudo mount /dev/sdb5 /mnt/home
sudo mkdir /mnt/boot
sudo mkdir -p /mnt/efi/EFI/Fedora
sudo mount --bind /mnt/efi/EFI/Fedora /mnt/boot
sudo dnf -y --installroot=/mnt --releasever=26 install systemd fedora-release passwd kernel systemd-udev binutils
sudo echo "/efi/EFI/Fedora	/boot	none	defaults,bind	0	0" >> /mnt/etc/fstab

And again, set up the boot entry

/mnt/efi/loader/entries/$(cat /mnt/etc/machine-id)-4.12.5-300.fc26.x86_64.conf

title		Fedora
version		4.12.5-300.fc26.x86_64
machine-id	{ /mnt/etc/machine-id }
options		root=PARTUUID={ blkid | grep "Fedora Root" (PARTUUID) } rw
linux		EFI/Fedora/vmlinuz-4.12.5-300.fc26.x86_64
initrd		EFI/Fedora/initramfs-4.12.5-300.fc26.x86_64.img

Cj Malone on