OK, let's start off by saying:
/etc/fstab
is no longer required* #- You don't need a bootloader, UEFI will take care of that? #
- I'm going to dual boot Arch Linux and Fedora, both of which install there kernels wrong :( #
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:
- 1 / C12A7328-F81F-11D2-BA4B-00A0C93EC93B for $BOOT
- 19 / 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for swap
- 21 / 3B8F8425-20E0-4F3B-907F-1A25A76F98E8 for srv
- 22 / 44479540-F297-41B2-9AF7-D131D5F0458A for /
- 28 / 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for /home
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 likegurb
, 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/
- EFI/
- ArchLinux/
- vmlinuz-linux-4.12.8-1-ARCH
- initramfs-linux-4.12.8-1-ARCH.img
- initramfs-linux-4.12.8-1-ARCH-fallback.img
- vmlinuz-linux-4.9.44-1-ARCH-lts
- initramfs-linux-4.9.44-1-ARCH-lts.img
- initramfs-linux-4.9.44-1-ARCH-lts-fallback.img
- BOOT/
- BOOTX64.efi
- Fedora/
- vmlinuz-4.11.8-300.fc26.x86_64
- initramfs-4.11.8-300.fc26.x86_64.img
- systemd/
- systemd-bootx64.efi
- loader/
- entries/
- 59442b9d9dab4886b843f1001619f9bb-4.12.8-1-ARCH.conf
- 59442b9d9dab4886b843f1001619f9bb-4.9.44-1-ARCH-lts.conf
- c093753328d54283a023608ccbcac4c5-4.11.8-300.fc26.x86_64.conf
- loader.conf
- entries/
- ArchLinux/
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