Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: Rabie on January 25, 2022, 03:05:47 PM

Title: Boot with both legacy and UEFI
Post by: Rabie on January 25, 2022, 03:05:47 PM
Hi There,

is there a way to make TinyCore boots from a boot media with both legacy and UEFI if the PC doesn't support legacy boot?

i am using TinyCore x64 with the bootloader extlinux.

Thank you
Title: Re: Boot with both legacy and UEFI
Post by: Rich on January 25, 2022, 05:05:06 PM
Hi Rabie
I kind of sounds like you answered your own question.

Regardless of what you do to the boot media, how could you expect to boot it legacy mode if the hardware
does not support legacy mode?
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on January 26, 2022, 01:58:41 AM
Hi Rich,

i may have asked the question wrong.

Quote
how could you expect to boot it legacy mode if the hardware
does not support legacy mode?

it has to boot with UEFI if the PC doesn't support legacy! Not with legacy if its not supported  ;D

Title: Re: Boot with both legacy and UEFI
Post by: mocore on January 27, 2022, 08:04:52 AM

it has to boot with UEFI if the PC doesn't support legacy! Not with legacy if its not supported  ;D

AFAIK usually this choice of which to prioritise  is handled by the system bios.

wrt how to setup a hdd/usb ect  see

http://forum.tinycorelinux.net/index.php?topic=20939.0 - How to make a legacy bios/uefi dual boot usb stick with syslinux

http://forum.tinycorelinux.net/index.php/topic,19364.0.html -  Howto make a legacy bios/uefi dual boot usb stick with grub2 

Title: Re: Boot with both legacy and UEFI
Post by: Rabie on January 27, 2022, 09:35:46 AM
hi mocore,

Quote
http://forum.tinycorelinux.net/index.php?topic=20939.0 - How to make a legacy bios/uefi dual boot usb stick with syslinux

yes i already found this topic but i couldn't really follow the instructions.

is Syslinux the same as extlinux ?
Title: Re: Boot with both legacy and UEFI
Post by: Rich on January 27, 2022, 10:10:19 AM
Hi Rabie
... is Syslinux the same as extlinux ?
Syslinux and extlinux are both found in the  syslinux.tcz  extension.

From the  .info  file:
Quote
----- Snip -----
                bootloaders for MS-DOS FAT filesystems (SYSLINUX),
                network booting (PXELINUX),
                bootable "El Torito" CD-ROMs (ISOLINUX), and
                Linux ext2/ext3/ext4 or btrfs filesystems (EXTLINUX).
 ----- Snip -----
Found here:
http://tinycorelinux.net/12.x/x86/tcz/syslinux.tcz.info
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on January 27, 2022, 03:04:59 PM
Hi Rich,

Quote
Syslinux and extlinux are both found in the  syslinux.tcz  extension.

i see.

I have installed TinyCore on a USB media and can boot with it but only with legacy.

It would be nice, if you told me step by step how do i make the same USB media boot on a UEFI system.

You already helped me so much before.

Thnx
Title: Re: Boot with both legacy and UEFI
Post by: Rich on January 27, 2022, 08:46:16 PM
Hi Rabie
I've only had to deal with  UEFI  once, and this was the writeup I followed:
http://forum.tinycorelinux.net/index.php/topic,22848.msg143377.html#msg143377
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on January 27, 2022, 09:27:06 PM
is Syslinux the same as extlinux ?
They are the same family, just different design for different file system.
If your boot media is FAT(32) use syslinux
If it is EXT2(,3,4) use extlinux

It would be nice, if you told me step by step how do i make the same USB media boot on a UEFI system.
Which part do you have trouble with ?
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on January 31, 2022, 08:49:00 AM
Hi polikuo,

first i have an understanding question.
when i try to make the USB-Stick bootable with both legacy and UEFI, should i follow the instruction on an new attached USB-Stick or on the same boot Stick i use ?

when i try to do your instruction from: http://forum.tinycorelinux.net/index.php/topic,20939.0.html

i get like 9 Partitions
Code: [Select]
sudo gdisk /dev/sdb
sdb   sdb1  sdb2  sdb3  sdb4  sdb5  sdb6  sdb7  sdb8  sdb9

i continue anyway with:
Code: [Select]
sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.4

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.



but that seems to be wrong in my case, cause all sdb* Partitions are mounted and in the next step you say:

Quote
formatting

tce-load -wil dosfstools
mkfs.vfat /dev/sdb1
mkfs.vfat /dev/sdb2
mkfs.ext4 /dev/sdb3
sudo rebuildfstab

