WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Boot with both legacy and UEFI  (Read 13613 times)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #15 on: February 02, 2022, 08:27:51 PM »
in my case is the Device "sdd" but There is no sdd2 and sdd3

Hi Rabie.
It looks like the partition table is not updated to the kernel.
Did you run gdisk with sudo ?
Anyway, replug your USB should do the trick.
If not, run rebuildfstab
Code: [Select]
sudo rebuildfstab

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #16 on: February 03, 2022, 12:08:07 AM »
Hi Rich, hi polikuo,

it turns out, that i did something wrong. Now i have the 3 Partitions after i have tried it again.
Code: [Select]
fdisk -l /dev/sdd
Disk /dev/sdd: 3727 MB, 3908042752 bytes, 7632896 sectors
1017 cylinders, 121 heads, 62 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sdd1    0,33,3      2,88,11           2048      20470      18423 9211K  7 HPFS/NTFS
/dev/sdd2 *  2,88,21     27,34,39         20480     204700     184221 89.9M ef EFI (FAT-12/16/32)
/dev/sdd3    27,36,15    272,104,9       204800    2047000    1842201  899M 83 Linux
/dev/sdd4    0,0,2       0,33,2               1       2047       2047 1023K ee EFI GPT

Partition table entries are not in disk order

so i am stuck now with the configuration from syslinux.

this is not the full configuration right ?
Code: [Select]
UI vesamenu.c32
DEFAULT tc

LABEL tc
MENU LABEL Tiny Core
KERNEL /vmlinuz
INITRD /core.gz
APPEND ...

This is how i modified your example:

Code: [Select]
UI vesamenu.c32
DEFAULT tc

LABEL tc
MENU LABEL Tiny Core
KERNEL /mnt/sdd2/vmlinuz64
INITRD /mnt/sdd2/corepure64.gz
APPEND ...      #what should be in APPEND


What should i do if i pick the 3rd partion as the bootable partion ?
Quote
83       # Linux filesystem
n        # if you pick the 3rd partition as the bootable partition, use extlinux to install the boot loader



« Last Edit: February 03, 2022, 12:27:48 AM by Rabie »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #17 on: February 03, 2022, 05:32:03 AM »
this is not the full configuration right ?
Code: [Select]
UI vesamenu.c32
DEFAULT tc

LABEL tc
MENU LABEL Tiny Core
KERNEL /vmlinuz
INITRD /core.gz
APPEND ...

This is how i modified your example:

Code: [Select]
UI vesamenu.c32
DEFAULT tc

LABEL tc
MENU LABEL Tiny Core
KERNEL /mnt/sdd2/vmlinuz64
INITRD /mnt/sdd2/corepure64.gz
APPEND ...      #what should be in APPEND
Hi Rabie
You have clearly misunderstood the syntax of Syslinux
/vmlinuz means look from the top of your partition
If you put your file at say /mnt/sdd2/boot/vmlinuz
The syntax would be /boot/vmlinuz

Quote
What should i do if i pick the 3rd partion as the bootable partion ?
Quote
83       # Linux filesystem
n        # if you pick the 3rd partition as the bootable partition, use extlinux to install the boot loader
That means
Code: [Select]
extlinux -i /mnt/sdd2/path/to/extlinux.conf
Note that, while they are the same family, they use different commands during installations.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #18 on: February 03, 2022, 06:58:22 AM »
Hi polikuo,

Can't i just use extlinux in the 3rd partition like this ?

Code: [Select]
DEFAULT corepure64
LABEL corepure64
KERNEL /tce/boot/vmlinuz64
INITRD /tce/boot/corepure64.gz
APPEND ##my parameter##

Code: [Select]
extlinux -i /mnt/sdd3/tce/boot/
extlinux: not a fat, ntfs, ext2/3/4, btrfs, xfs orufs1/2 filesystem: /mnt/sdd3/tce/boot/

it seem like the Directory ist not ext4 although we did format the partition with ext4 like this:
Code: [Select]
mkfs.ext4 /dev/sdb3

