You are not logged in.

#1 2012-12-11 15:39:26

skipperx
Member
Registered: 2012-12-09
Posts: 19

Grub2 Install in MacbookPro 9,2

I would like to get some help with installing grub2 in my first arch install. I am installing on a MacbookPro 9,2 to dual boot with existing OSX. Here is what I have done so far.
# Installed rEFIt in OSX.
# Shrunk the OSX size with disk utility inside the mac. Then I used GParted to add 2 ext4 partitions. My partitions and their intended use are as follows:
/dev/sda1     FAT     for efi system partition
/dev/sda2        OSX
/dev/sda3        OSX rescue
/dev/sda4    ext4    / for linux
/dev/sda5    ext4    /home for linux
# Sync the partitions and tables with refit.
# Installed arch after booting the dvd in efi mode following this guide.
https://wiki.archlinux.org/index.php/Be … therboards
To install the bootloader on the mac, I followed the steps for grub-uefi boot files in this guide.
https://wiki.archlinux.org/index.php/GR … onfig_file
I used or tried to use the sda1 (FAT) partition for efi-directory and /boot for boot-directoy.

# mkdir -p /mnt/boot/efi
# mount /dev/sda1 /mnt/boot/efi
# mkdir –p /mnt/home
# mount /dev/sda4 /mnt
# mount /dev/sda5 /mnt/home

# modprobe dm-mod
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
# mkdir -p /boot/grub/locale
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

At this stage, I thought I should install os-prober because of I am dual booting with OSX. So I did

# pacman -S os-prober

Then I generated grub2 uefi config file

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

Commands were processed and I got no error messages at the time. I also saw the grub.cfg file in the /boot/grub folder. Then I thought refit will let me choose the os for dual booting and I don’t really need to choose inside grub. I have no plan to add another OS. And I wanted to keep things simple. So I removed the os-prober with

#pacman –Rs os-prober

I renamed the old grub.cfg to something else.
Then I regenerated grub.cfg with

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

I got a new grub.cfg.
When I rebooted, I could choose the x86_64-efi option in the refit. When I clicked on it, I just got a grub shell
Grub>
So I thought I should try what they did on this page
https://wiki.archlinux.org/index.php/MacBookPro#GRUB
I rebooted the install dvd in efi mode again and tried these:

# cd /
# mount /dev/sda4 /mnt
# mount -t proc proc /mnt/proc
 # mount -t sysfs sys /mnt/sys
 # mount -o bind /dev /mnt/dev
 # chroot /mnt /bin/bash
 # grub

Then I got the msg

# bash: grub: command not found

I would think grub is already installed, but the installer now does not know where it is after I boot back in. Or I never installed it? If so, how do I install it while running the arch installer? Also can I edit the grug.cfg file to change to (hd0,0) ?
I really want to use arch. Any help would be much appreciated.

Offline

#2 2012-12-12 03:09:58

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

Here is my grub.cfg.

#
# 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_gpt
insmod ext2
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  f9a1bce5-533b-4975-8309-1f8d173df499
else
  search --no-floppy --fs-uuid --set=root f9a1bce5-533b-4975-8309-1f8d173df499
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 ###

### 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 ###

It looks quite different from the example shown here
https://wiki.archlinux.org/index.php/GR … _systems_2

I cannot find this section

# (0) Arch Linux
menuentry "Arch Linux" {
    set root=(hd0,1)
    linux /vmlinuz-linux root=/dev/sda3 ro
    initrd /initramfs-linux.img
}

Are there things in my grub.cfg that I can change and try? Can it do any harm to copy and try the example manual file with appropriate variables for my system?

Offline

#3 2012-12-12 04:00:27

caltac
Member
Registered: 2012-11-27
Posts: 22

Re: Grub2 Install in MacbookPro 9,2

I think since you're using UEFI, you should have run

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

EDIT: I'm not running arch right now, so forgive me if the path is wrong. But basically, you should be placing the grub config file in the ../efi directory, since you're booting from UEFI.

Last edited by caltac (2012-12-12 04:02:14)

Offline

#4 2012-12-12 13:45:07

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

Well, I did that because it was the recommended way to do for the grub-uefi installation according to this
https://wiki.archlinux.org/index.php/GR … onfig_file

ie, keeping the grub.cfg and the boot directory outside the uefi system partition. But it is not working and I am willing to try the other way. To do it, I will have to basically reinstall the grub.

I am no expert, but the grub.cfg that was automatically generated looks strange. I mean I cannot see the bits that's supposed to help boot the arch kernel.

I just noticed something else. There are 2 sets of commands to install the grub in ways mentioned above. In the set I used, --boot-directory term was missing from the command line.

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

----boot-directory term is present in the other set of commands.

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot/efi/EFI --recheck --debug

I am not sure if it was left out in the first one because the default boot-directory is /boot or it was a mistake. I also did not see the menu.list file in any of the folders even though I found grub.cfg.

I will also try rerunning the command with the --boot-directory term tonight.

Last edited by skipperx (2012-12-12 14:21:26)

Offline

#5 2012-12-12 16:36:43

srs5694
Member
From: Woonsocket, RI
Registered: 2012-11-06
Posts: 719
Website

Re: Grub2 Install in MacbookPro 9,2

I can't offer much help on the GRUB issues you're having, but I can say this: You began your installation in a way that's consistent with doing a BIOS-mode installation of Linux, but you're trying to install the EFI version of GRUB 2. In particular, using gptsync to create a hybrid MBR is necessary only when installing an OS in BIOS mode. On a computer that has no BIOS-mode OS, creating a hybrid MBR is useless at best and dangerous at worst. Although your priority is likely to be to get your system booting, I recommend correcting this problem by removing the hybrid MBR in favor of a conventional protective MBR ASAP. This issue is most likely not the source of your immediate problems, though; I mention it mainly because unnecessary use of a hybrid MBR is risky and so should be avoided.

Also and IMO, GRUB 2 is an unnecessary complication for your configuration. You'll probably find the following much easier:

  1. Replace rEFIt with rEFInd, which is an update/fork of rEFIt that I maintain. Running the "install.sh" script in OS X should do this task.

  2. Copy your Linux kernel (vmlinuz*) and initial RAM disk (init*) files from /boot to /boot/efi/EFI/arch (or the EFI/arch directory of wherever the ESP is mounted).

  3. Create a refind_linux.conf file in /boot, as described in the rEFInd documentation. Alternatively, create manual boot stanza(s) for the Arch kernel(s) in rEFInd's refind.conf file.

  4. Reboot.

At this point, rEFInd should come up and show you an option to boot Linux. If your configuration file has the right format and options, Arch should boot when you select the Linux option. No GRUB configuration is required, and the rEFInd configuration is simple by comparison. There is one complication because Arch names its initial RAM disks a bit oddly compared to what most distributions do. Many Arch users therefore take extra configuration steps, as described in the Arch wiki. The rEFInd documentation also covers this approach in more detail, including various alternative ways of doing it. If you plan to use Arch's stock kernels, though, sticking with the Arch wiki's way of doing things makes sense, at least initially.

A similar process is possible with gummiboot, which is a simpler text-mode-only boot manager for EFI systems, but the configuration details differ, and gummiboot takes more effort to maintain if you frequently add kernels.

Offline

#6 2012-12-14 02:02:21

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

Thank you for your help. I have replaced refit with refind now. I did the step 1 in mac and the rest in linux. I hope that's what you meant. In mac, I just did install.sh without mounting the fat partition. The files were written in /efi/refind directory. Is that normal or do I have to mount the fat partition and reinstall in mac? Seems to be working as it now though. I am a little surprised and confused how refind works without having the efi file in the fat partition.

I created, copied, and renamed things on the linux side per instructions as I understood. Now I can login!!

I would like to learn to make a basic useful refind_linux.conf file. Could you please point me to the right place.

Last edited by skipperx (2012-12-14 04:09:43)

Offline

#7 2012-12-14 06:07:41

srs5694
Member
From: Woonsocket, RI
Registered: 2012-11-06
Posts: 719
Website

Re: Grub2 Install in MacbookPro 9,2

skipperx wrote:

Thank you for your help. I have replaced refit with refind now. I did the step 1 in mac and the rest in linux. I hope that's what you meant. In mac, I just did install.sh without mounting the fat partition. The files were written in /efi/refind directory. Is that normal or do I have to mount the fat partition and reinstall in mac? Seems to be working as it now though. I am a little surprised and confused how refind works without having the efi file in the fat partition.

