Re: Transferring an existing system from non-RAID disks to RAID1 disks in the same computer

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

 



Sigh,

On 1/20/23 15:26, Wol wrote:
On 20/01/2023 19:27, Pascal Hambourg wrote:
Why in initramfs-tools ? The initramfs has nothing to do with the bootloader installation nor the EFI partition so there is no need to resync EFI partitions on initramfs update (unless GRUB menu entries or kernel and initramfs images are in the EFI partition, which is not a great idea IMO). IMO the right place would be a hook called after the system configuration manager or the GRUB package runs grub-install, if that exists.

I think you've just put your finger on it. Multiple EFI partitions is outside the remit of linux, and having had two os's arguing over which was the right EFI, I really don't think the system manager - be it yast, yum, apt, whatever - is capable of even trying. With a simple configuration you don't have mirrored EFI, some systems have one EFI per OS, others have one EFI for several OSes, ...

Linux has efibootmgr, which certainly can manage multiple EFI partitions.

If using grub on multiple efi partions, you would use efibootmgr one time (after grub-install) to ensure all of your partitions were listed in the order you want them tried. If one gets corrupted the BIOS will fall back to the next one.

{ This is the #1 reason to use EFI instead of MBR boot. }

If using EFI boot *without* GRUB, you want your actual bootable kernel *and* initramfs in place in all of your EFI partitions.

I use an initramfs hook for this on some of my production servers. Kernal install reliably installs an initramfs, too, so this hook is the right place for my use case.

At the end of the day, it's down to the user, and if you can shove a quick rsync in the initramfs or boot sequence to sync EFIs, then that's probably the best place. Then it doesn't get missed ...

As noted, rsync on boot is too late. rsync on kernel or initramfs install is best.

Cheers,
Wol

My script for direct booting (instead of grub) is attached. Works with distro kernels that have EFI_STUB turned on. (Ubuntu Server, in my case.)

Regards,

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