Skip to content

Commit

Permalink
Support GPT on legacy BIOS system (#759)
Browse files Browse the repository at this point in the history
* Support GPT on legacy BIOS system

Add argument `--force-gpt` to cos-installer to force GPT partition
scheme on legacy BIOS system. GRUB has support on this.

* Bump installer version

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

* Bump cOS version

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

Co-authored-by: Ettore Di Giacinto <edigiacinto@suse.com>
  • Loading branch information
johnliu55tw and mudler authored Oct 5, 2021
1 parent 7e40b04 commit cd59684
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 1 addition & 5 deletions packages/cos/collection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ packages:
- &cos
name: "cos"
category: "system"
version: 0.7.0-7
version: 0.7.0-9
description: "cOS base image, used to build cOS live ISOs"
brand_name: "cOS"
labels:
Expand All @@ -11,17 +11,13 @@ packages:
- !!merge <<: *cos
name: "cos-container"
description: "cOS container image, used to build cOS derivatives from scratch"
version: 0.7.0-8
- !!merge <<: *cos
category: "recovery"
brand_name: "cOS recovery"
description: "cOS recovery image, used to boot cOS for troubleshooting"
version: 0.7.0-7
- !!merge <<: *cos
name: "cos-img"
category: "recovery"
version: 0.7.0-7
- !!merge <<: *cos
name: "cos-squash"
category: "recovery"
version: 0.7.0-7
2 changes: 1 addition & 1 deletion packages/installer/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "installer"
category: "utils"
version: 0.17.1-1
version: "0.18"
description: "Installer, Upgrade and reset utilities to manage cOS derivatives"
28 changes: 23 additions & 5 deletions packages/installer/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cleanup()

usage()
{
echo "Usage: $PROG [--force-efi] [--iso https://.../OS.iso] [--debug] [--tty TTY] [--poweroff] [--no-format] [--config https://.../config.yaml] DEVICE"
echo "Usage: $PROG [--force-efi] [--force-gpt] [--iso https://.../OS.iso] [--debug] [--tty TTY] [--poweroff] [--no-format] [--config https://.../config.yaml] DEVICE"
echo ""
echo "Example: $PROG /dev/vda"
echo ""
Expand Down Expand Up @@ -110,7 +110,7 @@ do_format()
parted -s ${DEVICE} mklabel ${PARTTABLE}

# TODO: Size should be tweakable
if [ "$PARTTABLE" = "gpt" ]; then
if [ "$PARTTABLE" = "gpt" ] && [ "$BOOTFLAG" == "esp" ]; then
BOOT_NUM=1
OEM_NUM=2
STATE_NUM=3
Expand All @@ -122,6 +122,18 @@ do_format()
parted -s ${DEVICE} mkpart primary ext4 15100MB 23100MB # recovery
parted -s ${DEVICE} mkpart primary ext4 23100MB 100% # persistent
parted -s ${DEVICE} set 1 ${BOOTFLAG} on
elif [ "$PARTTABLE" = "gpt" ] && [ "$BOOTFLAG" == "bios_grub" ]; then
BOOT_NUM=
OEM_NUM=2
STATE_NUM=3
RECOVERY_NUM=4
PERSISTENT_NUM=5
parted -s ${DEVICE} mkpart primary 0% 1MB # BIOS boot partition for GRUB
parted -s ${DEVICE} mkpart primary ext4 1MB 51MB # oem
parted -s ${DEVICE} mkpart primary ext4 51MB 15051MB # state
parted -s ${DEVICE} mkpart primary ext4 15051MB 23051MB # recovery
parted -s ${DEVICE} mkpart primary ext4 23051MB 100% # persistent
parted -s ${DEVICE} set 1 ${BOOTFLAG} on
else
BOOT_NUM=
OEM_NUM=1
Expand Down Expand Up @@ -302,6 +314,9 @@ setup_style()
if [ ! -e /sys/firmware/efi ]; then
echo WARNING: installing EFI on to a system that does not support EFI
fi
elif [ "$COS_INSTALL_FORCE_GPT" = "true" ]; then
PARTTABLE=gpt
BOOTFLAG=bios_grub
else
PARTTABLE=msdos
BOOTFLAG=boot
Expand Down Expand Up @@ -339,6 +354,9 @@ while [ "$#" -gt 0 ]; do
--force-efi)
COS_INSTALL_FORCE_EFI=true
;;
--force-gpt)
COS_INSTALL_FORCE_GPT=true
;;
--poweroff)
COS_INSTALL_POWER_OFF=true
;;
Expand Down Expand Up @@ -402,7 +420,7 @@ trap cleanup exit

if [ "$STRICT_MODE" = "true" ]; then
cos-setup before-install
else
else
cos-setup before-install || true
fi

Expand All @@ -417,7 +435,7 @@ SELinux_relabel

if [ "$STRICT_MODE" = "true" ]; then
run_hook after-install-chroot $TARGET
else
else
run_hook after-install-chroot $TARGET || true
fi

Expand All @@ -430,7 +448,7 @@ cos-rebrand

if [ "$STRICT_MODE" = "true" ]; then
cos-setup after-install
else
else
cos-setup after-install || true
fi

Expand Down

0 comments on commit cd59684

Please sign in to comment.