Title: Re: Boot with both legacy and UEFI
Post by: Rich on January 31, 2022, 09:03:53 AM
Hi Rabie
... when i try to make the USB-Stick bootable with both legacy and UEFI, should i follow the instruction on an new attached USB-Stick or on the same boot Stick i use ? ...
The instructions are for a stick which is not mounted and the contents will be destroyed.

Title: Re: Boot with both legacy and UEFI
Post by: Rabie on January 31, 2022, 10:22:17 AM
Quote
Which part do you have trouble with ?
i don't get this part

Quote
# follow gdisk instruction to set up MBR hex code and bootable flags
07       # M$
n        # not bootable
EF       # ESP
y        # personally I prefer putting all the files together
83       # Linux filesystem
n        # if you pick the 3rd partition as the bootable partition, use extlinux to install the boot loader
x        # go back to expert menu

i was asked from gdisk to create entry for GTP:

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

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

GPT partition #3 does not exist or is too big; skipping.
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 01, 2022, 05:22:39 AM
Hi Rabie

My tutorial destroys everything on an USB stick

Back in the days, windows only allow a single partition on an USB stick.

If windows finds more, it would read the first partition and pretend that the rest do not exist.

Therefore, I setup a FAT32 partition as the first for file sharing between the systems.

You don't need this if you're not using TC that way.

I put my EFI in the second partition when TC takes the third.

i get like 9 Partitions
Code: [Select]
sudo gdisk /dev/sdb
sdb   sdb1  sdb2  sdb3  sdb4  sdb5  sdb6  sdb7  sdb8  sdb9

i continue anyway with:
Code: [Select]
sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.4

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

This means your disk/USB is not a GPT one.
Converting from MBR to GPT may cause data loss.
It's not a must, but most machine that use UEFI prefer GPT format.

Quote
Which part do you have trouble with ?
i don't get this part
Which part of my tutorial do you have trouble with ?
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 02, 2022, 05:29:34 AM
Hi polikuo,
so i have done the following Part successfully

Code: [Select]
sudo gdisk /dev/sdb
# main menu
o        # create a new empty GUID partition table (GPT)
n        # add a new partition
# number, size, type = 0700
n        # add a new partition
# number, size, type = ef00
n        # add a new partition
# number, size, type = 8300
# now we'll create a hybrid MBR for legacy BIOS
x        # extra functionality (experts only)
# expert menu
r        # recovery and transformation options
h        # make hybrid MBR
1 2 3    # assign partitions to MBR
# Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N):
n        # we're using syslinux
# follow gdisk instruction to set up MBR hex code and bootable flags
07       # M$
n        # not bootable
EF       # ESP
y        # personally I prefer putting all the files together
83       # Linux filesystem
n        # if you pick the 3rd partition as the bootable partition, use extlinux to install the boot loader
x        # go back to expert menu
# expert menu
a        # set attributes
2        # your legacy bootable partition
2        # boot flag attribute code
w        # write table to disk and exit

i have trouble with the following:

Quote
formatting

tce-load -wil dosfstools
mkfs.vfat /dev/sdb1
mkfs.vfat /dev/sdb2
mkfs.ext4 /dev/sdb3
sudo rebuildfstab

in my case is the Device "sdd" but There is no sdd2 and sdd3

