Thursday, January 29, 2015

linux - How to share an EFI boot partition

I have two Archlinux installations on an EFI system set up with gummiboot. One is rooted at /dev/sda2, the other at /dev/sdb1. Both use /dev/sda1, the EFI system partition, as their /boot partition, but place their kernel images in different locations:


/boot/loader/entries/arch.conf:


title   Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=/dev/sda2 rw

/boot/loader/entries/arch-here.conf:


title   HERE Arch Linux
linux /here-img/vmlinuz-linux
initrd /here-img/intel-ucode.img
initrd /here-img/initramfs-linux.img
options cryptdevice=/dev/sdb1:cryptroot root=/dev/mapper/cryptroot rw

This was fine until I updated the kernel from 4.8.13 to 4.9 on sdb. The next time I booted into sda, it failed with


Warning: /lib/modules/4.8.13-1-ARCH/modules.devname not found
...
ERROR: device '/dev/sda2 not found. Skipping fsck.
...

I booted back into sdb, reinstalled kernel 4.8.13, and found I could boot into sda again. However, now I could no longer boot into sdb, as it failed to load the encrypt hook needed to open /dev/sdb1.


I resolved this by chrooting into /dev/sdb1 from sda and installing 4.9 again. This allowed me to boot into sdb but not sda.


Now I'm stuck in a loop where I need to rebuild my kernel image every time I want to switch between installations. It seems that the two kernels are interfering somehow.


Here are the steps I go through on my sda install every time I want to boot into sdb:


sudo cryptsetup open /dev/sdb1 cryptroot
sudo mount /dev/mapper/cryptroot /mnt/
sudo mount /dev/sda1 /mnt/boot/
chroot /mnt/
sudo pacman -U /var/cache/pacman/pkg/linux-4.8.13-1-x86_64.pkg.tar.xz /var/cache/pacman/pkg/nvidia-375.20-3-x86_64.pkg.tar.xz /var/cache/pacman/pkg/nvidia-utils-375.20-3-x86_64.pkg.tar.xz

The steps I go through on sdb when I want to move to sda are similar, but fails with


/lib/modules/4.8.13-1-ARCH is not a valid kernel module directory

I resolve this by symlinking /lib/modules/4.9-1-ARCH to /lib/modules/4.8.13-1-ARCH.


I'm sure I'm doing at least one, if not many things wrong here (that symlink seems like a horrible hack). It seems like my kernels are interfering somehow. How can I fix this?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...