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

How to install Arch Linux on a UEFI motherboard

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 spent many hours trying to get Arch Linux installed on my brand new computer and it was somewhat painful. The instructions for UEFI in the ArchWiki are very thorough and well-documented. The problem is, they are not sorted in a fashion that makes it easy for doing a single install. It forces you to jump around between articles and points within an article. It can quickly get confusing. I'd rather not see anyone else have to go through this, so I wrote a guide.

Side note: If your motherboard can boot a CD in a UEFI environment, you can stop following my instructions after the first "grub-install" and "grub-mkconfig" commands. You'd just reboot and the operating system would already be in the list. Additionally, you would not need a UEFI bootable flash drive, but honestly, it is nice to have.

These instructions assume you have a completely blank hard drive. If you are going to start over, erase the beginning of the drive to delete the partitions. I won't explain how to do that here in case someone is not paying attention to what I'm saying and is just typing stuff in the command line!

Download and burn the Arch install to a disk (you could also do this with a bootable flash drive). http://www.archlinux.org/download/

Download the shell for UEFI, we will use this later to get into a UEFI environment. In case this link does not work, I've attached it to this post.
https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#UEFI_Shell_download_links
Rename the file to bootx64.efi
Place the bootx64.efi file in /efi/boot/ (So, the file is located at "[flash-drive]/efi/boot/bootx64.efi") on a flash drive that is formatted FAT32. That is all that needs to be done for now.

Boot the Arch install disk on the target computer

Create the GPT label, the UEFI partition, and then setup the disk how you want.
Code:
parted /dev/sda
(parted) mklabel gpt
(parted) mkpart fat32 1049kB 250MB
(parted) mkpart ext4 250MB 100% ([COLOR=Lime]Note, you can set this up however you want.  I use a LVM later for this.[/COLOR])
(parted) toggle 1 boot
(parted) toggle 2 lvm
(parted) print ([COLOR=Lime]Verify your setup before exiting[/COLOR])
(parted) quit
Once you have the partitions done, run the normal Arch setup. You want to run the install until we get to the bootloader install section. We do not want to install GRUB.

Code:
/arch/setup
Select your source and setup your network if you are using a net install
Select editor
Select region and time

Prepare the hard drives:

  1. Select manually configure
  2. Select by label

Select /dev/sda1

  1. format as "vfat"
  2. mountpoint is "/boot"
  3. label is whatever you want (I leave it blank)
  4. additional opts is "-F32" (no quotes)

Select /dev/sda2

  1. format this how you want, I use a LVM, which I'll describe here
  2. format as "lvm-pv"

Select /dev/sda2+ lvm-pv

  1. give it a name, I use the name of my computer

Select /dev/mapper/[lvm-name] lvm-vg

  1. select New
  2. label is "swap"
  3. size is whatever you want for swap

Select /dev/mapper/[lvm-name] lvm-vg

  1. select New
  2. label is root
  3. size is whatever is remaining for the lvm

Select lvm container swap

  1. format as "swap"

Select lvm container root

  1. format as "ext4"
  2. mountpoint is "/"


Select packages:
  1. Select "grub" when it asks to choose the bootloader
  2. Select "base" (hit enter)
  3. Look through the list until you find "grub", highlight it and press the space bar to deselect, then press enter

Install packages

Configure system:
  1. Select "/etc/rc.conf"
  2. Locate the "modules" line and add "efivars" into the parenthesis - "MODULES=(efivars)"
  3. Save and close rc.conf
  4. Set the root password

SKIP Install bootloader

Exit the installer

This will drop you to a command line, type the following
Code:
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-key --init
pacman-key --populate archlinux
pacman -S grub2-efi-x86_64
grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch --boot-directory=/boot --recheck --debug
grub-mkconfig -o /boot/grub/grub.cfg
You will notice towards the end of the "grub-install" that it *does give an error*. "Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables." Ignore this error. We are not currently in an UEFI environment, so we can't install it just yet. This is where that flash drive we prepared earlier comes into play. Put that into the computer and reboot the system. At restart, select your motherboard's device selection screen (F8 on Asus, F12 on Gigabyte) and select the UEFI option for your flash drive. On my Gigabyte board, it was labeled as "UEFI: USB USB USB Hard Drive", no that isn't a typo. This should bring you to a UEFI Interactive Shell.

