WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 9004
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)

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 efi_gop
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"

Note: the efi partition does not need to be set as bootable for this to work.

Edit: slightly modified grub.cfg for clarity
« Last Edit: November 13, 2016, 01:03:04 AM by Juanito »

Offline vincentyu1130

  • WikiUser
  • *
  • Posts: 11
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: 9004
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"  ;)