and in the 2nd Partition the EFI boot ?
« Last Edit: February 03, 2022, 07:27:54 AM by Rabie »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #19 on: February 03, 2022, 11:23:36 PM »
Can't i just use extlinux in the 3rd partition like this ?
I have no clue, never try that.

Code: [Select]
extlinux -i /mnt/sdd3/tce/boot/
extlinux: not a fat, ntfs, ext2/3/4, btrfs, xfs orufs1/2 filesystem: /mnt/sdd3/tce/boot/

it seem like the Directory ist not ext4 although we did format the partition with ext4 like this:
Code: [Select]
mkfs.ext4 /dev/sdb3
Did you mount your partition ?
Extlinux uses file path, which requires mounting.

Syslinux on the other hand, use device name.
You likely need to unmount the partition

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #20 on: February 05, 2022, 08:19:08 AM »
Hi Rabie
Can't i just use extlinux in the 3rd partition like this ?

Code: [Select]
DEFAULT corepure64
LABEL corepure64
KERNEL /tce/boot/vmlinuz64
INITRD /tce/boot/corepure64.gz
APPEND ##my parameter##
If you mean setting the 3rd as legacy boot partition
You need to mark it bootable with gdisk

Quote
it seem like the Directory ist not ext4 although we did format the partition with ext4 like this:
Code: [Select]
mkfs.ext4 /dev/sdb3
You mean sdd right?
Is that a typo, or have you formatted a wrong partition

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #21 on: February 06, 2022, 11:43:52 AM »
Hi polikuo,

Quote
Did you mount your partition ?
Extlinux uses file path, which requires mounting.
i will try that.

Quote
If you mean setting the 3rd as legacy boot partition
You need to mark it bootable with gdisk
yes this is exactly what i meant.

i did mark the 3rd partition as bootable but somehow i can't get this to work.


Quote
mkfs.ext4 /dev/sdb3

You mean sdd right?
Is that a typo, or have you formatted a wrong partition
yes i meant
Code: [Select]
mkfs.ext4 /dev/sdd3 it was a typo

i will write you tomorrow, what i exactly did. Because the new USB won't boot neither from UEFI or Legacy  :(  :(

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #22 on: February 07, 2022, 04:50:38 AM »
Hi polikuo,

so here is exactly what i did:


Quote
sudo gdisk /dev/sdd

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n

Partition number (1-128, default 1):1
First sector (34-7632862, default = 2048) or {+-}size{KMGTP}:2048
Last sector (2048-7632862, default = 7632862) or {+-}size{KMGTP}: 20470
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Command (? for help): n
Partition number (2-128, default 2):2
First sector (34-7632862, default = 20480) or {+-}size{KMGTP}:20480
Last sector (20480-7632862, default = 7632862) or {+-}size{KMGTP}: 204700
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'


Command (? for help): n
Partition number (3-128, default 3):3
First sector (34-7632862, default = 204800) or {+-}size{KMGTP}:204800
Last sector (204800-7632862, default = 7632862) or {+-}size{KMGTP}: 2047000
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): x

Expert command (? for help): r

Recovery/transformation command (? for help): h

Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 1 2 3
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): n

Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code (default 07): 07
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default EF): EF
Set the bootable flag? (Y/N): y

Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default 83): 83
Set the bootable flag? (Y/N): y

Recovery/transformation command (? for help): x

Expert command (? for help): a
Partition number (1-3): 3
Known attributes are:
0: system partition
1: hide from EFI
2: legacy BIOS bootable
60: read-only
62: hidden
63: do not automount

Attribute value is 0000000000000000. Set fields are:
  No fields set

Toggle which attribute field (0-63, 64 or <Enter> to exit): 2
Have enabled the 'legacy BIOS bootable' attribute.
Attribute value is 0000000000000004. Set fields are:
2 (legacy BIOS bootable)

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.

formatting:
mkfs.vfat /dev/sdd1
mkfs.fat 3.0.26 (2014-03-07)

mkfs.vfat /dev/sdd2
mkfs.fat 3.0.26 (2014-03-07)

 mkfs.ext4 /dev/sdd3