Apple's implementation of EFI can read HFS+ volumes as well as FAT volumes, and in fact a standard OS X-only installation reads the OS X boot loader from the main HFS+ volume. If you run rEFInd's install.sh from OS X without any options, the result is that it installs in the main OS X partition, just like the OS X boot loader and also just like rEFIt. You can install rEFInd to the EFI System Partition (ESP; the "fat partition" you mention), but this isn't necessary.

I created, copied, and renamed things on the linux side per instructions as I understood. Now I can login!!

That's good to hear.

I would like to learn to make a basic useful refind_linux.conf file. Could you please point me to the right place.

The quickest way to get started is to run the "mkrlconf.sh" file that comes with rEFInd 0.5.1 and later. Be sure to run it from your working Linux installation, though, not from an emergency disk. You can then edit this file as you see fit. Note that the important stuff it contains is kernel options, and in most cases you don't need much in the way of kernel options. Usually something like the following is adequate in refind_linux.conf:

"Standard boot options" "ro root=/dev/sda4"

The boot options themselves are the second quoted field ("ro root=/dev/sda4"); the first field is the rEFInd entry name. The device ("/dev/sda4") has to be customized for your system. Sometimes additional options are required because of hardware- or installation-specific issues. You might also want to edit it to create a "boot splash" rather than a scrolling list of boot messages, to create emergency options (like adding "single" to boot into single-user mode for maintenance), or for other reasons. None of these are rEFInd-specific, though.

You must also pass an initial RAM disk filename to the kernel. rEFInd does this automatically, but the algorithm it uses to match the kernel to the initrd file isn't optimal for Arch, so some Arch users prefer to create entries in refind.conf. The Arch wiki describes such matters in detail:

https://wiki.archlinux.org/index.php/UE … ing_rEFInd

The rEFInd documentation covers Linux setup options more generally, but with less in the way of Arch-specific details:

http://www.rodsbooks.com/refind/linux.html

Offline

#8 2012-12-16 18:54:08

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

I am almost there. I made the refind_linux.conf per instructions. I got 2 lines in it after running mkrlconf.sh. Then I tried to pass the initial RAM disk file name with linux.conf file per
https://wiki.archlinux.org/index.php/UE … ng_EFISTUB

Then I saw your note about linux.conf no longer being used. So I added the line from linux.conf file to refind_linux.conf file. My refind_linux.conf file is below:

"Boot with standard options" "root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499 ro add_efi_memmap initrd=\EFI\arch\initramfs-arch.img quiet splash"
"Boot to single-user mode"   "ro root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499  quiet single"

Is it a correct way to pass the initial ram disk file name?
Is it OK to use UUIDs as opposed to partUUIDs as shown in archwiki example?
Is initramfs-arch.img is the bit that is providing the "standard options" in this case?

While it was booting, I noticed a msg which led me to believe that I am really booting with the fallback.img even though I did not specify it in the conf file. Here is the part of dmesg

#dmesg | grep img
[    0.000000] Command line: vmlinuz-arch.efi root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499 ro add_efi_memmap initrd=\EFI\arch\initramfs-arch.img quiet splash initrd=\EFI\arch\initramfs-arch-fallback.img
[    0.000000] Kernel command line: vmlinuz-arch.efi root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499 ro add_efi_memmap initrd=\EFI\arch\initramfs-arch.img quiet splash initrd=\EFI\arch\initramfs-arch-fallback.img

How can I stop it from automatically adding and booting with the fallback.img?

BTW, after I limped my way in, I was able to startx and do other things normally.

Offline

#9 2012-12-16 19:23:24

srs5694
Member
From: Woonsocket, RI
Registered: 2012-11-06
Posts: 719
Website

Re: Grub2 Install in MacbookPro 9,2

skipperx wrote:

I am almost there. I made the refind_linux.conf per instructions. I got 2 lines in it after running mkrlconf.sh. Then I tried to pass the initial RAM disk file name with linux.conf file per
https://wiki.archlinux.org/index.php/UE … ng_EFISTUB

Then I saw your note about linux.conf no longer being used. So I added the line from linux.conf file to refind_linux.conf file. My refind_linux.conf file is below:

