WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 9463
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, 10: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, 01:44:13 AM »
I suppose you'll install CorePure64 after this procedure into sdc1 partition, right?
Thx.
Vincent

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 9463
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #2 on: August 13, 2016, 02: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: 6
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #3 on: August 08, 2017, 10: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: 9463
Re: Howto make a legacy bios/uefi dual boot usb stick with grub2
« Reply #4 on: August 08, 2017, 11:16:25 PM »
default=menu_label, i.e. default=core in the example above