mke2fs 1.44.4 (18-Aug-2018)
/dev/sdd3 contains a ext4 file system
        created on Thu Feb  3 16:17:50 2022
Proceed anyway? (y,N) y

#sudo rebuildfstab

#sudo mount /mnt/sdd3

#sudo extlinux -i /mnt/sdd3
/mnt/sdd3 is device /dev/sdd3

#sudo cp /usr/local/share/syslinux/efi64/syslinux.efi  /mnt/sdd2/EFI/BOOT/BOOTX64.EFI

#sudo dd if=/usr/local/share/syslinux/gptmbr.bin of=/dev/sdd bs=440 count=1
1+0 records in
1+0 records out
440 bytes (440B) copied, 0.000828 seconds, 518.9KB/s

#sudo cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT
#sudo cp /usr/local/share/syslinux/efi64/libutil.c32 /mnt/sdd2/EFI/BOOT
#sudo cp /usr/local/share/syslinux/efi64/libcom32.c32 /mnt/sdd2/EFI/BOOT
#sudo cp /usr/local/share/syslinux/efi64/vesamenu.c32 /mnt/sdd2/EFI/BOOT
#sudo cp /usr/local/share/syslinux/libutil.c32  /mnt/sdd2
#sudo cp /usr/local/share/syslinux/libcom32.c32 /mnt/sdd2
#sudo cp /usr/local/share/syslinux/vesamenu.c32  /mnt/sdd2

#sudo cp /mnt/sdb1/tce/boot/corepure64.gz  /mnt/sdd2
#sudo cp /mnt/sdb1/tce/boot/vmlinuz64  /mnt/sdd2

#sudo mount /mnt/sdd2
#sudo extlinux -i /mnt/sdd2
#sudo cp -a /mnt/sdb1/tce/boot/extlinux/* /mnt/sdd2/       ## in this diractory is the config file for extlinux  "extlinux.conf  ldlinux.c32    ldlinux.sys"##

so what about the files: (firstrun mydata.tgz ondemand/ optional/ onboot.lst  xwbar.lst  ) shouldn't i also move to /mnt/sdd2 ?

what am i doing wrong ?  :-\



Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #23 on: February 07, 2022, 10:16:59 AM »
what am i doing wrong ?  :-\

Here
Don't set 2 bootable partitions.
Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code (default 07): 07
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default EF): EF
Set the bootable flag? (Y/N): y

Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default 83): 83
Set the bootable flag? (Y/N): y

Also this one.
Sorry, I've totally forgot about the difference between 32-bit and 64-bit.
Our tc-install.sh script has been adjusted to handle that by me ages ago.
mkfs.ext4 /dev/sdd3
mke2fs 1.44.4 (18-Aug-2018)
/dev/sdd3 contains a ext4 file system
        created on Thu Feb  3 16:17:50 2022
