WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)  (Read 4849 times)

Offline Twist

  • Newbie
  • *
  • Posts: 41
TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« on: January 01, 2020, 06:59:25 PM »
I feel like I'm close but can't quite get it working: corepure64 on a 13" MacBook Air (mid 2013)
What I'd like: a bootable usb device with TC on it. Hold 'alt' during boot to select USB with TC instead of (default) OS X on built in HDD.
What I'd also like: leave the internal hdd completely alone (i.e. not change the EFI partition on there).

My progress so far:
- I managed to install rEFInd on its own on a usb stick. Fine, as a proof of concept that is recognised when holding alt during boot and presents boot options.
- Then got the core-10.1.iso, converted that to .img, and with etcher wrote it to another usb stick.
- rEFInd stick presents that as something with a bootable kernel on it. Needed to add initrd=/boot/corepure64.gz in the rEFInd boot screen and then it boots
- Downloaded tinycorepure64-10.1iso and use that after boot with the fromISOfile command, so I could do startx
- With some information from here (http://forum.tinycorelinux.net/index.php?topic=21096.0) got the wifi up
- downloaded tc-install-GUI and tried to do a frugal install on (yet another) usb drive. It completes fine, but it doesn't appear In rEFInd.
- Tried an install to an existing partition (no reformat) on the 2nd usb stick, completes fine, but not recognised by rEFInd.

I lack some understanding of EFI, bootloaders, and the way they can work to get TC bootable on a USB drive in this MacBook Air. Seems like the tc-install program is geared towards BIOS based PCs, not EFI? I feel I'm close, but also missing something to nail this.

Help appreciated!

Note: I'm more familiar with piCore ip to now

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #1 on: January 01, 2020, 08:18:44 PM »
Hi Twist
I successively used this writeup to make a boot-able EFI USB for an ASUS tablet:
http://forum.tinycorelinux.net/index.php/topic,22848.msg143377.html#msg143377

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #2 on: January 02, 2020, 08:29:14 AM »
Hi Rich,
Thanks, unfortunately no luck yet.
I'm unable to run gparted: it crashes almost immediately after startup. The output is:

Code: (bash) [Select]
GParted 1.0.0
configuration --enable-online-resize
libparted 3.2.122-46cd

** (gpartedbin:10050): WARNING **: 11:17:41.532: AT-SPI: Could not obtain desktop path or name


** (gpartedbin:10050): WARNING **: 11:17:41.535: atk-bridge: GetRegisteredEvents returned message with unknown signature

** (gpartedbin:10050): WARNING **: 11:17:41.535: atk-bridge: get_device_events_reply: unknown signature

** (gpartedbin:10050): WARNING **: 11:17:41.535: atk-bridge: get_device_events_reply: unknown signature

(gpartedbin:10050): Gdk-ERROR **: 11:17:42.736: The program 'gpartedbin' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 2422 error_code 2 request_code 139 (RENDER) minor_code 34)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Trace/breakpoint trap

So I used parted instead to set up the usb stick with a 200MB fat32 partition and the remainder as ext2. Used mkfs.fat -F 32 on /dev/sde1 and mkfs.ext2 on /dev/sde2. Able to complete all instructions.

Alas, when booting with 'alt' key pressed, only the internal hdd is show as a boot option. The new tc stick doesn't show up.
When I insert my rEFInd-only usb stick, I can boot into the rEFInd menu. However, also now, the fresh tc-stick doesn't show as a boot option.



Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #3 on: January 02, 2020, 11:42:51 AM »
The gparted error is possibly due to using Xvesa/Xfbdev rather than Xorg-7.7

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #4 on: January 02, 2020, 01:12:45 PM »
Hi Twist
... So I used parted instead to set up the usb stick with a 200MB fat32 partition and the remainder as ext2. ...
Did you create a new partition table? It needs to be  GPT  not  MSDOS.

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #5 on: January 02, 2020, 03:00:03 PM »
The gparted error is possibly due to using Xvesa/Xfbdev rather than Xorg-7.7
The crash of gparted is perhaps better for a different topic? Surely anything that gparted does can be done with parted? Or is that assumptions wrong?

Hi Twist
... So I used parted instead to set up the usb stick with a 200MB fat32 partition and the remainder as ext2. ...
Did you create a new partition table? It needs to be  GPT  not  MSDOS.
Yes I completely wiped it and put a new GPT table on it.

I'm confused why there is still a need for GRUB(2) to be involved and installed. I thought the whole idea was that a modern linux kernel (with efi support) has a built on boot loader. Such that the firmware boot manager in the macbook just presents an option to boot the linux kernel.
Q: is the kernel in tinycorepure64 actually efi bootable?

Should I set a boot flag on the first /boot partition of the usb stick with TC?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #6 on: January 02, 2020, 05:04:23 PM »
Hi Twist
... Surely anything that gparted does can be done with parted? Or is that assumptions wrong? ...
I suspect that is true. The GUI makes the job easier and less error prone in my opinion.

Quote
Should I set a boot flag on the first /boot partition of the usb stick with TC?
I don't think it should be necessary, but I haven't dealt with Apple devices. This is what  parted -l  returned for a working thumb drive:
Code: [Select]
Model: UFD USB Flash Drive (scsi)
Disk /dev/sdg: 514MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name   Flags
 1      1049kB  37.7MB  36.7MB  fat32        Boot   msftdata
 2      37.7MB  513MB   475MB   ext2         Linux

