• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

SOLVED Linux and UEFI: Self-torture guru meditation

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Automata

Destroyer of Empires and Use
Joined
May 15, 2006
I've been spending the last few hours taking my first steps in the wonderful world of UEFI booting. I recently built my system due to instability issues and went with pretty high end hardware. I'm currently using a Gigabyte Z77 UD5H, 3570k, 32gb RAM, Intel 180gb SSD and a 570 GTX all packed in a Lian Li 1020B. So far, the hardware has been great. So great, in fact, that I decided that my 2500k didn't deserve to live. But that isn't really related to this.

For the past few days, my poor Thinkpad T61 and Firefox have been under the strain of 70+ tabs (think molasses in a South Dakota winter), some of which are normal load (OCF) and most were research into UEFI. I quickly learned that there was no single walkthrough or guide that explained exactly what needs to be done. These fragments made it difficult to understand exactly what UEFI does and what I need to do to make it work with Linux. I pictured it somewhat of a maze. There were multiple paths and the answer was not always clear, so I had to pick one way and see if it was a dead end and retrace my steps, hoping that I hadn't fallen into a pit and trashed my progress thus far. Surprisingly, it went nearly to plan.

Initially, it was my plan to wipe my SSD of Windows completely, start with a blank drive and install Arch. This would give me the basis for a walk-through that I could post here. I fully intend to follow through with this, but I need to solve this before I can continue! So, here are the exact steps and notes I have for the install, completely unedited.

DO NOT USE THESE INSTRUCTIONS
Assuming completely blank hard drive

Download the shell for uefi
https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#UEFI_Shell_download_links
Rename to shellx64.efi
Reboot into liveCD

Create the GPT partition and the UEFI partition
parted /dev/sda
(parted) mklabel gpt
(parted) mkpart fat32 1049kB 250MB
(parted) mkpart ext4 250MB 500MB
(parted) mkpart ext4 500MB 100%
(parted) toggle 1 boot
(parted) toggle 3 lvm
(parted) quit

Create the fat32 partition
mkfs.vfat -F 32 /dev/sda1

Create folders and mount the partition
mkdir /boot/efi
mount /dev/sda1 /boot/efi
cd /boot/efi

Copy your UEFI shell code to the new partition, yours will probably be different - my flash drive was automounted because of how I installed the bootable disk. I could not get this to work on my Gigabyte UD5H.
cp /bootmnt/shellx64.efi /boot/efi/

While I was at it, I installed the UEFI shell code to my flash drive, but I had some work to do first.
mount -o remount,rw /bootmnt
cd /bootmnt
mkdir -p ./efi/boot
cp x64_2.0.efi ./efi/boot/bootx64.efi

Install arch like normal. Do not install the bootloader. Exit the install to the command line. We need to get Grub2 install, so some preperation is required.
cp /etc/resolv.conf /mnt/etc/resolv.conf
mount -o bind /dev /mnt/dev
mount -t proc /proc /mnt/proc/
mount -t sysfs /sys /mnt/sys/
chroot /mnt bash
pacman-db-upgrade
pacman -Syy
pacman -S grub2-efi-x86_64 efibootmgr
grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot --recheck --debug
DO NOT USE THESE INSTRUCTIONS

To make the above short, there are three actual partitions.
1) UEFI
2) /boot
3) LVM (swap, /root)

Arch was installed like normal, but "aborted" before the bootloader was installed because it wasn't required. Grub2 was installed at that point to the UEFI partition. Upon reboot, there was no entry for the operating system. You can see the missing option in the BIOS:

uefi_1.JPG




Ok, so earlier in my notes, you see that I expected something like this in advance, so I created a bootable UEFI shell on my flash drive. I booted to that and listed out the partitions. As expected, Arch isn't there:

uefi_2.JPG




I added Arch to the boot list with the following command:
Code:
bcfg boot add 0 fs1:\EFI\arch_grub\grubx64.efi "Arch Linux (GRUB2)"
It confirms finding the file and adding it to the list. I double confirmed by outputting the current list of the current boot items and Arch is listed first:

uefi_3.JPG




Upon restarting out of the shell, I press F12 to use the device selection screen so I can manually pick the device. "Arch Linux" is listed, as expected -- perfect! Select it and let's go!

uefi_4.JPG




Oh baby, look at that sexy command line with all those ASCII values. Mmmm.

uefi_5.JPG




Ok, just to make sure I'm being thorough and a good tester, let's restart the system to see what----WHAT. WHAT IS THIS. :mad::mad::mad:WHERE DID IT GO.:mad::mad::mad:

uefi_6.JPG




I frantically mash the F12 button at startup to see my precious "Arch Linux" entry missing. What right does the motherboard think it has to simply delete my operating system bootloader? I put my flash drive in again, add the entry, restart, boot the operating system, restart -- same thing. I thought about it for a few seconds and figured that maybe the removal of the flash drive is causing it to reset as the settings could be saved on that. Nope, even if I keep the flash drive in, it dumps the settings on reboot. Looking further into how UEFI works, it looks like it is supposed to keep track of hard drive changes so you don't have to. This seems to be doing the exact opposite of that.

