You are not logged in.

#1 2017-04-12 17:43:20

amscisr
Member
Registered: 2017-04-12
Posts: 14

[SOLVED] GRUB install on dual boot UEFI system

I installed Arch Linux by following the Installation guide. When I got to the section on installing the bootloader, I chose GRUB and attempted to install it (again, following the guide for installing GRUB on a UEFI system). I will briefly explain the steps that I took followed by the problem experienced.

Mount the partitions and chroot from live UEFI USB:

# arch-chroot /mnt /bin/bash

Install grub and efibootmgr:

# pacman -S grub efibootmgr

With the ESP partition /dev/sda1 mounted at /boot as such:

# mount /dev/sda1 /boot

Install GRUB:

# grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub

Then finally generate the grub.cfg file as follows:

 # grub-mkconfig -o /boot/grub/grub.cfg

Everything seems to work properly, including detecting my Linux Mint install on sda6 (which I plan to remove after getting Arch setup properly) after I installed os-prober. However, when I reboot:

# exit
# umount -R /mnt
# reboot

(Sub-problem: I get messages that /run/... cannot be unmounted, the reboot hangs, and I have to manually power off the system)

The main problem however is that when loading GRUB, I only get options for my Mint installation, with no trace of Arch (the installation guide indicates that grub-mkconfig will automatically detect the Arch root partition as long as you are chrooted or booted into that partition, which I was).

I have tried this in several other ways:

  • Install GRUB without using os-prober. Result: I get a CLI with no boot options.

  • Install GRUB with additional custom configuration by editing /boot/grub/custom.cfg with "shutdown", "restart", and "firmware setup" menu entries. Result: All of the menu entries work, but still no Arch to be seen.

A few things to note:

  • This is already a dual boot system with Linux Mint 18.1 KDE and Windows 10. I did not attempt to add Windows manually it to the GRUB menu yet; when I need to boot into it (rarely) I can choose it from system setup.

  • I've removed my attempts at installing GRUB from the system by deleting the GRUB directory on /mnt/boot and using efibootmgr to remove the entries from UEFI boot options on startup. So, if this successfully removed the GRUB that I configured, I should be able to configure from scratch once I figure out why Arch isn't being automatically added to the menu. Right?

Any help in resolving this issue would be much appreciated (and if there's a fix for the sub-problem with rebooting from live USB, also...). Thank you!

Last edited by amscisr (2017-04-13 02:57:40)

Offline

#2 2017-04-12 20:35:34

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,475
Website

Re: [SOLVED] GRUB install on dual boot UEFI system

amscisr wrote:

I installed Arch Linux by following the Installation guide.

This is far too vague, please post a list of the *exact* commands that you used in the order that they were entered.

For example, it is not clear whether you mounted /dev/sda1 to /boot before or after using `arch-chroot`; the ESP must be mounted before using `pacstrap` — did you do this?

You should also post the content of /boot/grub/grub.cfg

Finally, if a hard power cycle was used with the filesystems mounted, there may be corruption and data loss, the FAT filesystem on the ESP is particularly susceptible to this.


Para todos todo, para nosotros nada

Offline

#3 2017-04-12 20:53:01

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Head_on_a_Stick wrote:

This is far too vague, please post a list of the *exact* commands that you used in the order that they were entered.

Here is what I did (after booting USB in UEFI mode).

# ls /sys/firmware/efi/efivars

to verify the boot mode (directory exists).

# wifi-menu

to connect to Wifi.

# ping google.com
# timedatectl set-ntp true

Then mounted filesystems. Already partitioned using GNU Parted live USB. Partitions are as follows: /dev/sda9 => formatted as ext4 for /, /dev/sda10 => formatted as ext4 for /home. Using lsblk found that /dev/sda1 contained ESP.

Then mounted formatted partitions as follows:

# mount /dev/sda9 /mnt
# mkdir /mnt/home
# mount /dev/sda10 /mnt/home

Installed base packages:

# pacstrap /mnt base

Configuration:

# genfstab -U /mnt >> /mnt/etc/fstab
# arch-chroot /mnt
# ln -sf /usr/share/zoneinfo/Canada/Eastern /etc/localtime
# hwclock --systohc
# locale-gen

Set the hostname by creating /etc/hostname. Added 127.0.1.1 *hostname*.localdomain *hostname* to /etc/hosts.

# pacman -S iw wpa_supplicant dialog

Set root password using passwd. Then, proceeded to install the bootloader (as described in detail in my initial post).

More importantly (I think):
No, I did not mount ESP before using pacstrap. I suppose this is the important point that I overlooked, although it was not specified explicitly in the installation guide besides as a side note to mount any remaining partitions.

Please see /boot/grub/grub.cfg as follows:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos5'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  ad4103fa-d940-47ca-8506-301d8071d467
else
  search --no-floppy --fs-uuid --set=root ad4103fa-d940-47ca-8506-301d8071d467
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-ad4103fa-d940-47ca-8506-301d8071d467' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos5'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  ad4103fa-d940-47ca-8506-301d8071d467
	else
	  search --no-floppy --fs-uuid --set=root ad4103fa-d940-47ca-8506-301d8071d467
	fi
	echo	'Loading Linux core repo kernel ...'
	linux	/boot/vmlinuz-linux root=UUID=ad4103fa-d940-47ca-8506-301d8071d467 rw  quiet
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initramfs-linux.img
}
menuentry 'Arch Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-ad4103fa-d940-47ca-8506-301d8071d467' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos5'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  ad4103fa-d940-47ca-8506-301d8071d467
	else
	  search --no-floppy --fs-uuid --set=root ad4103fa-d940-47ca-8506-301d8071d467
	fi
	echo	'Loading Linux core repo kernel ...'
	linux	/boot/vmlinuz-linux root=UUID=ad4103fa-d940-47ca-8506-301d8071d467 rw  quiet
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initramfs-linux-fallback.img
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

And finally, thank you for the information regarding the hard power cycle. I went back into my UEFI boot of the Arch iso and figured out how I believe the correct way to reboot the system is: could you confirm that I should: exit the chroot environment, then unmount (using umount -R /mnt) the mounted partitions, then remove the installation media, then after removing the USB, use reboot?

I appreciate your response and await insight from the grub.cfg file and the revelation that I pacstrapped before mounting ESP to /boot.

Thanks!
-amscisr

Offline

#4 2017-04-12 21:32:11

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,475
Website

Re: [SOLVED] GRUB install on dual boot UEFI system

That grub.cfg contains Arch menu entries but no Mint entries.

Are you sure that the machine is booted in UEFI mode when the GRUB menu is shown?

Is Mint installed in UEFI mode? Does it boot with UEFI enabled?

If you ran `pacstrap` & `genfstab` before mounting the ESP then your system will have another /boot on the root partition (sda9), you will need to correct this.

A fresh installation using the knowledge gained in this thread may be the best approach here.


Para todos todo, para nosotros nada

Offline

#5 2017-04-12 21:42:27

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Yes, I did notice that when I posted it which I found strange, but since I'm new to Arch at this point wasn't sure what steps to take to investigate how it could be that Arch is shown in the cfg but Mint in the menu. Mint is indeed booted in UEFI mode and so is GRUB when it's shown (I access it through UEFI options on the system setup menu).

I will follow your advice and do a fresh installation. I think I know more about where the boot partition has to be mounted now, thanks to this whole process, so hopefully this is the first step towards not just using but understanding Linux, one of my goals when I started out trying Arch smile

One more question before I attempt this -- to prepare my sda9 and sda10 partitions for reinstalling Arch, could I just format them again as ext4 from GNU Parted? What about sda1, is all I need to do for that remove the references to archgrub (my bootloader-id) using efibootmgr or is there another step to completely remove the bootloader from ESP in preparation for reinstall?

Oh, and also what about the correct method to reboot from installation media. Am I correct in removing the USB after umount is used but before typing reboot? Don't want to risk losing data from the ESP as you mentioned is possible!

Thanks for your help smile
- amscisr

Last edited by amscisr (2017-04-12 21:50:10)

Offline

#6 2017-04-12 21:52:04

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,475
Website

Re: [SOLVED] GRUB install on dual boot UEFI system

amscisr wrote:

to prepare my sda9 and sda10 partitions for reinstalling Arch, could I just format them again as ext4 from GNU Parted?

Yes, I think that would work.

A simple `mkfs.ext4` should also do it if you were impatient  big_smile

What about sda1, is all I need to do for that remove the references to archgrub (my bootloader-id) using efibootmgr

That should be all that is needed, UEFI is easier to manage than the old methods.

Be sure not to disturb any of the other files on the ESP from your other distribution, any Arch-specific files should be overwritten upon the reinstall anyway.


Para todos todo, para nosotros nada

Offline

#7 2017-04-12 21:59:07

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Head_on_a_Stick wrote:

A simple `mkfs.ext4` should also do it if you were impatient  big_smile

Very true. Gotta practice those CLI skills!

amscisr wrote:

Oh, and also what about the correct method to reboot from installation media. Am I correct in removing the USB after umount is used but before typing reboot? Don't want to risk losing data from the ESP as you mentioned is possible!

Added that question in an edit just before you replied so I don't think you saw it. Seems like a basic but important aspect of the process so I want to make sure I'm doing it right.

Offline

#8 2017-04-12 23:51:02

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] GRUB install on dual boot UEFI system

When exactly did you ran the /boot mount command? Apparently after pacstrap? If that's the case it's perfectly expected that grub(-mkconfig) won't find Arch kernel and hence no entry generated for it.

grub-install has a --boot-directory (different from --efi-directory) switch that has implied value /boot, so if the "/boot" grub knows (i.e. the ESP, because it was mounted to /boot) is not the "/boot" (i.e. /boot directory on the / partition, because nothing was mounted to /boot) you installed the Arch kernel to, then certainly it will not be aware it.

P.S. --efi-directory is the location to install the EFI executable to, which means it should always be the mount point of the ESP, while --boot-directory is where to put the grub modules and grub.cfg et. al., which can be pointed to anywhere _as long as you know what you are doing_

Offline

#9 2017-04-13 00:22:01

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Thanks tom.ty89 for this detailed explanation of why mounting ESP to /boot after pacstrap will result in grub-mkconfig not finding the Arch kernel. This makes a lot of sense! That was indeed the order in which I ran the commands, so now I know how to do it correctly and why the original attempt resulted in a misconfigured grub.

Would you happen to have an explanation for why when exiting the chroot environment and rebooting, the process hangs at umount?

Offline

#10 2017-04-13 00:30:42

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

amscisr wrote:

Would you happen to have an explanation for why when exiting the chroot environment and rebooting, the process hangs at umount?

I have found the solution to this problem myself actually, by experimenting a bit with booting from the ISO. The solution in my case was adding nouveau.modeset=0 as a kernel parameter. This fixed the problem.

I'll be attempting a clean installation of Arch Linux with my newly gained knowledge of the process soon, and will mark the thread as [Solved] if I succeed in using this fix to add Arch to the bootloader.

Thanks again Head_on_a_Stick and tom.ty89 for your prompt assistance!

-amscisr

Offline

#11 2017-04-13 00:35:26

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] GRUB install on dual boot UEFI system

amscisr wrote:

Would you happen to have an explanation for why when exiting the chroot environment and rebooting, the process hangs at umount?

Not sure. Does the hang always occur? Like if you boot it and do nothing but just wait for 30s and reboot?

I wonder if it's related to the fact that you (apparently) mounted a partition in chroot (and worsestill you didn't umount it manually before exiting chroot). I don't know if it is supposed to cause problem but we rarely do that.

Anyway you won't be doing it anymore coz you will need to mount /boot (literally /mnt/boot) before pacstrap.

Last edited by tom.ty89 (2017-04-13 00:38:26)

Offline

#12 2017-04-13 00:48:43

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Yeah, thankfully it wasn't anything to do with mounting the partitions in chroot and was simply related to the kernel boot options (modeset).

Is there a specific reason why it's bad to mount partitions in chroot? I obviously won't do it again, but am interested in knowing the technical explanation behind it too. Perhaps that will also help in avoiding future problems.

Offline

#13 2017-04-13 01:01:48

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] GRUB install on dual boot UEFI system

Well, I haven't concretely heard that it is bad, instead it's just a sense/hunch of mine, as in, you should present an all set environment for chroot to work on, but not adding something from outside after it is done, which might be confusing to it and the whole system. Truth is, unlike for grub, I never really get to know about chroot, I just use it, with the wrapper arch-chroot.

Last edited by tom.ty89 (2017-04-13 01:02:55)

Offline

#14 2017-04-13 02:57:21

amscisr
Member
Registered: 2017-04-12
Posts: 14

Re: [SOLVED] GRUB install on dual boot UEFI system

Either way, mounting my ESP to /mnt/boot before pacstrap solved my problem. I have a working Arch installation that I can actually boot into. Now on to the fun part! Marking this thread as [SOLVED], thank you again for your help.

-amscisr

Offline

Board footer

Powered by FluxBB