Code: [Select]
/dev/sdd*
/dev/sdd   /dev/sdd1
Title: Re: Boot with both legacy and UEFI
Post by: Rich on February 02, 2022, 09:34:04 AM
Hi Rabie
What does this return:
Code: [Select]
fdisk -l /dev/sdd
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 02, 2022, 11: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
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 03, 2022, 03: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



Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 03, 2022, 08: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.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 03, 2022, 09: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 ?
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 04, 2022, 02:23:36 AM
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
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 05, 2022, 11: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
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 06, 2022, 02:43:52 PM
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  :(  :(
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 07, 2022, 07: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 ?  :-\


Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 07, 2022, 01:16:59 PM
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 (https://wiki.syslinux.org/wiki/index.php?title=Filesystem) 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.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 08, 2022, 09: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 ?
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 08, 2022, 09: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
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 09, 2022, 05: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
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 09, 2022, 07: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
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 09, 2022, 10: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.
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 09, 2022, 11: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 ?
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 10, 2022, 03:53:04 PM
hi polikuo,

Quote
Have you tried it on other machine ?
not yet

Quote
Have you locked your UEFI by accident ?
no i can boot windows with the same machine with UEFI and i checked extra.

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

you or someone else may have/has an Idea why it doesn't work ?
i realy need to boot with UEFI  :-\ :-\

i am using this machine: https://www.zotac.com/at/product/mini_pcs/ci329-nano
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 11, 2022, 12:03:12 AM
Quote
Have you locked your UEFI by accident ?
no i can boot windows with the same machine with UEFI and i checked extra.
I'm referring to the secure boot
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 11, 2022, 04:44:06 AM
Hi polikuo,
Quote
I'm referring to the secure boot
it's disabled.
should it be enabled for UEFI?

 
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 11, 2022, 10:31:17 AM
Hi polikuo,
Quote
I'm referring to the secure boot
it's disabled.
should it be enabled for UEFI?
No, you should keep it disabled.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 12, 2022, 08:22:04 AM
i am goin crazy!

i don't know why it's not working.

so i am gonna try grub with the tutorial from Juanito: http://forum.tinycorelinux.net/index.php/topic,19364.0.html

But this part i don't unterstand:

Quote
menuentry "corepure64" {
linux /boot/vmlinuz64 quiet text tce=UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba"/tce64 waitusb=10:UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba"
initrd /boot/rootfs64.gz /boot/modules64.gz
}

what i know that both of those files /boot/rootfs64.gz /boot/modules64.gz make the core file but i just have the Corepure64 file.

so my question is:
should i split the core into those files ? or how does it work ?
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 12, 2022, 08:36:00 AM
what i know that both of those files /boot/rootfs64.gz /boot/modules64.gz make the core file but i just have the Corepure64 file.

so my question is:
should i split the core into those files ? or how does it work ?

Hi Rabie
If you have corepure64.gz, use that.
If you have rootfs64.gz and modules64.gz, you might wanna merge them together.
Code: [Select]
cat rootfs64.gz modules64.gz > corepure64.gz
I don't use GRUB2, but I think different bootloader use different syntax
SYSLINUX:(comma)
Code: [Select]
INITRD /boot/rootfs64.gz,/boot/modules64.gzGRUB2:(space)
Code: [Select]
initrd /boot/rootfs.gz /boot/modules.gz
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 12, 2022, 08:47:27 AM
hi polikuo,

yes, but if i just have the core file, would the syntax be like this?

Code: [Select]
initrd /boot/corepure64.gz
or it doesn't matter and still have to be like this :

Code: [Select]
initrd /boot/rootfs64.gz /boot/modules64.gz
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 12, 2022, 08:51:28 AM
hi polikuo,

yes, but if i just have the core file, would the syntax be like this?

Code: [Select]
initrd /boot/corepure64.gz
Hi Rabie.
Yes, that should work.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 12, 2022, 09:39:48 AM
hi polikuo,
yes it did work, now i can boot from UEFI with grub  :)  :)

but i still wanna know why it didn't work with syslinux   :-\  ???

Thank you very much for teaching me so much  :)
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 14, 2022, 06:14:34 AM
Hi polikuo,

like i said i did exactly the steps from Juanitos Tuturial: http://forum.tinycorelinux.net/index.php/topic,19364.0.html
and it does boot with UEFI.

The only problem now, that i am getting the following error and after that i must start x manually   :-\

Code: [Select]
SQUASHES error: zlib decompression failed, data probably corrupt
SQUASHFS error: squashfs read data failed to read block Ox9d534
SQUASHIS error: zlib decompression failed, data probably corrupt
SQUASHES error: squashfs _read _data failed to read block Ox9dae4
SQUASHIS error: zlib decompression failed, data probably corrupt
SQUASHIS error: squashfs _read _data failed to read block Ox9e644
SQUASHES error: zlib decompression failed, data probably corrupt
SQUASHES error: squashfs read data failed to read block Ox9ebf4
.SQUASHIS error: zlib decompression failed, data probably corrupt
"SQUASHES error: squashfs_read data failed to read block Oxa3dd5
SQUASHFS error: zlib decompression failed, data probably corrupt
SQUASHFS error: squashfs _read _data failed to read block Oxa4329
SQUASHIS error: zlib decompression failed, data probably corrupt
I SQUASHES error: squashfs _read data failed to read block Oxa5569
SQUASHES error: zlib decompression failed, data probably corrupt
SQUASHIS error: squashfs _read _data failed to read block Oxa58bd
SQUASHES error: zlib decompression failed, data probably corrupt
SQUASHFS error: squashfs read_data failed to read block 0x8c970
SQUASHIS error: zlib decompression failed, data probably corrupt
SQUASHFS error: squashfs read _data failed to read block 0x8cd18
SQUASHES error: zlib decompression failed, data probably corrupt
SQUASHTS error: squashfs _read _data failed to read block OxBe15e
rc _core: IR keymap rc-cec not found

do you know what is that ?

edit:

