WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Howto make a legacy bios/uefi dual boot usb stick with grub2  (Read 55616 times)

Offline Dr.FrankenHouse

  • Newbie
  • *
  • Posts: 6
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #30 on: February 26, 2020, 07:29:24 AM »
Hi,

I followed your guide, the usb stick starts regularly on a pc with uefi and 64bit cpu.
I have a newbie question: does the usb also works with 32-bit PCs?

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #31 on: February 26, 2020, 08:01:28 AM »
Hi, Dr.FrankenHouse!

In general answer is yes. Details depend on what boot entry You used on 64-bit PC. Have You booted "core64" or "corepure64"?

Offline Dr.FrankenHouse

  • Newbie
  • *
  • Posts: 6
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #32 on: February 26, 2020, 01:21:35 PM »
Hi jazzbiker,
I booted my laptop (uefi & cpu i7) without any problem with corepure64 entry.
I tried to boot my netbook (cpu atom 32bit) and it won't start, it didn't recognize the partition (bios recognize the usb stick and I set it like first boot).
I immediately thought that the problem was how I made the usb stick, but before I restarted all the procedure I would like to know if it will go or not.
It's not necessary that it run on 32bit, it's just a curiosity. Unfortunately I don't have another old pc here to test, I should have to go to my parents (200km from here).

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #33 on: February 26, 2020, 02:15:45 PM »
Hi, Dr.FrankenHouse!

I am writing this post from the very old ASUS netbook with 32-bit Atom, Z520, booting from USB flash drive, cooked according to Juanito recipe. Here i load using "core" entry. And the same stick i boot 64-bit laptop in both modes - core64 and corepure64.
So Juanito's installation instructions are perfect and You can rely on them absolutely.
Maybe You missed, that on the 32-bit hardware You can select only "core" entry? Be carefull with UUID's defined.

Good luck!

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11652
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #34 on: February 26, 2020, 02:16:23 PM »
Hi Dr.FrankenHouse
... I tried to boot my netbook (cpu atom 32bit) ...
Are you sure? Atoms came in both 32 and 64 bit. I have an old ASUS T100-CHI tablet that has a 64 bit Atom but 32 bit UEFI firmware.
I also found out this tablet would not boot a 32 bit kernel so I used vmLinuz64 with Core64 (not CorePure64) so I could still run
32 bit applications since this tablet only has 2 Gig of RAM.

Offline Dr.FrankenHouse

  • Newbie
  • *
  • Posts: 6
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #35 on: February 26, 2020, 04:51:09 PM »
Hi, Dr.FrankenHouse!

I am writing this post from the very old ASUS netbook with 32-bit Atom, Z520, booting from USB flash drive, cooked according to Juanito recipe. Here i load using "core" entry. And the same stick i boot 64-bit laptop in both modes - core64 and corepure64.
So Juanito's installation instructions are perfect and You can rely on them absolutely.
I never doubt about juanito's instructions. As I wrote, first thing I thought was "ok, I made a mistake".

Maybe You missed, that on the 32-bit hardware You can select only "core" entry? Be carefull with UUID's defined.

Good luck!
The problem is that boot menu doesn't came out,it starts directly the boot menu installed on ssd in the netbook.
It's like the pc doesn't recognize usb stick (but bios does).

Hi Dr.FrankenHouse
... I tried to boot my netbook (cpu atom 32bit) ...
Are you sure? Atoms came in both 32 and 64 bit. I have an old ASUS T100-CHI tablet that has a 64 bit Atom but 32 bit UEFI firmware.
I also found out this tablet would not boot a 32 bit kernel so I used vmLinuz64 with Core64 (not CorePure64) so I could still run
32 bit applications since this tablet only has 2 Gig of RAM.

Unfortunately I'm pretty sure, it's an Asus eeepc 1005ha with Atom N280

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11652
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #36 on: February 26, 2020, 05:00:34 PM »
Hi Dr.FrankenHouse
... The problem is that boot menu doesn't came out,it starts directly the boot menu installed on ssd in the netbook.
It's like the pc doesn't recognize usb stick (but bios does). ...
I had that same issue with the tablet. I had to go into the BIOS and turn off secure boot and place grub as option #1 under
Boot Option Priorities.
« Last Edit: February 27, 2020, 01:06:08 AM by Rich »

Offline Dr.FrankenHouse

  • Newbie
  • *
  • Posts: 6
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #37 on: March 01, 2020, 05:54:00 AM »
Hi,

I performed a new installation on a new USB stick.
This time netbook recognize it!
But I have another problem when starts grub:
Code: [Select]
error: unknown filesystem
Entering rescue mode...
I tried on several computers (both with uefi and with legacy) and I did the installation of the USB stick several times.
In attachment a screenshot of fdisk

I don't know if the problem could be that I install it by running tc on virtualbox hosted by Windows

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #38 on: March 01, 2020, 09:38:04 AM »
Hi, Dr.FrankenHouse!

You're right, it's better to make bootable media without the use of VM. There are a lot of issues on the forum about some software working slightly different if run under one of the various VMs.
If it is possible, try to make bootable media under the running "real" TinyCore.  If it is not possible, use some other "real" Linux.

Good luck!

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11652
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #39 on: March 01, 2020, 10:32:51 AM »
Hi Dr.FrankenHouse
This is the procedure that worked for me
http://forum.tinycorelinux.net/index.php/topic,22848.msg143377.html#msg143377
If memory serves, using a  GPT  partition was necessary in my case.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #40 on: May 28, 2020, 07:16:28 AM »
Hi, all Core explorers!