The Linux developers planned to use the linux.conf filename themselves, but I don't know if that support has yet made it into an released kernels. If it has, the file format is different from that of refind_linux.conf -- linux.conf should just have a single line of raw kernel options, as I understand it, whereas refind_linux.conf supports multiple lines, each with two quoted fields -- a label and a set of options.

"Boot with standard options" "root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499 ro add_efi_memmap initrd=\EFI\arch\initramfs-arch.img quiet splash"
"Boot to single-user mode"   "ro root=UUID=f9a1bce5-533b-4975-8309-1f8d173df499  quiet single"

Is it a correct way to pass the initial ram disk file name?

Not in any released version of rEFInd; however, I've got a test version in which passing an initrd filename in an option field overrides the auto-detected initrd image. You can try the test version by downloading the binary from here:

http://www.rodsbooks.com/refind-bin-0.5.1.6.zip

(Note: That download link is likely to disappear soon, since I'm preparing a new non-test release. Check the rEFInd download page for links to the latest official release.)

Is it OK to use UUIDs as opposed to partUUIDs as shown in archwiki example?

Yes.

Is initramfs-arch.img is the bit that is providing the "standard options" in this case?

I'm not sure what you mean by "standard options." The use of that term in the refind_linux.conf file is arbitrary; it just means the default options for your configuration. You can change those options to anything you might like, and you can change the description to anything you like (although at present, the description for the first line is ignored and replaced with a stock one, just because of a quirk of the way the code is structured).

How can I stop it from automatically adding and booting with the fallback.img?

Either by using the test version (or the next regular release, which I expect to make available sometime today or tomorrow) or by ditching the auto-detection and instead relying on manual boot stanzas. There are other possible ways to coax it into working, but as such workarounds are awkward and will be obsolete once I make my next release, I don't think it's worth describing them at this point.

Offline

#10 2012-12-17 13:03:10

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

Thank you for the answers. I did get the one-line linux.conf file per instructions on
https://wiki.archlinux.org/index.php/UE … ng_EFISTUB

I will keep using it for now and remove the initrd file term from the refind_linux.conf. I had thought that those 2 files could not co-exist. I can wait for the new release of refind to deal with the fallback.img issue.

Offline

#11 2012-12-18 00:46:03

srs5694
Member
From: Woonsocket, RI
Registered: 2012-11-06
Posts: 719
Website

Re: Grub2 Install in MacbookPro 9,2

skipperx wrote:

I can wait for the new release of refind to deal with the fallback.img issue.

No need; I released it last night. Check its downloads page for download links.

Offline

#12 2012-12-20 15:29:13

skipperx
Member
Registered: 2012-12-09
Posts: 19

Re: Grub2 Install in MacbookPro 9,2

I installed the new refind in OSX and added initrd term in the first default booting line of refind_linux.conf file like this;

............ initrd=\EFI\arch\initramfs-arch.img .......

There is no initrd term in the 2nd line for single user booting.

It is working now. It is booting with initramfs-arch.img for normal booting and initramfs-arch-fallback.img for single user mode.

Thank you for your help.

Offline

#13 2012-12-20 16:58:59

srs5694
Member
From: Woonsocket, RI
Registered: 2012-11-06
Posts: 719
Website

Re: Grub2 Install in MacbookPro 9,2

skipperx wrote:

I installed the new refind in OSX and added initrd term in the first default booting line of refind_linux.conf file like this;

............ initrd=\EFI\arch\initramfs-arch.img .......

There is no initrd term in the 2nd line for single user booting.

It is working now. It is booting with initramfs-arch.img for normal booting and initramfs-arch-fallback.img for single user mode.

Be aware that when you omit the initrd= option from refind_linux.conf, rEFInd uses whatever initrd file it finds first that matches the (nonexistent for Arch) numbers in the kernel's filename. Since the scan order of those initrd files is not guaranteed, the result is that you could end up booting with the wrong initrd when you select your second option the next time you update your kernels.

The bottom line: For this type of configuration (when the kernel matches multiple initrd files), I recommend specifying your initrd file on all the lines in refind_linux.conf.

Thank you for your help.

You're welcome.

Offline

Board footer

Powered by FluxBB