You probably need to turn off secure boot since none of the executables are signed by Microsoft.

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #7 on: January 03, 2020, 03:24:22 PM »
Bit of progress and further insight:
When I
- grab a tinycore kernel (vmlinuz64)
- rename it bootx64.efi
- place it on an EFI partition from a GPT formatted USB stick ...
- ... inside EFI/boot/

... then it is recognised by the MacBooks built-in efi bootmanager (hold alt during boot).
So, the tinycore kernel does have EFI-stub support, and can be booted without needing another bootmanager.

The kernel boots, but then fails as the command line options for the initrd hasn't been passed to it.
Can I use efbootmgr to pass the arguments? Perhaps (haven't tried yet), but that limits the usb stick to the particular Mac where the NVRAM has been update with the efibootmgr tools. (Or at least that is what I understand efibootmgr to do)

So, perhaps I should go for rEFInd, as an intermediary bootmanager and setup its config file so it passes the correct command line options to the kernel.

Thoughts?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #8 on: January 04, 2020, 12:44:41 AM »
My 2012-ish mac mini boots from a standard efi install - I used bootcamp and made an additional partition on the ssd for tinycore.

Although rEFInd works, there's no need to use it - holding down the apply key during boot brings up an efi menu with tinycore being one of the options.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #9 on: January 04, 2020, 04:38:17 AM »
https://github.com/KNNSpeed/UEFI-Stub-Loader seems to be what you want, a simpler efi bootloader than grub.
The only barriers that can stop you are the ones you create yourself.

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #10 on: January 04, 2020, 09:19:27 AM »
My 2012-ish mac mini boots from a standard efi install - I used bootcamp and made an additional partition on the ssd for tinycore.

Although rEFInd works, there's no need to use it - holding down the apply key during boot brings up an efi menu with tinycore being one of the options.
So how do you pass command options to the kernel in that setup?

https://github.com/KNNSpeed/UEFI-Stub-Loader seems to be what you want, a simpler efi bootloader than grub.
Yes spot on, that sounds promising. It keeps the macbook completely 'standard', with everything needed to run tinycore on a USB drive.

Thanks all. I'll report back here.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #11 on: January 04, 2020, 09:48:23 AM »
You pass commands using grub.cfg in the usual way.

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #12 on: January 04, 2020, 11:51:13 AM »
Nearly there!

The KNNSpeed/UEFI-Stub-Loader as suggested by curaga is working. When holding down alt (option) at startup I can select the USB disk. The UEFI-stub-loader then grabs the command line options form a text file and passes over to tiny core's vmlinuz. The initrd is picked up correctly.

Tiny core boots, but seems to ignore my tce= and opt= directive. I've added a waitusb option as well, and surely all 15 seconds pass by, but no luck. Which seems to suggest the waitusb is not effective here?
Note that dmesg at the end says:
EXT4-fs (sdb2): mounting ext2 file system using the ext4 subsystem
EXT4-fs (sdb2): mounted filesystem without journal. Opts: (null)
But mount shows nothing of a mounted sdb2 at all.


Here's the contents of the Kernelcmd.txt
Code: (bash) [Select]
\EFI\tc10-x86_64\vmlinuz64
initrd=\EFI\tc10-x86_64\corepure64.gz waitusb=15:UUID="b88c641f-ad15-4d9f-9c97-3a3b2e752d0e" tce=UUID="19C897BC-1573-4758-A315-5B5E304FDA2A"/tce opt=UUID="19C897BC-1573-4758-A315-5B5E304FDA2A" blacklist=bcma,ssb,bc43


This is the output of blkid which I ran inside TC
Code: (bash) [Select]
/dev/sdb: PTUUID="b88c641f-ad15-4d9f-9c97-3a3b2e752d0e" PTTYPE="gpt"
/dev/sdb1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="34823828-e6ad-4f98-8ff8-673f28f0f701"
/dev/sdb2: UUID="5403a65f-6c9e-4d1a-a037-da2ee96d5287" TYPE="ext2" PARTLABEL="ext" PARTUUID="19c897bc-1573-4758-a315-5b5e304fda2a"

And for completeness here's dmesg output attached

    [EDIT]: Renamed attached file.  Rich
« Last Edit: January 04, 2020, 12:21:05 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11639
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #13 on: January 04, 2020, 12:17:12 PM »
Hi Twist
Are  UUIDs  case sensitive? Your blkid command shows:
Code: [Select]
PARTUUID="19c897bc-1573-4758-a315-5b5e304fda2a"but you command file show this:
Code: [Select]
tce=UUID="19C897BC-1573-4758-A315-5B5E304FDA2A"/tce opt=UUID="19C897BC-1573-4758-A315-5B5E304FDA2A"
In the future, please use a  .txt  extension for files containing text.

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: TC frugal on USB for (EFI) MacBook Air (no CD, no eth)
« Reply #14 on: January 04, 2020, 04:55:52 PM »
Thanks Rich. .txt it is in the future.
I figured it out... I was using the PARTUUID instead of the (filesystem?)UUID. Not sure the waitusb does anything useful in my case, so will experiment with that.

At last! A bootable tinycore USB drive that's completely self contained (i.e. does not rely on anything specifically set up on the hardware it runs on, just press alt(option) at boot)

This particular macbook runs some (hydro)navigation software and the licences for the charts are reliant on some sort of system fingerprint. I don't want to risk messing that up. Hence my quest to have it all contained on a USB drive.

I will do this once more from scratch and document the steps for future reference.