Proceed anyway? (y,N) y
Syslinux still does NOT support 64-bit ext filesystem yet.  :(
Therefore, the proper command should be
Code: (sh) [Select]
mkfs.ext4 -O '^64bit' -m 0 /dev/sdd3
This is trivial
#sudo ...
You don't need "sudo" if you're already running as root.
It may not do anything.

extlinux doesn't really need sudo privilege.
#sudo extlinux -i /mnt/sdd3
/mnt/sdd3 is device /dev/sdd3

Wrong place
#sudo cp /usr/local/share/syslinux/libutil.c32  /mnt/sdd2
#sudo cp /usr/local/share/syslinux/libcom32.c32 /mnt/sdd2
#sudo cp /usr/local/share/syslinux/vesamenu.c32  /mnt/sdd2
You don't need these for UEFI on sdd2
Put them in your /mnt/sdd3

Now you're just messing around without knowing what you're doing.
#sudo cp /mnt/sdb1/tce/boot/corepure64.gz  /mnt/sdd2
#sudo cp /mnt/sdb1/tce/boot/vmlinuz64  /mnt/sdd2

#sudo mount /mnt/sdd2
#sudo extlinux -i /mnt/sdd2
#sudo cp -a /mnt/sdb1/tce/boot/extlinux/* /mnt/sdd2/       ## in this diractory is the config file for extlinux  "extlinux.conf  ldlinux.c32    ldlinux.sys"##
Wrong location...
You don't need "sudo" either.
Also, you'll need 2 sets of corepure64.gz, vmlinuz64 on both partition with this strategy.
(putting UEFI and legacy BIOS on different partitions)

In your case, they should be
Code: (sh) [Select]
mount /mnt/sdd3
extlinux -i /mnt/sdd3
install /mnt/sdb1/tce/boot/extlinux/extlinux.conf /mnt/sdd3
(To prevent forum error, I use install instead of cp, they act the same anyway  :P)

However, I'd rather do it this way
Code: [Select]
mount /mnt/sdd3
extlinux -i /mnt/sdd3/boot
install /mnt/sdb1/tce/boot/extlinux/extlinux.conf /mnt/sdd3/boot
install libcom32.c32 libutil.c32 vesamenu.c32 /mnt/sdd3/boot

so what about the files: (firstrun mydata.tgz ondemand/ optional/ onboot.lst  xwbar.lst  ) shouldn't i also move to /mnt/sdd2 ?
I would put them in /mnt/sdd3/tce instead.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #24 on: February 08, 2022, 06:25:38 AM »
Hi polikuo,

Quote
Don't set 2 bootable partitions.
if i didn't set the 2nd partition (sdd2) bootable, how should it boot from UEFI then ?

Quote
Wrong place
Quote
#sudo cp /usr/local/share/syslinux/libutil.c32  /mnt/sdd2
#sudo cp /usr/local/share/syslinux/libcom32.c32 /mnt/sdd2
#sudo cp /usr/local/share/syslinux/vesamenu.c32  /mnt/sdd2
You don't need these for UEFI on sdd2
what do i need for the UEFI partition ?

should i configure extlinux for both sdd2 and sdd3 ?

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #25 on: February 08, 2022, 06:48:38 AM »
Quote
Don't set 2 bootable partitions.
if i didn't set the 2nd partition (sdd2) bootable, how should it boot from UEFI then ?

UEFI doesn't care, it has it's own rule.
Just make sure the hex code of your UEFI partition is EF00

Quote
Wrong place
Quote
#sudo cp /usr/local/share/syslinux/libutil.c32  /mnt/sdd2
#sudo cp /usr/local/share/syslinux/libcom32.c32 /mnt/sdd2
#sudo cp /usr/local/share/syslinux/vesamenu.c32  /mnt/sdd2
You don't need these for UEFI on sdd2
what do i need for the UEFI partition ?

These are for UEFI
cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT
cp /usr/local/share/syslinux/efi64/libutil.c32 /mnt/sdd2/EFI/BOOT
cp /usr/local/share/syslinux/efi64/libcom32.c32 /mnt/sdd2/EFI/BOOT
cp /usr/local/share/syslinux/efi64/vesamenu.c32 /mnt/sdd2/EFI/BOOT
Those are for Legacy BIOS
cp /usr/local/share/syslinux/libutil.c32  /mnt/sdd2
cp /usr/local/share/syslinux/libcom32.c32 /mnt/sdd2
cp /usr/local/share/syslinux/vesamenu.c32  /mnt/sdd2

should i configure extlinux for both sdd2 and sdd3 ?
syslinux for sdd2
extlinux for sdd3

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #26 on: February 09, 2022, 02:57:22 AM »
Hi polikuo,

Quote
so what about the files: (firstrun mydata.tgz ondemand/ optional/ onboot.lst  xwbar.lst  ) shouldn't i also move to /mnt/sdd2 ?
I would put them in /mnt/sdd3/tce instead.
where should i put those Files in the EFI partition ? in /mnt/sdd2/EFI/tce or /mnt/sdd2/EFI/BOOT/tce

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #27 on: February 09, 2022, 04:10:41 AM »
Quote
so what about the files: (firstrun mydata.tgz ondemand/ optional/ onboot.lst  xwbar.lst  ) shouldn't i also move to /mnt/sdd2 ?
I would put them in /mnt/sdd3/tce instead.
where should i put those Files in the EFI partition ? in /mnt/sdd2/EFI/tce or /mnt/sdd2/EFI/BOOT/tce

Hi Rabie

These are TC files, you only need one copy.
Quote
(firstrun mydata.tgz ondemand/ optional/ onboot.lst  xwbar.lst)

They don't belong to the bootloader.

Normally we put them in a "tce" directory.
In your case, it's better to put them in /mnt/sdd3/tce
All you have to do is to tell the bootloader where tce directory is.
Code: [Select]
tce=UUID="XXXX-XXXX"
To find out what your UUID is
Code: [Select]
blkid -s UUID /dev/sdd3

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Boot with both legacy and UEFI
« Reply #28 on: February 09, 2022, 07:29:32 AM »
Hi polikuo,

Quote
They don't belong to the bootloader.

Normally we put them in a "tce" directory.
In your case, it's better to put them in /mnt/sdd3/tce
All you have to do is to tell the bootloader where tce directory is.
Code: [Select]
tce=UUID="XXXX-XXXX"

To find out what your UUID is

blkid -s UUID /dev/sdd3
that i didn't know  ???

now i have got the legacy partition (sdd3) to boot properly.

The Problem is now the UEFI partition (sdd2)
there is something wrong
the USB Drive shows up in the UEFI bios as 2 devices like:
USB 1
USB 2
but when i try to boot from them, it give:
no bootable device detected please reboot and check

is there something i am missing ?
Quote

Command (? for help): n
Partition number (2-128, default 2):2
First sector (34-7632862, default = 20480) or {+-}size{KMGTP}:20480
Last sector (20480-7632862, default = 7632862) or {+-}size{KMGTP}: 204700
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'


Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default EF): EF
Set the bootable flag? (Y/N): n