i ran gdisk to check the USB drive and got that the partition is damaged!

Code: [Select]
#sudo gdisk /dev/sdd
GPT fdisk (gdisk) version 1.0.4

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: OK

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: damaged

Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
 1 - MBR
 2 - GPT
 3 - Create blank GPT

why whould that happen ? i have repeated the tutorial many times and i am getting the same thing

what am i doing wrong ?
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 14, 2022, 07:12:48 AM
Code: [Select]
data probably corruptthe partition is damaged!
I guess your hardware is failing.
You should verify your extensions (and your corepure64.gz) like this
Code: [Select]
tc@box: /tmp/md5 $ ls
kmaps.tcz          kmaps.tcz.md5.txt
tc@box: /tmp/md5 $ md5sum -c kmaps.tcz.md5.txt
kmaps.tcz: OK
tc@box: /tmp/md5 $ echo corrupt > kmaps.tcz
tc@box: /tmp/md5 $ md5sum -c kmaps.tcz.md5.txt
kmaps.tcz: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match
Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 14, 2022, 08:14:07 AM
Hi guys,

I use USB-flash installed TinyCore and regularly (not so frequent, around once per month) check it with
the help of attached script. The names of the corrupted extensions will be seen on the screen after the script exit.

Have a nice Core!

@Rabie, so Your partition has GPT table? You've mentioned that You followed the steps from Juanito's HOWTO, but he mentioned fdisk and MBR partition in his posts. I've never used gdisk, but seems that it don't want to work with MBR.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 14, 2022, 08:24:40 AM
hi polikuo,
Quote
I guess your hardware is failing.
You should verify your extensions (and your corepure64.gz) like this

yes you were right, there was one extainsion failing

Code: [Select]
md5sum: can't open '/mnt/sda1/tce/optional/mylocale.tcz': No such file or directory
/mnt/sda1/tce/optional/mylocale.tcz: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match

but i am still getting this:
Code: [Select]
rc _core: IR keymap rc-cec not found
should i mybe reinstall kemaps or is that something else ?
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 14, 2022, 08:28:34 AM
Hi guys,

I use USB-flash installed TinyCore and regularly (not so frequent, around once per month) check it with
the help of attached script. The names of the corrupted extensions will be seen on the screen after the script exit.

Have a nice Core!
thank you i will try the script later.
Quote
@Rabie, so Your partition has GPT table? You've mentioned that You followed the steps from Juanito's HOWTO, but he mentioned fdisk and MBR partition in his posts. I've never used gdisk, but seems that it don't want to work with MBR.
yes, i think that the USB drive wasn't formatted correctly  ;D

Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 14, 2022, 08:33:26 AM
Why You say MBR is incorrect? I think it's all right. I use MBR.
Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 14, 2022, 08:37:17 AM
I think polikuo is right, Your system exhibits unstable behaviour, some hardware problems are probably present, bad power, unstable contacts somewhere... Beware of possible storage damage. Try to power-off the system and check the cables.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 14, 2022, 09:07:50 AM
Why You say MBR is incorrect? I think it's all right. I use MBR.

i think you were right, that gdisk don't want to work with MBR.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 14, 2022, 09:08:47 AM
is there a way to remove the message "Welcome to GRUB!" ?
Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 14, 2022, 09:26:48 AM
Load grub2 sources, remove this message, compile and pack Your own extension :)
By the way Arch includes grub-silent package.
Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 14, 2022, 09:38:45 AM
Edit: This was the bad message, please forget if You've seen the previous content.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 15, 2022, 01:33:53 AM
Hi jazzbiker,
Quote
Load grub2 sources, remove this message, compile and pack Your own extension :)
By the way Arch includes grub-silent package.
thank you
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 15, 2022, 01:38:12 AM
does anyone know what this Error mean?

