Blog /Gentoo on the Intel NUC

August 02, 2014 17:36 +0000  |  Gentoo Linux 3

The NUC is a pretty neat idea: Intel gives you a little box with a motherboard and a CPU inside and you decide what else you want to do with it. For me, I just wanted a quiet little server in the corner of the house, so I bought 4GB of RAM and a 500GB (cheap, spinning) hard drive. About €220 and I was ready to go... and then the pain started.

An image of the Intel NUC

Keyboard

The NUC comes with the latest-and-shiniest BIOS stuff that Intel could come up with: a whole bunch of useless polish to obfuscate the useful features you're looking for. Still, this wouldn't be so bad if it weren't for the fact that the NUC doesn't recognise some keyboards at boot time. I plugged in my primary board, hit F10 and... nothing. Lucky for me I had an old dusty Logitech solar keyboard around, otherwise this effort would have died before it started.

UEFI vs. Legacy

I'd heard of UEFI, and had a little experience trying (and failing) to get Gentoo onto a Macbook in the past. I had a weekend, so I thought it'd be a good learning experience to go the UEFI route this time. For the record, this is a Bad Idea.

UEFI support in Linux is still rather young, and resources for its use in Gentoo are sketchy and fragmented, often with conflicting advice. The handbook mentions UEFI only once in the entire document, and web searches for UEFI Gentoo result in a plethora of conflicting and/or unhelpful pages:

  • https://wiki.gentoo.org/wiki/Partition
  • https://wiki.gentoo.org/wiki/UEFI_Gentoo_AMD64_Quick_Install_Guide
  • https://wiki.gentoo.org/wiki/EFI_stub_kernel
  • https://wiki.gentoo.org/wiki/GRUB2_Quick_Start
  • https://wiki.gentoo.org/wiki/GRUB2
  • http://forums.gentoo.org/viewtopic-t-971988-highlight-intel+nuc.html
  • https://bbs.archlinux.org/viewtopic.php?id=168548

Legacy it is

So, after doing a complete install on this little Celeron box (it's slower than you might think), I decided to blow away everything and start again, this time opting for just sticking to legacy boot.

After 10 min or so poking around in Intel's ridiculous Visual Bios interface, I managed to turn off UEFI and enable Legacy (protip: you can't simply check the Legacy box: it doesn't do anything. You have to uncheck the UEFI box and magically the Legacy box will check itself. Nice job there Intel.) I rebooted using my SystemRescueCD USB stick, booted into the Gentoo setup environment and followed the handbook verbatim (choosing GPT partitioning, this important to the story) right up until the end. I rebooted and...

The NUC complained that it couldn't find any bootable partitions.

It's all in the partitions

Frustrated, bitter, and angry at this point, I started searching online again, this time specifically for gpt, intel nuc and bootable and I found this obscure forum post where someone essentially had my problem with a different machine: the BIOS was set to legacy, the disks were partitions with GPT, and the machine couldn't find a bootable disk.

The post explained that some BIOSes are dumb and require an old-style bootable flag to be set on the boot partition (read: old, fdisk-style, not parted-gpt-style partitions). The solution was to open /dev/sda in fdisk and set the partition (there's only one when you've used GPT) to bootable. Problem solved right? Wrong.

The version of fdisk that ships with SystemRescueCD is a modern one that actually recognises and attempts to make use of GPT partitions. If you open /dev/sda in this modern version, there's no ability to actually set a bootable flag. I was stuck again. Back to the Internetz to where I found this useful page that gave me the magic incantations required:

# parted /dev/sda
(parted) disk_toggle pmbr_boot
(parted) quit
# reboot

Apparently disk_toggle pmbr_boot does the very same thing as opening a GPT partitioned disk in an old version of fdisk and setting the bootable flag. After the reboot (and the removal of the USB stick from the back of the NUC), everything booted up nicely, Systemd stuff included (that part was painless).

So, to recap:

  • Don't use UEFI unless you like pain
  • Do everything old-school, and if you must use GPT, remember disk_toggle

I hope this helps someone out there.

Comments

Alfredo Hernández P.
2 Sep 2014, 5:23 a.m.  | 

Hey!! Thank you very much. This post was sooooo helpful.

I spent an entire weekend installing, reinstalling and doing everything all over again trying to get my NUC to boot, until I was about to give up and luckily came up with this.

Marc Elser
8 Jun 2015, 10:55 a.m.  | 

Well,

It did not have any of the issues described above with the new intel nuc broadwell series i3.

I just updated the bios to the latest version with an usb stick. Then I installed gentoo x86_64 like described in the gentoo handbook and about uefi boot with grub (just google it). One tiny thing to note is, if you do not plan on using legacy boot. Your /boot resides in root fs and you mount /boot/efi to a vfat partition (/dev/sda1) and it must be vfat and have around 200 MB of space. (That somewhat differs from the handbook, where they still create /dev/sda1 for grub and /dev/sda2 for uefi & boot.

But if you stick to that everything goes fine. The UEFI BIOS starts grub2 and then the system loads. also no issues with boot disk not found. Don't know if the problem just lies with legacy BIOS setup or not.

But just stick do descriptions in handbook and for using UEFI + grub2 and at the various points (partitioning, installing grub, etc.) just stick to grub2 instructions instead of handbook.

ONUKI, Akihisa
22 Oct 2019, 11:38 a.m.  | 

Thank you!

In my NUC6CAYH, it happened on 10/22/2019 and the above solution was effective.

Post a Comment of Your Own

Markdown will work here, if you're into that sort of thing.