WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Howto make a legacy bios/uefi dual boot usb stick with grub2
« on: December 23, 2015, 11:02:13 AM »
In case you need to boot tinycore from a usb stick on legacy bios and uefi machines.

Note that you will need to use corepure64 as most efi/uefi are 64-bit.

Format a usb stick using fdisk as follows:
Code: [Select]
$ sudo fdisk /dev/sdc
...
   Device Boot      Start         End      Blocks  Id System
/dev/sdc1               2        3670    29471242+ 83 Linux
/dev/sdc2   *        3671        3797     1020127+ ef EFI (FAT-12/16/32)
Note it is easier to partition on 1mb boundaries using fdisk from the util-linux extension

Format the partitions:
Code: [Select]
$ tce-load -i dosfstools e2fsprogs
$ sudo mkfs.ext4 /dev/sdc1
$ sudo mkfs.vfat /dev/sdc2

Install grub:
Code: [Select]
$ tce-load -i grub2-multi
$ sudo mount /dev/sdc1
$ sudo mount /dev/sdc2
$ sudo grub-install --target=x86_64-efi --boot-directory=/mnt/sdc2/EFI/BOOT --efi-directory=/mnt/sdc2 --removable
$ sudo grub-install --target=i386-pc --boot-directory=/mnt/sdc2/EFI/BOOT /dev/sdc

Copy the distribution files rootfs.gz, rootfs64.gz, modules.gz, modules64.gz, vmlinuz and vmlinuz64 to /mnt/sdc1/boot

..then create a grub.cfg in /mnt/sdc2/EFI/BOOT/grub that will be shared by legacy bios and uefi boot:
Code: [Select]
$ cat /mnt/sdc2/EFI/BOOT/grub/grub.cfg
loadfont unicode
insmod all_video
set gfxmode=1366x768x32
set gfxpayload=keep
set gfxterm_font=unicode
terminal_output gfxterm

search --no-floppy --fs-uuid --set=root d4432cde-d21a-4d40-b44b-f097ce72cdba

menuentry "core" {
linux /boot/vmlinuz quiet text tce=UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba" waitusb=10:UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba"
initrd /boot/rootfs.gz /boot/modules.gz
}

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

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
}

menuentry "corepure64 base" {
linux /boot/vmlinuz64 quiet text tce=UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba"/tce64 waitusb=10:UUID="d4432cde-d21a-4d40-b44b-f097ce72cdba" base norestore
initrd /boot/rootfs64.gz /boot/modules64.gz
}
..where "d4432cde-d21a-4d40-b44b-f097ce72cdba" is the uuid of /dev/sdc1, obtained with "blkid -s UUID /dev/sdc1"

Substitute your machine's native resolution for 1366x768x32 if required.

Note: the efi partition does not need to be set as bootable for this to work with uefi boot, but (on my machine at least) it does need to be set for legacy-bios boot.

Edit: slightly modified grub.cfg for clarity

Edit2: changed grub.cfg insmod efi_gop -> insmod all_video to allow legacy-bios fb at 1366x768
« Last Edit: May 15, 2017, 02:02:46 AM by Juanito »

Offline vincentyu1130

  • Newbie
  • *
  • Posts: 14
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #1 on: August 13, 2016, 05:44:13 AM »
I suppose you'll install CorePure64 after this procedure into sdc1 partition, right?
Thx.
Vincent

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #2 on: August 13, 2016, 06:24:46 AM »
Yes - as it says above, "Copy the distribution files rootfs.gz, rootfs64.gz, modules.gz, modules64.gz, vmlinuz and vmlinuz64 to /mnt/sdc1/boot"  ;)

Offline punkgeek

  • Newbie
  • *
  • Posts: 12
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #3 on: August 09, 2017, 02:16:04 AM »
Thank you.
How can I chose default?
Code: [Select]
set default="0"
It doesn't work

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #4 on: August 09, 2017, 03:16:25 AM »
default=menu_label, i.e. default=core in the example above

Offline Arii

  • Newbie
  • *
  • Posts: 1
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #5 on: February 08, 2018, 08:30:51 PM »
Hi, not sure what the necro-posting policy is here but given the relevance I decided to forgo it.

Upon loading "grub2-multi", the directories for x86 aren't actually there, only the i386 ones... I'm assuming they're not in a separate package because it probably would've been mentioned by now. Is something wrong with how I've gone about this or do I need to acquire it from somewhere else?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #6 on: February 09, 2018, 12:16:00 AM »
the i386 files are the equivalent of x86 ones, no?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #7 on: February 09, 2018, 12:32:13 AM »
Hi Arii,
I believe  i386-pc  is pretty much what you're looking for. As in i286, i386, i486, i586 ... = x86.
While this version of grub2 will boot on CPUs compatible with i386 and above, it won't on i286 and below, thus the strict naming.
Download a copy and keep it handy: Core book ;)

Offline labeas

  • Sr. Member
  • ****
  • Posts: 266
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #8 on: May 25, 2019, 06:40:47 AM »
I didn't realise that this thread which was started in 2015, could be continued
in 2019!
My [possibly wrong] understanding of the STRUCTURE of this project is:
* Works only once the <UEFI security-lock> is overcome.
*  grub2-multi.tcz is installed.
    Does `man grub2-multi` exist; or is it internal to TC only ?
* The 2015 example/documented <grub2-multi HOW2> lists 4 entries.
   To reduce the confusion I want to analyse only the 1st: "core".
* The various versions of the <grub family>, list <global-vars / parameters>
  at the listing-start: which apply to all of the following entries.
   The grub2-multi that I'm trying to use: fails to responde to kybrd;
   showing: <the good 3-line-logo> plus:
     tc@box:~$
     with an appropriately FLASHING CURSOR;
     which to me, suggests that grub2-multi's kybrd-driver is bad.
------------
THIS laptop which runs TC64ver8, overcomes the UEFI/restiction problem by:
 navigation to the "Aptio Setup Utility/boot"
 and <disabling the UEFI-restriction>.
The Intel-Atom-based W10 which I'm trying to USBstik-boot TC from, has
 a differnt/newer (2018) "Aptio Setup Utility/boot".
 Examining the W10's settings NOW: I'll reorder:
  "Boot Option Priorities" to
  "Boot Option #1     [UEFI: SanDisk, Part...]"
!! Interestingly: it knows/shows that the USBstik has partn2 for booting;
and AFAIR it showed that my 32bitDebian7-stik used Partn-3.
  So a lot of the system seems to be working ?

What test can I do to help find out why <tc@box:~$ & Flashing cursor>
 doesn't respond to kybrd ?


Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #9 on: May 25, 2019, 07:08:33 AM »
The extension is called grub2-multi because it contains both i386-pc and x86_64-efi files.

Please post your grub.cfg so that we can try to help you.

Offline labeas

  • Sr. Member
  • ****
  • Posts: 266
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #10 on: May 26, 2019, 05:31:08 PM »
> Please post your grub.cfg so that we can try to help you.
===================
=> move stik from dud W10 Laptop to W8.1 Laptop:
=> locate, mount & list Dir/S
=> locate & list grub.cfg
==> Some extra files, Dirs are omitted from the listings.

Code: [Select]
-> ls -l /mnt/sde2/EFI/BOOT/ ==
-rwxrwxrwx 1 root root  121344 May 16 15:59 BOOTX64.EFI
drwxrwxrwx 6 root root    4096 May 16 16:24 grub

Code: [Select]
-> ls -l /mnt/sde2/EFI/BOOT/grub/ ==
drwxrwxrwx 2 root root  4096 May 16 15:59 fonts
-rwxrwxrwx 1 root root  1048 May 24 16:12 grub.cfg
-rwxrwxrwx 1 root root  1288 May 16 16:26 grub.cfgBak
-rwxrwxrwx 1 root root  1024 May 16 15:59 grubenv
drwxrwxrwx 2 root root 20480 May 16 16:03 i386-pc
drwxrwxrwx 2 root root  4096 May 16 15:59 locale
drwxrwxrwx 2 root root 20480 May 16 15:59 x86_64-efi

