Skip to content

Instantly share code, notes, and snippets.

@gretzky
Last active October 29, 2023 13:44
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gretzky/149e8ebe7a8f317cc687f82c1aacf1a0 to your computer and use it in GitHub Desktop.
Save gretzky/149e8ebe7a8f317cc687f82c1aacf1a0 to your computer and use it in GitHub Desktop.
dual booting arch linux on a macbook pro 12,1 (retina, 13", 2015)
#####################################################
# dual booting arch linux & macOS
# on a macbook pro 12,1
# ft. rEFInd
#
# this guide has been smashed together from a variety
# of other awesome guides out there for dual booting
# including but not limited to:
# mark nichols' 5 part guide: https://zanshin.net/2015/02/05/arch-linux-on-a-macbook-pro-part-1-creating-a-usb-installer/
# the arch linux docs: https://wiki.archlinux.org/index.php/mac#Arch_Linux_with_OS_X_or_other_operating_systems
# jonathan yantis' crazy insta-arch scripts: https://github.com/yantis/instant-archlinux-on-mac
#
# for each major step, i've denoted where you should
# be booted to in order to complete the step
#####################################################
######
step 1. (macOS) - install arch linux to bootable USB
######
# download an ISO of arch (https://www.archlinux.org/download/)
# convert the ISO to UDRW format
hdiutil convert -format UDRW -o destination_file.img source_file.iso
# if you prefer a GUI, i recommend Etcher (https://etcher.io/)
# otherwise...
# format the USB
- run `diskutil list` and find the identifier for your USB (/dev/diskX)
- erase the USB completely
- run `diskutil partitionDisk /dev/diskX 1 "Free Space" "unused" "100%"
# copy the iso to usb:
dd if=destination_file.img of/dev/diskX bs=1m
# if you had an issue with the filetype you created (the `.img.dmg`),
# you can remove `.dmg` from the filename.
# eject the drive
diskutil eject /dev/diskX
######
step 2. (macOS) - partition disk
######
# set aside a partition for arch linux in disk utility.
# make sure the new partition is any filesystem type except APFS.
# you'll be erasing this anyway.
######
step 3. (macOS) - install rEFInd
######
# at this point, plugin your the USB stick with arch you created.
# get rEFInd here: https://sourceforge.net/projects/refind/files/latest/download
# unzip and install rEFInd by running ./refind-install in the directory
# verify it works by restarting. you should be immediately brought to the
# rEFInd menu. from there, boot into your USB.
######
step 3a. OPTIONAL (macOS) - configure rEFInd
# in order to configure rEFInd, we have to edit the refind.conf
# mount the EFI partition and go to it
sudo mount -t msdos /dev/disk0s1 /Volumes
cd /Volumes/EFI/rEFInd
# download your chosen theme with git
# in this case, i chose rEFInd-minimal
git clone https://github.com/EvanPurkhiser/rEFInd-minimal
# add the theme to refind.conf
echo "include rEFInd-minimal/theme.conf" >> refind.conf
# change the icon paths in refind.conf
vi refind.conf
# locate the menuentry configs and change the path after icon
# for arch linux: /EFI/refind/themes/rEFInd-minimal/icons/os_arch.png
# for macOS: /EFI/refind/themes/rEFInd-minimal/icons/os_mac.png
######
step 5. (arch USB) get connected
######
# we need to be connected to the internet to install arch.
# newer macbooks ditched ethernet ports, so unless you have a dongle,
# we need to connect to wifi.
wifi-menu
# give it about ~2 mins. check it if works
ping -c 3 google.com
######
step 6. (arch USB) create partitions
######
# we have to split our linux partition further for arch.
# look for your new partition.
cgdisk /dev/sda
# to distinguish it from your macOS partition, it's the one that IS NOT
# called 'Untitled'. Your macOS partition is usually /dev/sda2.
# once you know you have the right partition selected, delete it. it should
# now just be free space.
# create the following partitions from the free space:
(size, name, hex)
- 128m, linux boot loader, 8300
- 8g, swap, 8200
- 256m, boot, 8300
- 40g, root, 8300
- 12g, var, 8300
- the rest, home, 8300
# once you're done, hit 'write'.
######
step 7. (arch USB) - format partitions
######
run `fdisk -l` to know each disk number (/dev/sdX).
# for boot:
mkfs.ext2 /dev/sdX
# for the rest (root, var, home):
mkfs.ex4 /dev/sdX
# for swap:
mkswap /dev/sdX
swapon /dev/sdX
######
step 8. (arch USB) - mount filesystems
######
# first, mount the root partition:
mount /dev/sdX /mnt
# mount the rest (order matters):
mkdir /mnt/boot && mount /dev/sdX /mnt/boot
mkdir /mnt/var && mount /dev/sdX /mnt/var
mkdir /mnt/home && mount /dev/sdX /mnt/home
######
step 9. (arch USB) - install arch and extra packages needed
######
# install arch & extras (vim and zsh not necessary):
pacstrap /mnt base base-devel zsh vim git efibootmgr dialog wpa_supplicant
# set fstab to record filesystem settings:
genfstab -p /mnt >> /mnt/etc/dstab
#######
step 10. (arch USB) - set initial arch configs
#######
# chroot into the new system:
arch-chroot /mnt /bin/bash
# set hostname
echo MYHOSTNAME > /etc/hostname
# set timezone
ln -sf /usr/share/zoneinfo/REGION/CITY /etc/localtime
# set hardware clock
hwclock --systohc --utc
# update locale
echo LANG=en_US.UTF-8 >> /etc/locale.conf
echo LANGUAGE=en_US >> /etc/locale.conf
echo LC_ALL=C >> /etc/locale.conf
# set root password
passwd
# add yourself as a user
# if you don't want zsh, remove the -s flag
# and change /bin/zsh to /bin/bash
useradd -m -g users -G wheel -s /bin/zsh MYUSERNAME
passwd MYUSERNAME
# allow users to execute commands as sudo
visudo
# uncomment the `wheel` line
# add the locale
# en_US.UTF-8 is uncommented by default
# if you need another locale, you can uncomment the
# one you want- `sudo vi /etc/locale.gen`
# otherwise, you can just generate the locale
locale-gen
# export locale settings
echo LANG=en_US.UTF8 > /etc/locale.conf
export LANG=en_US.UTF-8
# generate initrd
mkinitcpio -p linux
#######
step 11. (arch USB) - finishing off
#######
# exit the new system
exit
# unmount all partitions
umount -R /mnt
swapoff -a
# reboot into the new system
reboot
# after reboot, you should be brought to the rEFInd menu
#######
step 12. (arch) - last configurations
#######
# login as root
# edit modules
vi /etc/mkinitcpio.conf
# add ata_piix to the MODULES line
# save and reboot
###########################
completing the installation
###########################
After reboot, you should be brought to rEFInd. On selecting
the Linux penguin, you should be brought to GRUB. Select
the first option, and Arch Linux should start up properly.
#####################
further configuration
#####################
this next section installs KDE Plasma and i3-gaps
window manager.
# install plasma
sudo pacman -S plasma
# hit enter to install all default packages
# install SDDM, plasma recommended desktop manager
sudo pacman -S sddm
# add sddm to system startup
sudo systemctl enable sddm
# install i3 package group
sudo pacman -S i3-gaps
@daltonpearson
Copy link

When do I install grub?

@gretzky
Copy link
Author

gretzky commented Apr 21, 2021

@daltonpearson sorry for the extremely late reply. rEFInd is a bootloader, you can swap it out for grub if you'd like

@kd-sf-94107
Copy link

Your instructions say

"After reboot, you should be brought to rEFInd. On selecting
the Linux penguin, you should be brought to GRUB. Select
the first option, and Arch Linux should start up properly."

That would seem to suggest that both grub and rEFInd are needed, however, you did not say to install grub in your instructions and your answer to the previous question suggests that only one of them is required. Could you please clarify this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment