Re: Mdadm raid and UEFI boot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi G,

On 06/04/2018 01:39 PM, Chris Murphy wrote:
> On Mon, Jun 4, 2018 at 11:14 AM, G <garboge@xxxxxxx> wrote:
>> Thanks to everyone involved in development and/or support of mdadm. I've
>> been using it for years on legacy hardware!
>>
>> I've had to resort to additional devices (USB, additional drives, etc) for
>> /boot in order to use un-partitioned block devices for raid.
>>
>> I now want to use un-partitioned block devices on an Intel S5500HCV server
>> board with UEFI.
>>
>> Is it possible to use UEFI boot without an EFI partition but have it boot a
>> Linux kernel (Ubuntu server) directly using EFI stub and use un-partitioned
>> raided drives?

Simple answer: No.

Because....

> How does the firmware find the kernel?

There must be an EFI System Partition in a GPT reachable from the UEFI
bios that contains a bootable shim or monolithic kernel.  The target
file must be identified as the boot target in the UEFI bios's flash
variables.

> Generally it's expected the firmware finds the kernel via an NVRAM
> entry pointing to a partition and path to file, and via FAT support to
> locate the actual blocks for the file.
> 
> If you use mdadm metadata format 1.0, which goes at the end of the
> unpartitioned drive, and then partition and format the array - it will
> appear to the UEFI firmware to not be a RAID member but a normally
> partitioned drive. Ergo it can only be RAID 1, or this isn't going to
> work. Previously on this list, tricking the firmware with metadata
> format 0.9 or 1.0 to achieve this is frowned upon, as the layout and
> usage is ambiguous, and there's no assurance the firmware will never
> write to the EFI System partition: and if it were to do so, you'd have
> out of sync member devices on which a scrub would show an unresolvable
> mismatch.

Concur.  Don't do this with UEFI.  You're better off using two separate
System Partitions on different devices, and placing them separately in
the boot order.  Add suitable hook scripts to your distro to insert the
necessary entries for main and fallback kernel when the kernel is updated.

If you absolutely must use unpartitioned drives (why?), you can put an
EFI System Partition and the necessary shim/kernel on a thumb drive or
mSATA device.

The attached hook script will move kernel and initramfs files to
suitable EFI system partitions (mounted at /bootA and /bootB) and where
necessary, update the EFI boot order.  This works for distros that
include the EFI Stub in their kernels with support for external
initramfs.  (Ubuntu Server in this case.)

Phil
#! /bin/bash
#
# Normally installed in /etc/initramfs/post-update.d/ and marked
# executable.
#
# Move newly installed initramfs to /boot/efi and ensure corresponding
# kernel is also moved.  If the kernel has to be moved, also update
# the EFI Boot Manager with the new kernel and prune old kernels.
#
# This routine is called the kernel version in argument #1 and the 
# name of the initramfs file in argument #2

# Obtain root fs info for boot command line
source <(blkid -o export $(df / |grep -o '^/dev/[^ ]\+')) 
if test "${DEVNAME:0:12}" == "/dev/mapper/" ; then
	export RootSpec="$DEVNAME"
else
	if test "${DEVNAME:0:5}" == "/dev/" ; then
		vglv="${DEVNAME:5}"
		vg="${vglv%%/*}"
		lv="${vglv#$vg}"
		if test -n "$lv" ; then
			export RootSpec="$DEVNAME"
		else
			export RootSpec="UUID=$UUID"
		fi
	else
		export RootSpec="UUID=$UUID"
	fi
fi

# Destinations must have a trailing slash.
for DEST in /bootB/ /bootA/
do
	# First, copy the updated initramfs.
	cp "$2" "$DEST"

	# Construct the target kernel efi file name and check for existence
	export KF="${DEST}vmlinuz-$1.efi"
	test -f "$KF" && continue

	# Need to copy and register the kernel.
	echo "Copying $KF ..."
	cp "/boot/vmlinuz-$1" "$KF"

	# Obtain EFI boot fs info for boot partition info and file locations
	source <(blkid -o export $(df "$DEST" |grep -o '^/dev/[^ ]\+')) 

	BOOT="$(sed -r -e 's/(.+[^0-9])([0-9]+)/\1:\2/' <<< "$DEVNAME")"
	read dummy1 MOUNTPT other <<< "$(grep "^$DEVNAME " /proc/mounts)"
	EFIROOT="$(echo ${DEST##$MOUNTPT} |sed 's/\//\\/g')"

	# Set the new boot record
	efibootmgr -q -c --disk "${BOOT%%:*}" --part "${BOOT##*:}" \
		--label "EFI Direct $DEST $1" \
		--loader "${EFIROOT}vmlinuz-$1.efi" \
		-u "initrd=${EFIROOT}$(basename "$2") root=${RootSpec}"

	echo "Configured EFI Direct $DEST $1 as $EFIROOT on $BOOT"

done

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux