WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10881
Howto make a legacy bios/uefi dual boot usb stick with grub2
« on: December 23, 2015, 08: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 14, 2017, 11:02:46 PM by Juanito »

Offline vincentyu1130

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

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10881
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #2 on: August 13, 2016, 03: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

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

Online Juanito

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

Offline Arii

  • WikiUser
  • *
  • Posts: 1
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #5 on: February 08, 2018, 05: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?

Online Juanito

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

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1703
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #7 on: February 08, 2018, 09:32:13 PM »
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

  • Full Member
  • ***
  • Posts: 193
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #8 on: May 25, 2019, 03: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 ?


Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10881
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #9 on: May 25, 2019, 04: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

  • Full Member
  • ***
  • Posts: 193
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #10 on: May 26, 2019, 02: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: May 26, 2019, 04:49:24 PM by Rich »

Offline PDP-8

  • Sr. Member
  • ****
  • Posts: 400
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #11 on: June 19, 2019, 02: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