Commit 265b5e6f authored by Anton Midyukov's avatar Anton Midyukov

tar2fs: install grub-pc for x86_64 with UEFI

Both UEFI and Legacy BIOS are supported on x86_64 machines. Now the image x86_64 will be bootloaded on both.
parent 4ed779d7
...@@ -77,7 +77,12 @@ if [ "$BOOTLOADER" == grub-efi -o "$BOOTTYPE" == EFI ]; then ...@@ -77,7 +77,12 @@ if [ "$BOOTLOADER" == grub-efi -o "$BOOTTYPE" == EFI ]; then
EFIPART="1" EFIPART="1"
EFIPARTSIZEM="256" EFIPARTSIZEM="256"
EFIPARTFSTYPE="fat" EFIPARTFSTYPE="fat"
if [ "$ARCH" = x86_64 ]; then
BIOSPART="2"
ROOTPART="3"
else
ROOTPART="2" ROOTPART="2"
fi
fi fi
# tested to work: ext[234], jfs # tested to work: ext[234], jfs
...@@ -217,7 +222,7 @@ trap exit_handler EXIT ERR ...@@ -217,7 +222,7 @@ trap exit_handler EXIT ERR
# prepare disk image and a filesystem inside it # prepare disk image and a filesystem inside it
rm -f -- "$IMG" rm -f -- "$IMG"
OFFSET="$(($CUR_BOUNDARY + $EFIPARTSIZEM + $BOOTLOADERPARTSIZEM + $BOOTSIZEM + $ROOTSIZEM - 1))" OFFSET="$(($CUR_BOUNDARY + $EFIPARTSIZEM + $BOOTLOADERPARTSIZEM + $BOOTSIZEM + ${BIOSPART:+1} + $ROOTSIZEM - 1))"
dd if=/dev/zero of="$IMG" conv=notrunc bs=$MB count=1 seek="$OFFSET" dd if=/dev/zero of="$IMG" conv=notrunc bs=$MB count=1 seek="$OFFSET"
losetup -f "$IMG" losetup -f "$IMG"
LOOPDEV=$(losetup -j "$IMG" | cut -f 1 -d ':') LOOPDEV=$(losetup -j "$IMG" | cut -f 1 -d ':')
...@@ -249,6 +254,12 @@ if [ -n "$EFIPART" ]; then ...@@ -249,6 +254,12 @@ if [ -n "$EFIPART" ]; then
fi fi
fi fi
if [ -n "$BIOSPART" ]; then
parting mkpart bios $((CUR_BOUNDARY+1))MiB $(($CUR_BOUNDARY + 2))MiB
CUR_BOUNDARY="$(($CUR_BOUNDARY + 1))"
parting set "$BIOSPART" bios on
fi
if [ -n "$BOOTPART" ]; then if [ -n "$BOOTPART" ]; then
BOOTDEV="$BLOCKDEV$BOOTPART" BOOTDEV="$BLOCKDEV$BOOTPART"
mkpart "$BOOTSIZEM" mkpart "$BOOTSIZEM"
...@@ -447,8 +458,10 @@ grub-efi) ...@@ -447,8 +458,10 @@ grub-efi)
--removable --uefi-secure-boot --removable --uefi-secure-boot
chroot "$ROOTFS" grub-install --target=x86_64-efi --recheck \ chroot "$ROOTFS" grub-install --target=x86_64-efi --recheck \
--removable --uefi-secure-boot --removable --uefi-secure-boot
sed -i 's/initrd16/initrdefi/g' "$ROOTFS/boot/grub/grub.cfg" sed -i 's/initrd16/initrd/g' "$ROOTFS/boot/grub/grub.cfg"
sed -i 's/linux16/linuxefi/g' "$ROOTFS/boot/grub/grub.cfg" sed -i 's/linux16/linux/g' "$ROOTFS/boot/grub/grub.cfg"
[ -n "$BIOSPART" ] &&
chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV"
;; ;;
aarch64) aarch64)
chroot "$ROOTFS" grub-install --target=arm64-efi --recheck \ chroot "$ROOTFS" grub-install --target=arm64-efi --recheck \
...@@ -477,8 +490,8 @@ grub) ...@@ -477,8 +490,8 @@ grub)
case "$ARCH" in case "$ARCH" in
*86*) *86*)
chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV" chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV"
sed -i 's/initrdefi/initrd16/g' "$ROOTFS/boot/grub/grub.cfg" sed -i 's/initrdefi/initrd/g' "$ROOTFS/boot/grub/grub.cfg"
sed -i 's/linuxefi/linux16/g' "$ROOTFS/boot/grub/grub.cfg" sed -i 's/linuxefi/linux/g' "$ROOTFS/boot/grub/grub.cfg"
;; ;;
ppc*) ppc*)
[ -z "$LOOPBOOTLOADER" ] || [ -z "$LOOPBOOTLOADER" ] ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment