Gentoo on the Intel NUC
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.
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.