Code: [Select]
rc _core: IR keymap rc-cec not found
Title: Re: Boot with both legacy and UEFI
Post by: curaga on February 15, 2022, 03:00:34 AM
It concerns remote controls (like your TV's), you can ignore it if you're not using any.
Title: Re: Boot with both legacy and UEFI
Post by: Rabie on February 15, 2022, 03:16:14 AM
Hi curaga,

It concerns remote controls (like your TV's), you can ignore it if you're not using any.

i see, thnx  ;D
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 17, 2022, 09:31:41 AM
Hi

I've found something.

I think the dosfstools.tcz on x86_64 needs to be recompiled.

This is what happens on CorePure64 13.0
Code: [Select]
tc@box:~$ mkfs.vfat /dev/sdc1
mkfs.fat 4.2 (2021-01-31)
Cannot initialize conversion from codepage 850 to UTF-8: Invalid argument
Cannot initialize conversion from UTF-8 to codepage 850: Invalid argument
Using internal CP850 conversion table

On PiCore-aarch64 13.1
Code: [Select]
tc@pi3:~$ mkfs.vfat /dev/sda1
mkfs.fat 4.2 (2021-01-31)

I can load into UEFI GUI vesamenu with the re-formatted partition.
However, something went wrong when I try to boot.
I guess it'll take a while for me to find out why.
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 17, 2022, 10:01:30 AM
Hi again.

It appears the cause is the kernel.

TC 12 boots without any problem.

TC 13 refuses to boot.

I guess this might be related:
https://wiki.syslinux.org/wiki/index.php?title=Common_Problems#Linux_EFI_kernels (https://wiki.syslinux.org/wiki/index.php?title=Common_Problems#Linux_EFI_kernels)
Quote
Due to a bug in the configuration system, some EFI kernels are not safely relocatable. CONFIG_EFI now requires CONFIG_RELOCATABLE. Syslinux will (safely) attempt to load such a kernel at its preferred address and bail if the memory is not available. This will likely exhibit itself as working on some platforms while bailing on others (with different memory maps).

Wonderful, we'll need to recompile the kernel  :P
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 17, 2022, 10:13:51 AM
CONFIG_EFI now requires CONFIG_RELOCATABLE

Hi yet again

http://tinycorelinux.net/13.x/x86_64/release/src/kernel/config-5.15.10-tinycore64 (http://tinycorelinux.net/13.x/x86_64/release/src/kernel/config-5.15.10-tinycore64)
Code: [Select]
CONFIG_RELOCATABLE=y
CONFIG_EFI=y

We do have those options enabled.
This is getting nowhere  :(
Title: Re: Boot with both legacy and UEFI
Post by: curaga on February 17, 2022, 11:15:07 AM
Those conversion errors may mean it requires glibc-gconv.
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 17, 2022, 11:43:14 AM
Those conversion errors may mean it requires glibc-gconv.
Hi curaga
Both machine have mylocale.tcz onboot (depends on glibc_gconv.tcz)
They have the same version, too.

CorePure64
Code: [Select]
tc@box:~$ mkdosfs --help 2> /dev/null
mkfs.fat 4.2 (2021-01-31)
PiCore-aarch64
Code: [Select]
tc@pi3:~$ mkdosfs --help 2> /dev/null
mkfs.fat 4.2 (2021-01-31)

Anyway, there are 2 problems.
First, dosfstools.tcz is messing around.
(a corrupted partition can't get Syslinux running at all, returns to "BIOS menu")
Second, the kernel 13 simply can not boot with Syslinux UEFI, but kernel 12 can.
Title: Re: Boot with both legacy and UEFI
Post by: jazzbiker on February 17, 2022, 12:54:02 PM
Hi polikuo,
Sorry for the noobish 2 cents, but syslinux.tcz seems to be unchanged since TC7. Is it possible that rebuilding the extension will help?
Title: Re: Boot with both legacy and UEFI
Post by: polikuo on February 17, 2022, 10:04:01 PM
Hi polikuo,
Sorry for the noobish 2 cents, but syslinux.tcz seems to be unchanged since TC7. Is it possible that rebuilding the extension will help?
Hi jazzbiker
I don't think so, because the actual firmware that boot your system is precompiled. (files in share)
Only the toolkit is compiled for tiny core. (files in bin, sbin)
Title: Re: Boot with both legacy and UEFI
Post by: CNK on February 17, 2022, 10:06:37 PM
Quote
First, dosfstools.tcz is messing around.
(a corrupted partition can't get Syslinux running at all, returns to "BIOS menu")
Second, the kernel 13 simply can not boot with Syslinux UEFI, but kernel 12 can.

I'm booting TC13 x86_64 with Syslinux on a UEFI-only system (and I am sure that it's UEFI-only, though it doesn't need the boot drive to be GPT partitioned). It's installed on a dual legacy/UEFI MBR/GPT SD card following your tutorial (http://forum.tinycorelinux.net/index.php/topic,20939.0.html). But that was done with TC11, since then I've only replaced the corepure64.gz and vmlinuz64 files and updated the extensions to upgrade to TC12 then TC13.

So it's not something wrong with the kernel that prevents booting, but perhaps something prevents the installation process from working when it's done from TC13?

I tried mkfs.vfat myself and it gives me the same errors/warnings, but still seems to format an SD card OK and I can write file, remount, and read them back. I haven't tested extensively though (the card was already FAT formatted before, though an old directory was erased by the formatting so it did do something).