mkfs.vfat /dev/sdd2

syslinux -i /dev/sdd2

#mkdir -p /mnt/sdd2/EFI/BOOT

#cp /usr/local/share/syslinux/efi64/syslinux.efi /mnt/sdd2/EFI/BOOT/BOOTX64.EFI

dd if=/usr/local/share/syslinux/gptmbr.bin of=/dev/sdd bs=440 count=1

#cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT

#cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/libcom32.c32 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/libutil.c32 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/vesamenu.c32 /mnt/sdd2/EFI/BOOT
#cp corepure64.gz vmlinuz64 /mnt/sdd2


i don't think that the problem ist the syslinux.cfg, because it doesn't even get there to load it.
« Last Edit: February 09, 2022, 07:31:49 AM by Rabie »

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: Boot with both legacy and UEFI
« Reply #29 on: February 09, 2022, 08:41:10 AM »
the USB Drive shows up in the UEFI bios as 2 devices like:
USB 1
USB 2
This is indeed weird  ???
Usually, it should be something like
UEFI USB
USB

Command (? for help): n
Partition number (2-128, default 2):2
First sector (34-7632862, default = 20480) or {+-}size{KMGTP}:20480
Last sector (20480-7632862, default = 7632862) or {+-}size{KMGTP}: 204700
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'


Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default EF): EF
Set the bootable flag? (Y/N): n

mkfs.vfat /dev/sdd2

syslinux -i /dev/sdd2

#mkdir -p /mnt/sdd2/EFI/BOOT

#cp /usr/local/share/syslinux/efi64/syslinux.efi /mnt/sdd2/EFI/BOOT/BOOTX64.EFI

dd if=/usr/local/share/syslinux/gptmbr.bin of=/dev/sdd bs=440 count=1

#cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT

#cp /usr/local/share/syslinux/efi64/ldlinux.e64 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/libcom32.c32 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/libutil.c32 /mnt/sdd2/EFI/BOOT
#cp /usr/local/share/syslinux/efi64/vesamenu.c32 /mnt/sdd2/EFI/BOOT
#cp corepure64.gz vmlinuz64 /mnt/sdd2


This part looks fine, so it should work.

I have no clue for now, I don't have a UEFI machine around right now for me to test.

Have you tried it on other machine ?

Have you locked your UEFI by accident ?