Code: [Select]
-> cat /mnt/sde2/EFI/BOOT/grub/grub.cfg ==
loadfont unicode
insmod efi_gop
set gfxmode=800x600x32
set gfxpayload=keep
set gfxterm_font=unicode
terminal_output gfxterm

search --no-floppy --fs-uuid --set=root 5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767

menuentry "core" {
linux /boot/vmlinuz quiet text tce=UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767" waitusb=10:UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"
initrd /boot/rootfs.gz /boot/modules.gz
}

menuentry "core64" {
linux /boot/vmlinuz64 quiet text tce=UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767" waitusb=10:UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"
initrd /boot/rootfs.gz /boot/modules64.gz
}

menuentry "corepure64" {
linux /boot/vmlinuz64 quiet text tce=UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"/tce64 waitusb=10:UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"
initrd /boot/rootfs64.gz /boot/modules64.gz
}

menuentry "corepure64 base" {
linux /boot/vmlinuz64 quiet text tce=UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"/tce64 waitusb=10:UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767" base norestore
initrd /boot/rootfs64.gz /boot/modules64.gz
}
-------------------------
I don't know how this posting's line-len-overflow will work?

    [EDIT]: Added code tags.  Rich
« Last Edit: August 13, 2019, 09:39:38 AM by Rich »

Offline PDP-8

  • Hero Member
  • *****
  • Posts: 915
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #11 on: June 19, 2019, 05:22:38 AM »
Hey, it works!  Thanks Juanito..

I used CFDISK for the formatter and had no problem.

Tip: after formatting with mkfs, I removed the stick so the system would properly recognize the new partitions.  THEN I proceeded with mounting properly for the grub install.  I think everyone knows this, but this tripped me up before. :)

I actually turned this into a Tinycore / 64 setup with some tips from coreplayer2 - thanks man.

So happy I scarfed an entire pizza. :)
That's a UNIX book! - cool  -- Garth

Offline labeas

  • Sr. Member
  • ****
  • Posts: 266
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #12 on: August 13, 2019, 05:15:15 AM »
=> /mnt/sda2/Tmp/Forum/CagedAces  2019 Aug 13

I'm used to acessing the whole file-tree, which includes ALL the
plugged devices in the USBhub, and the 4-partition Microsoft hardDrive
when running TC64ver7.2 from a USBstik via the <APTIO 2015> laptop.

Now I've managed to boot only the 2nd-listing-below of the 5 grub.cfg
entries. And install gpm & mc and get 1+11=12 VTs via `sudo openvt`
on the problematic <APTIO 2018> laptop.

Q: Why does `fdisk -l` & other tests NOT see the Microsoft hardDrive ?
Code: [Select]
root@box:/home/tc# ls /mnt
mmcblk0p1  sda1       sda2 <-sda=USBstik;mmcblk0p1=equipped SDcard

root@box:/home/tc# dmesg | grep sd
 sees sda* PLUS:...
sd 1:0:0:0: [sdb] 0 512-byte logical blocks: (0 B/0 B)
sd 1:0:0:0: [sdb] 0-byte physical blocks
sd 1:0:0:0: [sdb] Test WP failed, assume Write Enabled
sd 1:0:0:0: [sdb] Asking for cache data failed
sd 1:0:0:0: [sdb] Assuming drive cache: write through
sd 1:0:0:0: [sdb] Attached SCSI disk

OK, maybe sdb is the Microsoft hardDrive. I didn't notice that previousy.
When I can afford to take the USBhub from the <APTIO 2015> laptop,
I'll test if this system CAN see other devices, than its own-booted.

We often must "put the research to WRITNG" to spot our mistakes?
Now I'll boot to Win10; to post this FAT text from partn2 of our
<how to boot UEFI via grub> USBstik. Q: does `halt -n` <autoUnmount> ?