I want to propose the small workaround, which can be usefull for those, who uses the same 32-bit rootfs under 32-bit or 64-bit kernels, depending on the hardware being booted. In Juanito's perfectly working grub.cfg You need to choose manually among Core and Core64 entries. But grub2 shell implements "cpuid" builtin command, which can make this dirty job for You.
I've added to original Juanito's grub.cfg the next entry:
Code: [Select]

if cpuid -l
then
  set KNAME="vmlinuz64"
  set MNAME="modules64"
else
  set KNAME="vmlinuz"
  set MNAME="modules"
fi

menuentry "core auto" {
linux /boot/"$KNAME" quiet tce=UUID="<Your boot disk UUID>" waitusb=10:UUID="<Your boot disk UUID>"
initrd /boot/rootfs.gz /boot/"$MNAME".gz
}


Have a nice Core!

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #41 on: May 28, 2020, 07:37:52 PM »
Let me make remarks here concerning avoiding of extraneous writes to flash, as it was not mentioned in this thread yet.

1. Making ext4 filesystem without journal. Proposed in the initial post
Code: [Select]
$ sudo mkfs.ext4 /dev/sdc1
can be modified adding option
Code: [Select]
$ sudo mkfs.ext4 -O ^has_journal /dev/sdc1

2. Remounting boot device with forbidden files' and directories' access time updates.
The next commands can be added to bootlocal.sh:
Code: [Select]
TCEDEV=$(readlink /etc/sysconfig/tcedir | sed 's_/mnt/\(.*\)tce.*_\1_')
mount -o noatime -o nodiratime -o remount /dev/"$TCEDEV"

3. Number of blocks written to Your device can be monitored with
Code: [Select]
cat /proc/diskstats | awk '/sdc1/{print $10}'
if Your flash partition is /dev/sdc1.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #42 on: May 29, 2020, 01:33:17 PM »
EDIT to privious post.

2. Remounting boot device with forbidden files' and directories' access time updates.
The next commands can be added to bootlocal.sh:
Code: [Select]
TCEDEV=$(readlink /etc/sysconfig/tcedir | sed 's_/mnt/\([^/]*\).*_\1_')
mount -o noatime -o nodiratime -o remount /dev/"$TCEDEV"

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #43 on: June 07, 2020, 07:43:35 AM »
Hi, Core people!

One more post about grub2 and TinyCore. Using multiple TC versions, building custom rootfs-es, kernels, having need for different bootcodes' batches makes someone tired of constant editing (manual!) of grub,cfg according to the newly appeared environments. Trying to avoid grub.cfg manual editing I've made a universal grub.cfg, which, once stored in /EFI/BOOT/grub directory, don't need to be cared and make all the job of creating grub2 menu entries  during boot process by itself lonely. Of course this assumes, that the structure and content of the boot device follows certain rules.

Boot device contains a directory tree with distribution files (vmlinuz, vmlinuz64, rootfs.gz, rootfs64.gz, modules.gz, modules64.gz) placed in various directories. Also boot device directory tree contains "bootcodes" files. The normal way to use  "bootcodes" files is to place the single
Code: [Select]
BOOTCODES="<something>"
definition, which will be sourced to the grub2 shell while creating the corresponding menu entry.

Boot menu entries are created only for the terminal nodes - dirctories, which doesn't have subdirs. Each terminal node has unique path from the root directory. Distribution files are collected along this path exclusively, means if on the way from / to /10/4/6/7 more than one "vmlinuz" will be found, the latest (closest to the terminal node) will be used. "bootcodes" assignments are accumulated in BOOTCODES_FULL variable, which immediately is used for creating menu entry itself.

For every terminal node entries tried to be created depends on the set of distribution files collected along the path and CPU bitness.

Directory names, visible for script, can only be natural numbers (see NATURALS constant in the source code). Directories alternatively named don't influence on entries cretion process.

First subdir in BOOT_ROOT is considered to be the version number and all the down-level subdirs' created entries will share the same TCE<version> working directory. So distribution files of TC10.0 version, placed in /10/0 and TC10.1 files placed in /10/1 will share the same /TCE10 directory for roots and /TCE10-64 for rootfs64. Boot and TCE devices may be separate ones.

So final grub.cfg is "cat"-ed  of the definition header (grub.cfg.def) and grub.cfg.template and is placed in /EFI/BOOT/grub/ on the EFI device, according to initial Juanito's post.

Additional tool for making menu entries understandable are "title" files. For example, if /10/1 contains 32-bit distributionn files, /10/1/2 contains "bootcodes" with
Code: [Select]
BOOTCODES="noswap nodhcp"
then corresponding boot menu entry will be named "core-10-1-2". But if You'll place in /10/1/2 the file "title", containing
Code: [Select]
TITLE="mysettings1"
then corresponding entry becomes named "core-10-1-mysettings1".

Important note: TITLE value string must not contain spaces.

This is brief description of the grub.cfg.template possibilities. Of course, it is not fully tested, so You can use it with care.

Have a nice Core!

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #44 on: June 08, 2020, 05:01:16 AM »
Update: added protection against spaces in TITLE value definition. They will be replaced with '_' symbols.
« Last Edit: June 08, 2020, 05:32:41 AM by jazzbiker »