UEFI is the true destroyer of dragons. You don't need knights for this. Help? :eh?:
 
Last edited:
A few hours of meditation later, I might have figured out what was going on. It wasn't adding an entry to the boot menu. I've reinstalled a few times and no matter what, it isn't adding an entry. According to the instructions, it is supposed to do it automatically. I checked the folder structure and it looked like it was missing files in the /boot directory. I ran the grub-install again to see an error towards the bottom that wasn't being detected by grub. "Could not find efivars". Tried to modprobe, nothing. Figured out that the motherboard wasn't booting the USB drive as UEFI. Doing another reinstall...
 
I still can't get this installed, even with a UEFI modified installer (archboot). Everything is fine until it goes to install the bootloader, where it complains about missing /dev/map, which doesn't exist. I can't find any information online about it. It then tries to open it with a program, which obviously errors out. I restart to a UEFI GRUB screen, but it says it can't load the kernel.

If the stock Arch install booted as UEFI, I'd have no issues at all, but I can't get it to detect and I don't see a way to just force it on.

I'm about ready to just give up and go back to MBR. Come Monday, I need this system working. I have this weekend to fix it and I work every day.
 
Last edited:
I just don't care anymore. I'm going to set it up as mbr. Unless someone can tell me how to boot a normal arch install as UEFI, I'm just going the easy route. I don't have the time or patience for this anymore.

Archboot error:
"Setup detected no GUID (gpt) partition table on /dev/map. UEFI boot requires /dev/map to be partition as GPT. Setup will now try to non-destructively convert /dev/map to GPT using sgdisk."

I'm also having a very annoying and constant lock up while doing anything with USB devices. If I have a USB flash drive plugged in (tried multiple), the system will lock up while POSTing, in the BIOS, during installs, whenever it feels like it. The system is 22 hours LinX stable with a high ambient temperature. I even dropped the BIOS to completely stock settings and it does the exact same thing. I've been dealing with this for days and I'm seriously starting to get angry. I just dropped over 1k on hardware and this crap doesn't even work.
 
Last edited:
I did this once when I was running Arch!

https://wiki.archlinux.org/index.php/GRUB2#UEFI_systems_2
https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#efibootmgr

Eventually, my system died once (it was running from an eSATA 2.5 drive, and cats... cats DON'T like 2.5 drives, glad that I had home backed up daily...) and I no longer have it, but, if I ever install Arch or any Linux again (that will be just as soon as I sell my Bravura and get an ODA/ODAC from NwAvGuy / Epiphany Acoustics, I need music in order to live, and when that happens, Windows will be reduced to a mere Wintendo and Visual Studio thingy), I'd do that again.

Exactly, this was the command:

# efibootmgr --create --gpt --disk /dev/sdX --part Y --write-signature --label "Arch Linux (GRUB2)" --loader '\EFI\arch_grub\grubx64.efi'
 
I have the command, that isn't the issue. When I boot from the flash drive, it says that it isn't in UEFI mode, so it can't install to the UEFI section. That is my problem.
 
I have the command, that isn't the issue. When I boot from the flash drive, it says that it isn't in UEFI mode, so it can't install to the UEFI section. That is my problem.

Grrr... I also faced this and eventually found a solution...

I think it had something to do with the architecture... Have you selected the UEFI entry instead of the normal CD entry?

Use the ArchBoot iso instead of the standard ISO, I think that one has UEFI mode.
 
It is on a flash drive, but yes, I select the "UEFI: Kingston Flash Drive" option in the boot menu. I'm willing to take one more shot with a disk instead of a flash drive.
 
Have you tried ArchBoot disc? You can always dump the ISO to a flash drive.

Try booting grubx64.efi from the UEFI shell or, adding it again as you did before, starting Arch, and then running the command from there.
 
Yes, I'm running a GPT partition table. It is in the instructions that I wrote in my first post.
 
SUCCESS.

With a bit of trickery, I was able to get it working. I was not able to get the disk to boot as UEFI, but I remembered that I can manually boot the operating system once with the bcfg command, which allows me access to efivars. From here, I do my grub-install option and BAM, magic.

I'm going to grab an image of the hard drive in case I screw this up, but I'm going to reinstall, getting exact instructions as I go and attempt to install Windows on the same hard drive at the same time. Wish me luck.
 
SUCCESS.

With a bit of trickery, I was able to get it working. I was not able to get the disk to boot as UEFI, but I remembered that I can manually boot the operating system once with the bcfg command, which allows me access to efivars. From here, I do my grub-install option and BAM, magic.

I'm going to grab an image of the hard drive in case I screw this up, but I'm going to reinstall, getting exact instructions as I go and attempt to install Windows on the same hard drive at the same time. Wish me luck.

Glad you could do it!!

Maybe it's a bug with how the GA-Z77X-UD5H UEFI handles the UEFI boot options?
 
No idea. :shrug:

I'll be posting instructions shortly, I'm just testing them right now.
 
Now I don't know what to do... :shrug:

Shall I love you for posting these useful instructions... :thup:
Or shall I hate you for the Dvorak challenge sig link? :p

:chair: Thanks for the instructions anyway!! :3!
 
Back