---> listing PASTED via mc & gpm:-
Code: [Select]
/mnt/sda2/EFI/BOOT/grub/grub.cfg     1154/1200      96%loadfont unicode
insmod efi_gop
set gfxmode=800x600x32
set gfxpayload=keep
set gfxterm_font=unicode
terminal_output gfxterm

search --no-floppy --fs-uuid --set=root bfe6116c-473a-4ee9-bbac-3638039dc9ad

menuentry "core" {
linux /boot/vmlinuz quiet text tce=UUID="bfe6116c-473a-4ee9-bbac-3638039dc9ad" waitusb=10:UUID="bfe6116c-473a-4ee9-bbac-3638039dc9ad"
initrd /boot/rootfs.gz /boot/modules.gz
}

menuentry "coreB" {  <-- ONLY THIS entry works OK
linux /boot/vmlinuz waitusb=10:UUID="bfe6116c-473a-4ee9-bbac-3638039dc9ad"
initrd /boot/rootfs.gz /boot/modules.gz
}

menuentry "core64" {
linux /boot/vmlinuz64v10 quiet text tce=UUID="bfe6116c-473a-4ee9-bbac-3638039dc9ad" waitusb=10:UUID="bfe6116c-473a-4ee9-bbac-3638039dc9ad"
initrd /boot/rootfs.gz /boot/modules64.gz
}
...
PS. I notice how the smart-arse web-based forum FALSELY wraps code-lines.
NNTP of 25 years ago is far superior. Too late to change now.
Whereas we wrote "27"; todays FB, twitter kiddie write "twenty seven".

    [EDIT]: Added code tags and corrected Microsoft spelling.  Rich
« Last Edit: August 13, 2019, 08:59:05 AM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #13 on: August 13, 2019, 10:20:56 AM »
Hi labeas
Please refrain from your  "clever"  spelling of Microsoft. If you feel a need to bash them, take it elsewhere. I'm sure there are sites
out there that specialize in that.

... Q: Why does `fdisk -l` & other tests NOT see the Microsoft hardDrive ? ...
Since you didn't show the results of  fdisk -l  we don't know what it saw. If your disk has GPT partitions, you probably need  gdisk.

Quote
PS. I notice how the smart-arse web-based forum FALSELY wraps code-lines.
If your line is longer than the display area it wraps at the last whitespace that still fits on the line. It will not wrap in the middle of a
word. If it encounters this and it's too long to still fit on the current line:
Code: [Select]
waitusb=10:UUID="5c4d3b5d-47c9-4e67-8403-4aa4eb9fb767"it will wrap that to the next line because it contains no whitespace. If you use  code tags,  it will wrap in the editing window, but
when you click the  Preview  button, you'll see it in a code box with a horizontal scrollbar on the bottom.

Offline labeas

  • Sr. Member
  • ****
  • Posts: 266
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #14 on: November 28, 2019, 02:36:21 AM »
This is the first & last time I use a FULL-BROWSER for the TCforum.
And now I see were the verbose/redundant:jsGenerated "Code: [Select]" comes from.
It seems absurd for TINYcore, which hasn't even got: awk, bash, X to want to ape
the WinTel/Bigboys? And we'd better solve this UEFI-booting, since there's a whole
flood of ChineseCheapo UEFI WinTel laptops coming.
---The following seems inconsistent with previous instructions:--
>installing manually is quite easy if you check off the following list items & notes below
>...
>* that Grub2 is installed from a 64bit operating system, with the following directory paths
>*         sd(x)1/EFI/BOOT
?????????? On the USBstik which mostly works, nonTClinux sees:---
=> /mnt/sdg2/EFI/BOOT/grub/ =fonts/ grub.cfg  grubenv i386-pc/ x86_64-efi/
Ie. -/EFI/BOOT is on the 2nd [FAT] partition, not the 1st [linux].

How can I continue fumbling in the dark; or has this instruction-error been corrected?