When it starts up, it outputs all the hard drives on the system. When booting to my flash drive, FS0 is the flash drive itself and FS1 is my Intel SSD. Yours may vary, so make sure you have the right one selected when you type in the following command:

Code:
bcfg boot add 0 fs1:\efi\arch\grubx64.efi "Arch Linux"
The entry we just added to the motherboard is temporary, so if you restart after booting once, it will be missing and you will have to add it again. Restart the computer and select the device boot menu again. You should see "Arch Linux" in the list, select it and let the system boot like normal. Right after the grub window, you may see a bunch of lines that say "Ooops! Too many entries in the memory map!". I get these on my system and they don't seem to hurt anything. If you have information on what these are or how to fix them, I'm open to suggestions.

Before we add the entry into the UEFI section of the motherboard, we need to make sure that we can see the EFI variables. Type "efibootmgr" and you should get no errors. It should list all the current boot devices. If you do not see this list or get an error, type "modprobe efivars" and try again. If that doesn't work, post here and we can help you sort out what is going on.

To add your Arch install permanently, we will use the previous command for grub-install:
Code:
grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch --boot-directory=/boot --recheck --debug
At the end, you should *not* get an error. It should say something along the lines of "No error reported". You can confirm it got added by typing "efibootmgr", which should list the newly added entry. Reboot and the entry should be in the boot menu. You can now use this like normal. I'd like to make a note that this entry stays even if the hard drive is completely wiped. If you want to delete an entry, boot to the UEFI flash drive that you made and type "bcfg boot dump" to get the boot list. This will give you numbers (00, 01, etc) that correspond with the entry. You can remove them by typing "bcfg boot rm xx" where "xx" is the number of the entry from the dump command.

If anyone has any questions or hits any issues during the install, please let me know and I'll do my best to help you out.
 

Attachments

  • bootx64.zip
    241.2 KB · Views: 530
Last edited:
Well informed guide.... when I get an UEFI motherboard I will definitely give this a go!
 
I may have to give this a shot the next time I break my bootloader. The past few upgrades of grub2 (but thankfully not the latest) have had problems figuring out what drivers to install, with the result that after the upgrade is complete I'm left with a nearly empty /boot/grub directory and a headache waiting upon my next reboot...

JigPu
 
Thanks Thideras! I've always wanted to give Arch Linux a go, but my Linux-fu is not quite there yet.
 
Found archwiki quite complex and quite liked your summary, so decided to have a go installing Arch following your instructions, and got stuck. Using a SSD as /dev/sda. Parted worked (and I confirmed it worked using gparted in a livecd). However in the section "manually configure", the setting of mountpoints does not seem to work, as when I select done, it claims it cannot find /boot or /. It is as if it cannot deal with GPT disks. Any suggestions?
 
Hello poppyfields and :welcome: to the forums,

When you boot the Arch Linux disk, can you post the output of "parted /dev/sda print"? Did you format /dev/sda1 as vfat and with the "-F32" option, then select it as /boot?

Does it give you the error when you go to format? If not, please explain the exact steps you do to get the error.
 
Thank you for such a quick reply. I think I just found the problem as you emailed me back. Not a fault with your instructions but with the /arch/setup. I was trying to use the latest arch snapshot 2012-05-19 to install, as I read that kernel 3.3 should be used. When I went to use an older snapshot from April, it worked. Basically any setup in the manually configure filesystems section was not being executed. Serves me right for trying to be too up to date. Will try to setup tomorrow.
What I really wanted to do was to avoid using grub at all, and use EFISTUB (for which kernel 3.3 is supposedly needed). It seems a bit more complex, but I was going to try and follow the wiki after setting up the first part using your instructions.
 
You could always delete the grub installation after you get the system booted properly. Remember that the portion where I have you boot to the flash drive only adds a temporary entry to the motherboard to get into a EFI environment within the operating system. So, you could boot the first time, do a "pacman -Syu" to get the 3.3 kernel (or whatever you need to do), restart, add the temporary entry again and boot the operating system. From there, you could technically install EFISTUB instead of grub. All you'd have to do is remove the grub2 package and delete the extra files on the /boot partition.
 
Last edited:
I think you are right. I will follow your guide to the end and then play around with EFISTUB. There appears to be a workaround to use EFISTUB, but it looks like a lot of hassle, and grub seems a safer option. Just looking through the recent snapshots of Arch, there are not too many successes. Interestingly the official snapshot 2011.8.19 panics on my system with loss of screen output, so I cannot even work out why. Using core i5 gen3 and Z77, with no graphics card - I guess there must be something that the kernel does not support. Thanks for your input and the great How-to.
 
Is there a reason you are using such an old snapshot? I think I'm using 04-29-2012 (or around there) and it works fine on my system.

Glad I could help!
 
They do not keep all the snapshots available for download (or maybe there is a repository somewhere else). Tried it out today and stuck again. First of all your vfat option should be -F 32, (not -F32 which reported errors). Unfortunately I'm a noob, and thought it would not matter. Unfortunately UEFI does not recognise FAT16, and therefore I never had a fs1:.
Grub is loading ok, but I cannot load arch.
Error: no such device: UUID num
I wonder when I converted FAT16 to FAT32 it changed the UUID.
I will chroot and try installing grub again
 
They must have changed it, -F32 works no problem for me. I did at least 40 installs with that option. :shrug:
 
Managed to boot a cd iso in UEFI, but the install command for grub would not work (complained of a read only system in /efi even when mounted normally). Going to try and install from scratch.
 
are you sure that this is an issue with all UEFI motherboards instead of the old BIOS? because i've had 0 problems booting live cd's, live usb keys, or had drives with linux already installed on any board i've tested that was UEFI. Sounds like this is more an issue with GRUB and GPT vs MBR partition tables. Which UEFI will boot MBR drives without an issue.
 
Splat, I'm not sure who you are talking to.
 
Just to update, your instructions worked. Also managed to boot using UEFI and kernel 3.3 directly (using arch UEFI bootloader wiki instructions), so now I have a backup if grub2 fails. Thanks for all your advice.
:clap:
 
No problem, and I'm glad it worked for you!
 
Hi thideras,
first let me give you my ongratulations to this post. Really you are my motivation to this forum due the simpliest post with the installation of Arch. I've mounted a new desktop pc with a gigabyte motherboard and of course UEFI. I've read a lot of info and some time confused due extense of that. you are very clear and helpfully. So as certainly might you know, at this time of the UEFI match is dificult and very hardly to install linux in UEFI linux users. I've used Linux since 1.5 yr ago and tested 15 or more linux distros, so i have some experience for installing in BIOS mode and MBR, but in UEFI is dificult and complicated. For now Ubuntu, fedora and ArchBang are my preferible distro than i would like to install in my new desktop-UEFI motherboard. Finally yesterday i did install Ubuntu 12.10 alpha1, because was the only one that allow me to partition the sataIII disk 1T and the installation was pretty good and smootly. Now is functioning very well, but its alpha1 release, you know might be crash the system at any time. You know that ubuntu 1210 it's using his own bootloader not grub2, i guess for this notice https://lists.ubuntu.com/archives/ubuntu-devel/2012-June/035448.html
So the big question is, could you help me to install Arch x64 at side of Ubuntu? I'll be wonderfully if you accept the target litle by little and step by step, please. Thank you.
 
Hello EsteBandido and welcome to the forum! I don't have enough experience to help directly with Ubuntu. Does that distro let you switch to GRUB2? If so, you could simply follow my directions to get both installed fairly easy.
 
Hello thideras, thank you for your quickly answer. I've partitioned my gpt disk and inluded sda5 & 6 as partiton for install ArchLinux at side of my Ubuntu. Yes, i don't wat to wipe the disk. I've doing a backup of grub in case of disaster (mostly jejeje), but when the preparation of Arch installation 'prepare hard drive' in manually partitions it seems like cfdisk don't reognize the partitions in the disk and i can't continue. so a message FATAL ERROR: annot open drive, prees any key to exit fdisk. So i jumping to the next stage of instaling 'Manually onfigure block devices' and ... tomorrow i will be doing other attempt... thank you ¡¡
 
Back