Mac: Difference between revisions

From ArchWiki
(remove t2mac from warning, since most of the hardware is supported now, see https://wiki.t2linux.org/state/)
(→‎GRUB: Remove duplicated content from the Mac#Setup boot loader section)
 
(217 intermediate revisions by 16 users not shown)
Line 3: Line 3:
[[ja:Mac]]
[[ja:Mac]]
[[zh-hans:Mac]]
[[zh-hans:Mac]]
{{Style}}
{{Out of date|Mentions [[AIF]] ({{ic|/arch/setup}}).}}
{{Related articles start}}
{{Related articles start}}
{{Related|Installation guide}}
{{Related|Mac/Troubleshooting}}
{{Related|General recommendations}}
{{Related|Laptop/Apple}}
{{Related|MacBook5,2 (early-mid 2009)}}
{{Related|MacBookPro7,1}}
{{Related|MacBookPro8,1/8,2/8,3 (2011)}}
{{Related|MacBookPro9,2 (Mid-2012)}}
{{Related|MacBookPro10,x}}
{{Related|MacBookPro11,x}}
{{Related|iMac Aluminum}}
{{Related|iMac (21.5-inch, Mid 2010)}}
{{Related|Apple Fusion Drive}}
{{Related|Apple Fusion Drive}}
{{Related articles end}}
{{Related articles end}}
 
This page complements the [[Installation guide]] with instructions specific to Apple Macs. The Arch installation image supports Apple Macs with Intel processors, but neither PowerPC nor Apple Silicon processors.
{{Warning|ARM architectures are supported by [https://archlinuxarm.org/ Arch Linux ARM]. However, it doesn't support M1 or future generation chip yet. For Linux support information for Mac with M1 chip, see [https://asahilinux.org Asahi Linux] project. Both Arch Linux ARM and Asahi Linux are downstream projects that not officially endorsed by Arch Linux, you may go to [https://archlinuxarm.org/forum Arch Linux ARM Forum] and [https://asahilinux.org/community Asahi Linux Community] for help.}}
 
Installing Arch Linux on a MacBook (12"/Air/Pro) or an iMac is quite similar to installing it on any other computer. However, due to the specific hardware configuration of a Mac, there are a few deviations and special considerations which warrant a separate guide. For more background information, please see the [[Installation guide]] and [[UEFI]]. This guide contains installation-instructions that can be used on any Apple computer whose hardware is supported by the Linux kernel. Please see 'related' pages (on the top right of this page) for model-specific tips and troubleshooting.


== Overview ==
== Overview ==


Specifically, the procedure for installing Arch Linux on a MacBook is:
Summed up, the procedure for installing Arch Linux on a Mac is:


# '''[[#Firmware updates|Firmware updates]]''': It always helps to start from a clean, backed up, and up-to-date install of OS X.
# '''[[#Pre-installation|Pre-installation]]''': Miscellaneous steps before partitioning.
# '''[[#Partitions|Partition]]''': Resizing or deleting the OS X partition to create partitions for Arch Linux.
# '''[[#Partitions|Partitions]]''': Resizing or deleting the macOS partition to create partitions for Arch Linux.
# '''[[#Installation|Installation]]''': Actual installation.
# '''[[#Setup boot loader|Setup boot loader]]''': Making sure that the new partition is bootable.
# '''[[#Setup boot loader|Setup boot loader]]''': Making sure that the new partition is bootable.
# '''[[#Installation|Install Arch Linux]]''': Actually installing Arch Linux.
# '''[[/Troubleshooting|Post-installation]]''': Device-specific configuration.
# '''[[#Post-installation|Post-installation]]''': MacBook-specific configuration.


== Firmware updates ==
== Pre-installation ==


Before proceeding with the installation of Arch Linux, it is important to ensure that the latest firmware updates for your MacBook are installed. This procedure requires OS X.
Before proceeding with the installation of Arch Linux, follow these steps.
In OS X, open the App Store and check for updates. If your mac finds and installs any updates, make sure to '''reboot''' your computer, and then check again for updates to make sure that you installed everything.


{{Note|If you uninstalled OS X or want to reinstall it, [https://support.apple.com/en-us/HT204904 Apple] has great instructions.}}
# Install macOS and install its updates. macOS is the only known method for installing firmware updates, even though the OS will not be necessary after installing Arch. See Apple's [https://support.apple.com/en-us/HT204904 instructions].
# Open ColorSync Utility, find the current {{ic|.icc}} color profile, and save the file elsewhere. The profile can later be used to set the display colors correctly. See [[#Color Profile|color profile]].
# Set the volume on macOS, which will be the volume of the startup chime. If the volume is muted, the startup chime will also be muted. See [[#Mute startup chime|mute startup chime]].


It is advisable to keep OS X installed, because MacBook firmware updates can only be installed using OS X. However, if you plan to remove OS X completely, make backups of these files, which you will need in Linux for adjusting the [[#Color Profile|color profile]]:
== Partitions ==
/Library/ColorSync/Profiles/Displays/*


Continue to [[#Partitions]]
If only Arch Linux is desired, then format the entire disk according to [[Installation guide#Partition the disks]]. To set up dual boot, follow these steps. Once done, go to [[#Installation]].


== Partitions ==
=== Arch Linux with macOS or other operating systems ===


Partitioning of the storage drive is no different from any other PC or laptop. However, if you plan on keeping OS X for dual booting, you should consider that, by default, a MacBook's drive is formatted using GPT and contains at least 3 partitions:
Macs typically have the following partition table. In Macs that use the [[Apple Fusion Drive]], the partition scheme could be different.


* '''EFI''': the ~200 MB [[EFI system partition]].
* '''EFI''': the ~200 MB [[EFI system partition]].
* '''OS X''': the main partition containing your OS X installation. It is formatted using [[File_systems|HFS+]].
* '''macOS''': the main partition containing your macOS installation, either [[File systems|HFS+]] or APFS.
* '''Recovery''': A recovery partition present in almost all MacBooks running OS X 10.7 or newer. It is usually hidden from OS X but can be viewed with partitioning tools.
* '''Recovery''': If not using APFS, a recovery partition is present. If using APFS, this partition is not present.
 
{{Note|In Macs that use the [[Apple Fusion Drive]], the partition scheme could be different.}}
 
How to partition depends on how many operating systems you want install. The following options will be explained:
 
* Single boot: [[#Arch Linux only]]
* Dual boot: [[#Arch Linux with OS X or other operating systems]] ''(recommended so you can still return to OS X when needed)''
* Triple boot: [[#OS X, Windows XP, and Arch Linux triple boot]]
 
=== Arch Linux only ===
 
This situation is the easiest to deal with. Partitioning is the same as any other hardware that Arch Linux can be installed on. Please refer to the standard [[Installation guide]] for details.
 
{{Note|It is advisable to '''disable''' the MacBook startup sound before proceeding with partitioning. Just boot in OS X, mute your system sound and reboot again to the Arch Linux Installation media. Please keep in mind that the volume of the startup sound can only be modified reliably in OS X.}}
 
If you want to configure your system in order to have full-disk encryption, please look at the [[Dm-crypt/Encrypting an entire system]] page for details.
 
An example for a very basic partitioning, that does not consider a separate {{ic|/home}} partition nor encryption or LVM, is the following:
 
{{bc|
partition  mountpoint  size    type  label
/dev/sda1  /boot      200MiB  vfat  EFI
/dev/sda2  /swap      adjust  swap  swap
/dev/sda3  /          remain  ext4  root
}}
 
Once done, you can continue to [[#Installation]].
 
=== Arch Linux with OS X or other operating systems ===
 
You need to partition your hard drive while keeping the partitions used for OS X/Windows. If you wish to keep OS X, the easiest way is to use partitioning tools in OS X and then finish with Arch Linux tools.


{{Warning| If your OS X partition is encrypted with FileVault 2, you '''must''' disable the disk encryption before proceeding. After the OS X partition has been resized, FileVault 2 can be re-enabled.}}
To install Arch with macOS, keep these partitions, and follow these steps.


'''Procedure''':
# You may need to turn off FileVault before resizing the macOS partition. See Apple's [https://support.apple.com/guide/mac-help/turn-off-filevault-encryption-on-mac-mchlp2560/mac instructions].
* In OS X, run ''Disk Utility.app'' (located in {{ic|/Applications/Utilities}})
# Run Disk Utility, select the drive to be partitioned in the left-hand column, and click '''Partition.''' Do not create a container.
* Select the drive to be partitioned in the left-hand column (not the partitions!). Click on the '''Partition''' button.
# Add a new partition by pressing the '''+''' button and choose how much space you want to leave for macOS, and how much for the new partition. The new partition will be formatted in Arch Linux, so you can choose any partition type you want.  
* Add a new partition by pressing the '''+''' button and choose how much space you want to leave for OS X, and how much for the new partition. Keep in mind the new partition will be formatted in Arch Linux, so you can choose any partition type you want.  
# Optionally, make any other partitions you may need for your setup. See [[Partitioning#Partition scheme]] for more information.
* If the above completed successfully, then you can continue. If not, then you may need to fix your partitions from within OS X first.
* Boot the Arch installation media or [[USB flash installation media|LiveUSB]] by holding down the {{ic|Alt}} '''during boot'''. Proceed with [[#Installation]].
 
It is possible to resize the newly created partition from within the Arch installation media, or delete it in order to proceed with the creation of other partitions (eg. swap).
 
{{Tip|Instead of cluttering your drive with different partition, it is possible to use a [[swapfile]] instead of a dedicated partition. Another solution can be setting up [[LVM]] in order to use the newly-created partition as a container. Please refer to the linked articles.}}
 
==== Option 1: EFI ====
 
* Run ''cgdisk''
 
* Delete the partition you made in ''Disk Utility.app'' and create the necessary partitions for Arch Linux. OS X likes to see a 128 MiB gap after partitions, so when you create the first partition after the last OS X-partition, type in '''+128M''' when cgdisk asks for the first sector for the partition. More information about Apple's partitioning policy can be read  [https://developer.apple.com/library/mac/technotes/tn2166/_index.html#//apple_ref/doc/uid/DTS10003927-CH1-SUBSECTION5 here]. A simple example (no LVM, crypto):
 
{{Note|
* The swap partition is optional on machines with 4GB of RAM or more. A '''[[swap file]]''' can be created later.
* The easiest dual-boot option is to install rEFInd from inside OS X, to its root directory (default for {{ic|install.sh}}). Following that, copy the driver folder from the installation tarball into the new rEFInd location, and uncomment the lines ''"scan_all_linux_kernels"'' and ''"also_scan_dirs"'' options in {{ic|refind.conf}}. Configuration of boot options can then be done from a {{ic|refind_linux.conf}} in Arch's {{ic|/boot}} directory.
* If you want to be able to boot GRUB from the Apple boot loader, you can create a small hfs+ partition (for convenience, use OS X to format it in ''Disk Utility.app'' afterwards). Follow the GRUB EFI install procedure, and mount your {{ic|/efi}} directory to the hfs+ partition you created. Finally, finish up again in OS X by blessing the partition. This will set GRUB as the default boot option (holding alt at startup goes to the mac boot options screen still. See https://mjg59.dreamwidth.org/7468.html).,
* OS X's EFI partition can be shared with Arch Linux, making the creation of an additional EFI partition dedicated to Arch completely optional.
}}


{{Note|For more information on partitioning, see [[Partitioning]]}}
Here is an example setup with five discrete partitions:


{{bc|
{{bc|
partition  mountpoint  size          type  label
partition  mountpoint  size          type  label
/dev/sda1  /efi        200MiB        vfat  EFI
/dev/sda1  /efi        200MiB        vfat  EFI
/dev/sda2  -          ?            hfs+  OS X
/dev/sda2  -          ?            hfs+  macOS
/dev/sda3  -          ?            hfs+  Recovery
/dev/sda3  -          ?            hfs+  Recovery
/dev/sda4  -          100MiB        hfs+  Boot Arch Linux from the Apple boot loader (optional)
/dev/sda4  -          100MiB        hfs+  Boot Arch Linux from the Apple boot loader (optional)
Line 125: Line 61:
}}
}}


Once done, you can continue to [[#Installation]].
{{Note|
* See [[#Installing a boot loader to a separate HFS+ partition]] for more information on booting Arch Linux from the Apple boot loader.
* An existing [[EFI system partition]] can be used by Arch Linux without needing to create an additional one.
}}


==== Option 2: BIOS-compatibility ====
== Installation ==


* Run ''parted'' as root.
These steps install Arch, assuming [[#Pre-installation]] and [[#Partitions]] are done.
* Delete the empty space partition and partition the space as you would for any other installation. Note that MBR is limited to 4 primary partitions (including the efi partition). That leaves 2 primary partitions for Arch. One strategy is to have a system and home partition, and use a swap file (I have not tried to use logical partitions). Another is to dedicate one partition to a shared partition (see below).
* Next, create new filesystems on those partitions which need them, especially the partition which will contain {{ic|/boot}}. If you are not sure how to do this using {{ic|mkfs.ext2}} (or whatever), run {{ic|/arch/setup}} and work through until you get to Prepare Hard Drive and use the ''"Manually configure block devices..."'' option, then exit the installer. This is necessary so that rEFIt will set the right partition type in the MBR in the next step (without an existing filesystem, it seems to ignore the partition type set by parted), without which GRUB will refuse to install to the right partition.
* At this point you should reboot your computer and have rEFIt fix the partition tables on your hard drive.  (If you do not do this, you may have to reinstall GRUB later on in order to have your Mac recognize the Linux partition.)  When you are into the rEFIt menu, select '''update partition table''', then press {{ic|y}}. Reboot.
* Done, you can continue with [[#Installation]].


=== OS X, Windows XP, and Arch Linux triple boot ===
# [[Installation guide#Boot the live environment|Boot the live environment]] by holding down {{ic|Alt}} ({{ic|Option}} on an Apple keyboard) during boot.
# If the keyboard has long delays or character doubling, reboot with the following [[kernel parameters]]: {{ic|1=arch noapic irqpoll acpi=force}}.
# Proceed through the installation as described in the [[Installation guide]] '''except''' in the following areas:
## Skip the [[Installation guide#Partition the disks|partition the disks]] stage, do only the [[Installation guide#Format the partitions|partition formatting]] and [[Installation guide#Mount the file systems|mounting]] steps, taking care to assign the correct partitions. Partitions have already been created if you followed [[#Partitions]]
## When at the [[Installation guide#Boot loader|install boot loader]] stage, follow [[#Setup boot loader]]
## '''(for booting with BIOS-compatibility)''' Add {{ic|1=reboot=pci}} as a [[kernel parameter]]. This will allow your Mac to reboot correctly from Arch.
# When the install process is complete, reboot your computer.
# During boot, if using optical disk, hold down the eject key to eject the disk.
# During boot, if using systemd-boot or GRUB, hold down the {{ic|Alt}} key to bring up the Apple boot menu, and select "EFI Boot." If using rEFInd, boot without holding any keys.


This may not work for everyone but it has been successfully tested on a MacBook from late 2009.
== Setup boot loader ==


The easiest way to partition your hard drive, so that all these operating systems can co-exist, is to use disk utility in OS X, use the formatter on windows XP, install XP and then finish with Arch Linux tools.
Macs use [[UEFI]] for booting, so any UEFI [[boot loader]] will work. The built-in boot loader (shown when holding {{ic|Alt}} during boot) will detect any [[EFI system partition]] that has a {{ic|/EFI/BOOT/BOOTX64.EFI}} file, showing it as a "EFI Boot" entry. Most UEFI boot loaders support installing directly to this location, making a dual boot setup easy.


{{Warning|It is highly recommended that this only be attempted after a clean install of OS X. Using these methods on a preexisting system may have undesired results. At least back your stuff up with timemachine or clonezilla before you begin.}}
The boot loader also has an alternate partition discovery method described in [[#Installing a boot loader to a separate HFS+ partition]] which is the method used for booting macOS, but can also be used for Linux.


'''Procedure''':
{{Tip|
* The UEFI firmware on a Mac can also be configured via [[efibootmgr]].
* To set a volume as the default boot entry using the Apple boot loader, hold down {{ic|Ctrl}} while selecting it.}}


* In OS X, run '''Disk Utility''' (located in {{ic|/Applications/Utilities}}).
=== Installing to the EFI system partition ===
* Select the drive to be partitioned in the left-hand column (not the partitions!). Click on the '''partition''' tab on the right.
* Select the volume to be resized in the '''volume scheme.'''
* Decide how much space you wish to have for your OS X partition, how much for XP, and how much for Arch Linux. Remember that a typical installation of OS X requires around 15-20 GiB, and XP about the same, depending on the number of software applications and files. Something like OS X 200Gb, XP 25Gb, Arch 25Gb should be fine.
* Put your decisions into action by pressing the + button and adding the new partitions, Label them as you like and make sure that your XP partition is the last one on the disk and is formatted for FAT32. It is probably best to have Arch formatted in HFS format as to not confuse you later, it will be reformatted anyway.


So in linux terms your partitions will be something like:
==== systemd-boot ====


:* sda (disk)
Follow the instructions at [[systemd-boot#Installing the UEFI boot manager]]. After installing, a copy of systemd-boot will be present at {{ic|/EFI/BOOT/BOOTX64.EFI}}.
:* sda1 (Mac boot partition - you cannot see this one in OS X)
:* sda2 (OS X install in HFS+)
:* sda3 (Arch install temporarly in HFS)
:* sda4 (XP install in FAT32)


* Finally, click '''apply'''. This will create a new partition out of the empty space.
==== rEFInd ====


{{Note|Using this method you may not be able to have a shared partition between OS X and Arch Linux, this is because the mac will only allow for 4 active partitions. You will however be able to mount a HFS partition in Arch for one workaround. There are other workarounds possible also.}}
To install [[rEFInd]] to the {{ic|/EFI/BOOT/BOOTX64.EFI}} location, run:


* If the above completed successfully, you can continue. If not, then you may need to fix your partitions from within OS X first.
# refind-install --usedefault /dev/sd''XY''
* You will not be needing boot camp this way, the program rEFIt is much more flexible (though not as flexible as GRUB). Download and install rEFIt [http://refit.sourceforge.net/]
* Go into a terminal in OS X and perform the following, this will enable the rEFIt boot manager.


# cd /efi/refit
Where {{ic|/dev/sd''XY''}} is the EFI system partition. After installing, see [[rEFInd#Configuration]] to finish setup.
# ./enable.sh


* Reboot to check the rEFIt is working, it should appear on boot. When it comes up go to the rEFIt partition manager and agree to the changes.
===== Installing from macOS =====


* Put your XP install CD and boot it with rEFIt - You may have to reboot a few times until it is recognized by the boot loader. Install XP and once it is installed use the OS X installation CD to get your drivers running nicely in XP.
These steps assume macOS is still installed on a partition, and the steps of the [[Installation guide]] were completed up to [[Installation guide#Boot loader]]. Boot into Safe Mode by holding down {{ic|Command+R}}, then disable SIP.
** Note: when installing XP make sure you select your XP partition and format it again inside the XP installer. If you do not reformat it will not work.


* Boot the Arch install CD, log in as root and run {{ic|# /arch/setup}}.
# csrutil disable


* Follow the install as normal but note that you will have to tell that arch installer to mount sda3 as the root partition and format it as ext3, there will not be a /boot or swap partition so ignore those warnings.
Boot macOS, and run the rEFInd install script,


* At this point, if you are dual booting, you should reboot your computer and have rEFIt fix the partition tables on your hard drive. (If you do not do this, you may have to reinstall GRUB later on in order to have your Mac recognize the Linux partition.)  When you are into the rEFIt menu, select '''update partition table''', then press Y.
  # ./refind-install --alldrivers
# reboot


* Done! You can continue to [[#Installation]].
rEFInd installed itself into Apple's boot partition, and replaced Apple's boot menu with its own. Boot into Safe Mode by holding down {{ic|Command+R}}, and enable SIP.


== Setup boot loader ==
# csrutil enable


=== Using the native Apple boot loader with systemd-boot (Recommended) ===
Reboot without holding down any keys. Arch should be recognized as {{ic|vmlinuz-linux}} by default. If it is not, uncomment the lines {{ic|scan_all_linux_kernels}} and {{ic|also_scan_dirs}} in {{ic|refind.conf}}. For configuration, see [[rEFInd#refind_linux.conf]]. Since rEFInd by default mounts root as ro, it is recommended to create refind-linux.conf.


Apple's native EFI boot loader reads {{ic|.efi}} files located inside the [[EFI system partition]] at {{ic|/EFI/BOOT/BOOTX64.EFI}}. Luckily, this is also the default install location for the [[systemd-boot]] binary. This means that booting linux using ''systemd-boot'' is very simple.
==== GRUB ====
* First, make sure you mounted the EFI System Partition at {{ic|/boot}}
* Proceed with [[#Installation]] normally
* Once inside the chrooted enviroment, type the following command to install ''systemd-boot'':
{{bc|1=# bootctl --path=/boot install}}
The above command will copy the ''systemd-boot'' binary to {{ic|/boot/EFI/BOOT/BOOTX64.EFI}} and add ''systemd-boot'' itself as the default EFI application (default boot entry) loaded by the EFI Boot Manager.
* Proceed to [[systemd-boot#Configuration]] in order to correctly set up the boot loader
At the next reboot, the Apple Boot Manager, shown when holding down the option key when booting the MacBook, should display Arch Linux (it will be displayed as {{ic|EFI Boot}} as a possible boot option.
{{Tip|If you installed Arch Linux alongside OS X, you will be able to change the default boot location from  system Settings inside OS X. If Arch Linux does not show up as a possible boot option, you will have to mount the EFI System Partition inside OS X before selecting your boot option:
{{bc|$ diskutil mount disk0s1}}
}}


=== Using the native Apple boot loader with GRUB ===
To install GRUB to {{ic|/EFI/BOOT/BOOTX64.EFI}}, follow the instructions at [[GRUB#Installation]], adding the {{ic|--removable}} option when running {{ic|grub-install}}.


{{Style|Uses [[partial upgrade]] procedure and explicitly lists many basic commands.}}
=== Installing a boot loader to a separate HFS+ partition ===


Despite using UEFI, the MacBook's native EFI boot loader [http://refit.sourceforge.net/myths/ does not use the EFI partition for booting]. Instead, it looks for .efi files inside all the partitions in internal and external drives and shows them as possible boot options if certain conditions are satisfied. For example, MacBooks can detect an existing OSX installation after checking that:
Despite using UEFI, the Mac native EFI boot loader [https://refit.sourceforge.net/myths/ does not use the EFI system partition for booting macOS]. Instead, it uses the [https://mjg59.dreamwidth.org/7468.html following conditions] to find existing macOS installations inside all the partitions in internal and external drives and shows them as possible boot options if they are satisfied:
* there is a partition formatted as HFS+
* the partition contains the partition id {{ic|af00}}
* in the root of that partition, there is a file called {{ic|mach_kernel}}
* inside that partition, there a {{ic|boot.efi}} file inside {{ic|/System/Library/CoreServices}}


This means that configuring an Arch installation to be automatically recognized by the MacBook boot loader is possible. Moreover, it simply requires a properly-formatted HFS+ {{ic|/boot}} partition and does not require meddling with the EFI system partition. The advantage of this method is that it can coexist with OS X nicely and allows to avoid other boot loaders such as rEFInd. However, this requires manual configuration. The following steps will illustrate how to perform this configuration using GRUB.
* The partition is formatted as HFS+
* First, while configuring a new Arch installation, create a separate {{ic|/boot}} partition. Many tools are available in the Arch ISO, for example '''cgdisk'''.
* The partition type ID is {{ic|af00}} ("Apple HFS/HFS+")
* Make sure the partition is at least ~250 MB in size, since it will be used to store the kernel as well as any custom kernel you will install in the future. Moreover, make sure the partition type is set as Apple HFS/HFS+ (it will appear as {{ic|Apple HFS/HFS+}} in fdisk/cgdisk or {{ic|af00}} in gdisk)
* In the root of the partition, there is a file called {{ic|mach_kernel}}
* Since the Arch installation ISO does not include the {{AUR|hfsprogs}} package, we need to install it in the installation environment before proceeding with formatting the new partition as HFS+, install {{Aur|hfsprogs}}, then:
* Inside that partition, there a {{ic|boot.efi}} file inside {{ic|/System/Library/CoreServices}}


# modprobe hfsplus
The advantage of this method to boot Arch over using a {{ic|BOOTX64.EFI}} file in the EFI system partition is that it can coexist with macOS nicely, showing the partition as a bootable volume in the macOS Startup Disk settings. However, this method requires manual configuration. The following steps will illustrate how to perform this configuration using GRUB.
# mkfs.hfsplus /dev/sd'''Xp''' -v "Arch Linux"


Note: replace {{ic|/dev/sd'''Xp'''}} with the appropriate device and '''p'''artition number.
First, create a new HFS+ partition. This can be done through the macOS Disk Utility, or the {{ic|mkfs.hfsplus}} tool in the {{AUR|hfsprogs}} package. The size and mount point of the partition depend on how you plan to use it:


* Done, proceed with [[#Installation]]
* If you plan on using it as the [[Partitioning#/boot|/boot]] directory, give it at least 300 MB;
* If you are going to keep your kernels in another partition and use a boot loader that can load other file systems, like rEFInd or GRUB, the partition can be smaller and be mounted anywhere you want.


{{Warning|Once inside the chrooted enviroment, do not forget to install the {{AUR|hfsprogs}} package on the newly installed system as well. After the installation of the package, [[regenerate the initramfs]] while chrooted.}}
[[Mount]] the partition, then create the {{ic|mach_kernel}} file:


* Once inside the chrooted enviroment, install the {{Pkg|grub}} and {{Pkg|efibootmgr}} packages.
# touch /''mountpoint''/mach_kernel
* Also, create a dummy {{ic|mach_kernel}} file


# touch /boot/mach_kernel
Create the directory structure for the boot loader:
# mkdir -p /boot/EFI/arch && touch /boot/EFI/arch/mach_kernel


* The following steps install the GRUB UEFI application to {{ic|/boot/EFI/arch/System/Library/CoreServices/boot.efi}} and install its modules to {{ic|/boot/grub/x86_64-efi}}.
# mkdir -p /''mountpoint''/System/Library/CoreServices


# grub-install --target=x86_64-efi --efi-directory=/boot
Now you can install any UEFI boot loader you want. For example, to do a manual install of rEFInd:


After that, remember to create a standard configuration file:
{{bc|
# cp -r /usr/share/refind/* /''mountpoint''/System/Library/CoreServices/
# mv /''mountpoint''/System/Library/CoreServices/refind_x64.efi /''mountpoint''/System/Library/CoreServices/boot.efi
}}


# grub-mkconfig -o /boot/grub/grub.cfg
Finally, you can [[create]] an optional {{ic|/''mountpoint''/System/Library/CoreServices/SystemVersion.plist}} file that will display some information about the volume in the macOS Startup Disk settings:


As you can see, the directory structure of the {{ic|boot.efi}} is not correct, as the {{ic|/System/Library/CoreServices}} directory is not supposed to be a subdirectory of the {{ic|/boot/EFI/}} folder. For this reason, we need to relocate the {{ic|boot.efi}} stub in a location the MacBook boot loader is able to recognize:
{{hc|/''mountpoint''/System/Library/CoreServices/SystemVersion.plist|2=
 
# mv /boot/EFI/arch/System/ /boot/
# rm -r /boot/EFI/
 
After that, you need to create the following file
 
{{hc|/boot/System/Library/CoreServices/SystemVersion.plist|2=
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<plist version="1.0">
<dict>
<dict>
       <key>ProductBuildVersion</key>
       <key>ProductBuildVersion</key>
      <string>rolling</string>
      <key>ProductName</key>
      <string>Arch Linux</string>
      <key>ProductUserVisibleVersion</key>
       <string></string>
       <string></string>
      <key>ProductName</key>
      <string>Linux</string>
       <key>ProductVersion</key>
       <key>ProductVersion</key>
       <string>Arch Linux</string>
       <string></string>
</dict>
</dict>
</plist>
</plist>
}}
}}


At the next reboot, the Apple Boot Manager, shown when holding down the option key when booting the MacBook, should display Arch Linux as a possible boot option. Selecting that option will boot GRUB.
After following these instructions, the new volume will appear on the Mac boot loader when holding down {{ic|Alt}} during boot, and it will also appear as a bootable volume in the macOS Startup Disk options.
 
Done! GRUB can now be selected on the standard MacBook boot loader and you can boot into your newly installed Arch Linux.
 
{{Tip| After the installation, it is optionally possible to set a custom icon that will be displayed in the MacBook boot loader. In order to do that, you need to install the {{Pkg|wget}}, {{Pkg|librsvg}} and {{Pkg|libicns}} packages. After that, just follow the following commands:
 
$ wget -O /tmp/archlinux.svg https://archlinux.org/logos/archlinux-icon-crystal-64.svg
$ rsvg-convert -w 128 -h 128 -o /tmp/archlogo.png /tmp/archlinux.svg
# png2icns /boot/.VolumeIcon.icns /tmp/archlogo.png
$ rm /tmp/archlogo.png
$ rm /tmp/archlinux.svg
Obviously, you can replace the Arch logo with any other icon you like.
}}
 
=== Other methods ===
 
{{Out of date | Section that describes boot loader setup for other setups should be revised and re-structured into more readable way}}
 
{{Tip|rEFIt is a popular boot loader for EFI-firmware computers (including Macs). It can be installed at any time during the installation. For instructions, please see [[#rEFIt]]. }}
 
If you are going for an Arch Linux-only setup, installing the boot loader is no different than on any other machine: Install [[systemd-boot]], [[rEFInd]] or other boot loader of your choice.
 
If, on the other hand, you are dual/triple booting, then read on.
 
=== Installing GRUB to EFI system partition directly ===
 
* If you would like to use GRUB as your main boot loader and use the "boot while holding the Alt/Option key" method to go back to OS X rather than using alternatives such as rEFIt (http://refit.sourceforge.net/, mentioned previously in [[#Option 2: BIOS-compatibility]] and [[#OS X, Windows XP, and Arch Linux triple boot]]) then you must install {{Pkg|grub}} to your Mac's '''already-existing''' EFI partition (see below).
 
{{Note|
* These instructions are known to work on a MacBook Pro (Early 2011). Please read the procedure carefully '''as well as the details following it'''.
* With a new MacBook Pro (Mid 2014), this procedure worked only after installing the
{{Pkg|efibootmgr}} package.
}}
 
'''Procedure''':
 
* Install {{Pkg|grub}}
* Make a directory named {{ic|efi}} in {{ic|/boot}}
* Mount the '''already-existing''' EFI partition on your Mac to this {{ic|/efi}} directory
* Install GRUB to this directory
* Make a directory named {{ic| locale}} in {{ic| /boot/grub}}
* Copy {{ic|grub.mo}} from {{ic|/usr/share/locale/en@quot/LC_MESSAGES/}} to {{ic|/boot/grub/locale/}}
* Generate a configuration for GRUB
* Done! GRUB will now start on reboot and you can boot into your newly installed Arch Linux.
* Remember to hold {{ic|Alt}}/{{ic|Option}} key '''while''' starting your computer if you want to boot back into OS X.
 
'''Details''' (quoted from [[GRUB EFI Examples#M5A97]]):
 
Finish the standard Arch install procedures, making sure that you install {{Pkg|grub}} and partition your boot hard disk as GPT.
 
From [[GRUB#UEFI systems]]:
 
The UEFI system partition will need to be mounted at {{ic|/efi}} for the GRUB install script to detect it:
 
# mkdir /efi
# mount -t vfat /dev/sdXY /efi
 
Where X is your boot hard disk and Y is the efi partition you created earlier.
 
Install GRUB UEFI application to  and its modules to {{ic|/boot/grub/x86_64-efi}} using:
 
# modprobe dm-mod
# grub-install --target=x86_64-efi --efi-directory=/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
 
Generate a configuration for GRUB
 
# grub-mkconfig -o /boot/grub/grub.cfg


=== Using blessing ===
=== Using blessing ===


It is possible to boot directly from GRUB in EFI mode without using rEFIt through what is known as "blessing" after placing GRUB on a '''separate partition'''.  These instructions are known to work on a MacBook7,1. It is advisable to host GRUB on either a FAT32 or HFS+ partition, but ext2 or ext3 may also work. GRUB's appleloader command does not currently work with the 7,1, but support can be added with the patch available [https://savannah.gnu.org/bugs/index.php?33185 here].
It is possible to boot directly from GRUB in EFI mode without using rEFIt through what is known as "blessing" after placing GRUB on a '''separate partition'''.  These instructions are known to work on a MacBook7,1. It is advisable to host GRUB on either a FAT32 or HFS+ partition, but ext2 or ext3 may also work.


After the GRUB install is in the desired location, the firmware needs to be instructed to boot from that location.  This can be done from either an existing OS X install or an OS X install disk.  The following command assumes that the GRUB install is in {{ic|/efi/grub/}} on an existing OS X partition:
After the GRUB install is in the desired location, the firmware needs to be instructed to boot from that location.  This can be done from either an existing macOS install or an macOS install disk.  The following command assumes that the GRUB install is in {{ic|/efi/grub/}} on an existing macOS partition:


  # bless --folder /efi/grub --file /efi/grub/grub.efi
  # bless --folder /efi/grub --file /efi/grub/grub.efi


=== Compilation ===
== Tips and tricks ==


Some models may need EFI_ARCH set to i386.
=== Color Profile ===
 
$ bzr branch --revision -2 bzr://bzr.savannah.gnu.org/grub/trunk/grub grub
$ cd grub
$ ./autogen.sh
$ patch -p1 < appleloader_macbook_7_1.patch
$ export EFI_ARCH=x86_64
$ ./configure --with-platform=efi --target=${EFI_ARCH} --program-prefix=""
$ make
$ cd grub-core
$ ../grub-mkimage -O ${EFI_ARCH}-efi -d . -o grub.efi -p "" part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot configfile linux multiboot
$ cp grub.efi *.mod *.lst ''yourinstalllocation''
 
== Installation ==
 
{{Note|This section is only required if you want to have OS X installed along with Arch Linux. If not, follow the steps in the official install guide, then skip to [[#Post-installation]].}}
 
* Boot from the Arch Linux install CD, or from a [[USB flash installation media#Using manual formatting|manually created]] bootable USB drive.
 
{{Note|
* On a MacBookPro7,1, I had an error booting the installation media Version 2012.12.01: "unable to handle kernel NULL pointer dereference at 0000000000000010" during pacpi_set_dmamode. To fix this problem, boot with the option: {{ic|1=acpi=off}}. After chrooting, add {{ic|1=MODULES=(ata_generic)}} to {{ic|/etc/mkinitcpio.conf}} and [[regenerate the initramfs]], see [[Installation guide#Configure the system]].
* Some MacBook users report strange keyboard output such as long delays and character doubling. To fix this problem, boot with the following options: {{ic|1=arch noapic irqpoll acpi=force}}.
}}
 
* Proceed through the installation as described in the [[Installation guide]] '''except''' in the following areas:
** Skip the [[Installation guide#Partition the disks|partition the disks]] stage, do only the [[Installation guide#Format the partitions|partition formatting]] and [[Installation guide#Mount_the_file_systems|mounting]] steps, taking care to assign the correct partitions. Partitions have already been created if you followed [[#Partitions]]
** When at the [[Installation guide#Boot loader|install boot loader]] stage, follow [[#Setup boot loader]]
** '''(for booting with BIOS-compatibility)''' Edit the menu.lst file of Grub and add '''reboot=pci''' to the end of the '''kernel''' lines, for example: {{bc|1=kernel /vmlinuz-linux root=/dev/sda5 ro reboot=pci}} This will allow your MacBook to reboot correctly from Arch.
** In the [[Installation guide#Configure the system|configure system]] stage, edit /etc/mkinitcpio.conf and ensure the '''keyboard''' hook is in the '''HOOKS''' line somewhere after the '''autodetect''' hook.  This will load the drivers for your keyboard in case you need to use it before Arch boots (e.g. entering a [[LUKS]] password or using the troubleshooting shell).
* When the install process is complete, reboot your computer.
* If using optical media, hold down the eject key as your MacBook starts, this should eject the Arch Linux install disk.
* If dual-booting OS X and Arch Linux, hold down the alt (option) key while the system boots to use the Mac boot loader to select which OS to boot.
 
== Post-installation ==
 
{{Style|Duplicated information, does not comply with [[Help:Style]].}}
 
See [[General recommendations]] for system management directions and post-installation tutorials like setting up a graphical user interface, sound or a touchpad.
 
=== Video ===
 
Different MacBook models have different graphic cards.
To see which graphics card you have type:
 
$ lspci | grep VGA
 
* If it returns a string containing {{ic|Intel}}, read [[Intel graphics]].
* If it returns {{ic|NVIDIA}}, read [[NVIDIA]].
* If it returns two lines, with both {{ic|NVIDIA}} and {{ic|Intel}}, your mac has dual graphics. See [[MacBookPro10,x#Graphics]] for an example of one such setup that might apply in other cases.
 
{{Warning|Despite lots of confusion in online forums, the dual graphics on MacBooks are [https://arstechnica.com/gadgets/2010/04/inside-apples-automatic-gpu-switching/ not] [[Optimus]]-based, and treating them as such will break your graphics. See instead [[MacBookPro10,x#Switching to/from GPUs with gpu-switch]] or your laptop's specific article for instructions on setting up graphics switching.}}
 
* Otherwise if it returns {{ic|ATI}} or {{ic|AMD}}, read [[ATI]].
 
==== NVIDIA note ====
 
{{Tip|If you have installed OS in EFI mode and NVIDIA binary drivers are working only in BIOS mode (e.g. you get black screen on EFI boot), try this approach: https://askubuntu.com/a/613573 }}
 
For MacBooks with NVIDIA graphics, for the backlight to work properly you may need the {{AUR|nvidia-bl-dkms}} package.
 
{{Tip|
* If backlight control does not work after installing nvidia-bl, you should [[blacklist]] apple_bl kernel module.
* If backlight control does not work even this way, try setting module parameters. Uncommenting {{ic|1=options nvidia_bl max_level=0x1ffff shift=11}} in {{ic|/etc/modprobe.d/nvidia_bl.conf}} should do the trick.
* Alternatively, you can choose to use the {{AUR|pommed-light}} package. If you do so, you may wish to change the step settings in {{ic|/etc/pommed.conf.mactel}} to something around 5000-10000 depending on how many levels of brightness you desire.  The max brightness is around 80000, so take that into account.
}}
 
==== iMac 2020 (with AMDGPU and 5k retina resolution) ====
 
It seems amdgpu driver has problems to set the native 5k resolution. If the display gets corrupted during boot when amdgpu driver module is loaded, try forcing a lower resolution. Add e.g. {{ic|1=video=2560x1440@60}} to your [[kernel parameters]].
 
=== Touchpad ===
 
The touchpad should have basic functionality by default. A true multitouch driver which behaves very similarly to native OS X is included in the {{AUR|xf86-input-mtrack-git}} package.  Configuration options are documented in the [https://github.com/p2rkw/xf86-input-mtrack readme].
 
The following mtrack options work well on a MacBook7,1:
 
  Option "Thumbsize" "50"
  Option "ScrollDistance" "100"
 
Probably, you also need to add:
 
  MatchDevicePath "/dev/input/event10"
 
To disable tap-to-click (that is, to press down to click) by default, add the following to your mtrack configuration section
 
    Option          "TapButton1" "0" 
    Option          "TapButton2" "0"
    Option          "TapButton3" "0"
 
'''Natural scrolling:''' To configure natural two finger scrolling similar to [https://support.apple.com/en-us/HT204895 OS X], refer to [[Touchpad Synaptics#Natural scrolling]].
 
If you are using {{AUR|xf86-input-mtrack-git}}, you can simply swap the scroll up and scroll down buttons (along with the scroll left and scroll right):
 
{{hc|/etc/X11/xorg.conf.d/10-mtrack.conf|
  ...
  Option "ScrollUpButton" "5"
  Option "ScrollDownButton" "4"
  Option "ScrollLeftButton" "7"
  Option "ScrollRightButton" "6"
  ...}}
 
'''Special Note About Older Macbook Models (confirmed on MacBook2,1):''' On older Macbook models (pre-multitouch), the touchpad will not function properly until you install the xf86-input-synaptics package. Please see [[Touchpad Synaptics]] for more information on installing and configuring this package.
 
'''Note on MacBookPro5,5:''' I found it is much simpler to use the {{Pkg|xf86-input-synaptics}} in Extra. Although it does not have much function as 3 finger swipe, this driver provides faster response. {{AUR|gpointing-device-settings}} also provides a simple GUI config. Below is a Xorg config file /etc/X11/xorg.conf.d/60-synaptics.conf for reference only.
 
{{bc|1=
Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "SHMConfig" "on"
        Option "TapButton1" "1"
        Option "TapButton2" "3"
        Option "TapButton3" "2"
        Option "PalmDetect" "on"
        Option "VertEdgeScroll" "off"
        Option "HorizEdgeScroll" "off"
        Option "CornerCoasting" "off"
        Option "EdgeMotionUseAlways" "off"
        Option "AreaLeftEdge" "10"
        Option "AreaRightEdge" "1270"
EndSection
}}
 
'''For some users, the two-finger right-click may not work correctly and trackpad may also become less responsive after these settings. For me, removing the 'AreaLeftEdge' and 'AreaRightEdge', solved that problem.'''
'''OS X like MultiTouch Gestures''' ''currently broken due to newer synaptic drivers!'' For users looking to add more of OS X's multitouch gestures to Arch, [https://github.com/iberianpig/xSwipe xSwipe] is a highly customisable, light weight perl script, which does just that. Once installed and configured (see xSwipe wiki on Github) I would recommend adding xSwipe as a [[Autostarting|start up item]].
 
=== Keyboard ===
 
MacBook keyboards work by default. For swaping {{ic|Fn}} keys with {{ic|F''x''}} keys see [[Apple Keyboard]].
 
To enable it you can map with right application like '''xbindkeys''' or through DE preferences; but another very good way, that we recommend, is to install the {{AUR|pommed-light}} package.
 
Edit the {{ic|/etc/pommed.conf}} according to your hardware on MacBook, building it from {{ic|/etc/pommed.conf.mac}} or {{ic|/etc/pommed.conf.ppc}} example files.
 
Note that you can also run it without a configuration file, the defaults may work for you. Then [[enable]] and start {{ic|pommed.service}}.
 
{{Tip|if you are using Gnome or KDE you can easily configure ''3rd level functionality'', ''multimedia key'', etc. in Keyboard Preferences.}}
 
{{Note|See the [[Xorg input hotplugging]] page for other configuration information.}}
 
==== Keyboard backlight ====
 
The keyboard backlight is controlled by {{ic|/sys/class/leds/smc::kbd_backlight}}.  Write the desired value to {{ic|brightness}} in that directory.
 
Both {{Pkg|acpilight}} or {{AUR|kbdlight}} (stalled since 2015) allow to control keyboard backlight though scripts. With the appropriate udev rules or [[sxhkd]] they allow light-level changes without being root.
 
As of 2017-11-12, {{Pkg|acpilight}} provides a "just-works" solution tested on a MacbookPro 8,1.
 
Alternatively you might want to check out the [[Keyboard backlight]] wiki page.
 
'''Ensuring the keyboard backlight is on when entering the LUKS decryption password'''
 
This can be done via [[Mkinitcpio#HOOKS|initcpio hooks]]. First, create an executable install script in {{ic|/etc/initcpio/install/mac_kb_backlight}} with the follwing:
 
{{bc|
#!/usr/bin/env bash
 
build() {
  add_module applesmc
  add_runscript
}
}}
 
Next, create an executable hook in {{ic|/etc/initcpio/hooks/mac_kb_backlight}} with:
 
{{bc|
#!/usr/bin/env bash
 
run_hook() {
  if [ -f "/sys/class/leds/smc::kbd_backlight/brightness" ]; then
    echo 100 > "/sys/class/leds/smc::kbd_backlight/brightness"
  fi
}
}}
 
Finally, add this custom hook to the {{ic|HOOKS}} array in {{ic|/etc/mkinitcpio.conf}}, and ensure it is placed before the {{ic|encrypt}} hook:
 
HOOKS=(... mac_kb_backlight encrypt ...)
 
Remember to [[regenerate the initramfs]] images after these steps to include the custom script.
 
===== NVIDIA note =====
 
If the brightness does not function correctly through pommed, make sure you have installed the {{AUR|nvidia-bl-dkms}} package and insert
 
find . -name "*" -exec sed -i 's/mbp_backlight/nvidia_backlight/' '{}' \;
 
into the second line of the pommed PKGBUILD build() function and remake the package. From [https://bbs.archlinux.org/viewtopic.php?id=105091 this forum post].
 
Another possible solution is to modify the pommed PKGBUILD build():
 
find . -name "*" -exec sed -i 's/nvidia_backlight/apple_backlight/' '{}' \;
 
If the previous does not work try the following,
 
run nvidia-settings, edit  the file {{ic|/etc/X11/xorg.conf}} and add this line into the {{ic|Device}} section:


Option "RegistryDwords" "EnableBrightnessControl=1"
Macs use [[ICC profiles]] which can easily be loaded in Arch. The current profile can be shown using ColorSync Utility or System Preferences > Displays > Color. These files correspond to particular models,


Save and reboot and check backlight buttons work. More information available at [https://help.ubuntu.com/community/MacBookPro5-5/Precise#LCD Ubuntu MacBookPro5,5].
* {{ic|Color LCD-4271800.icc}} for MacBook Pro with CoreDuo CPU
 
* {{ic|Color LCD-4271880.icc}} for MacBook with Core2Duo
=== Wi-Fi ===
* {{ic|Color LCD-4271780.icc}} for MacBook (non-Pro) based on CoreDuo or Core2Duo.
 
* {{ic|Color LCD-68FE312B-5EF0-E0A1-BCD8-8890B73C7B3A.icc}} for [[MacBookPro9,2 (Mid-2012)]]
Different MacBook models have different wireless cards.
 
You can easily check what card do your MacBook have by:
 
# lspci | grep Network
 
* If you have an Atheros card, all should work out-of-the-box.
* If you have a Broadcom card, follow the [[Broadcom wireless]] page.
* 5.0 and 6.0 generation MacBooks may have a BCM43xx, follow the instructions for the broadcom-wl driver on the [[Broadcom wireless]] page. The interfaces can swap during reboot so its best to define them in a udev rule (instructions on the [[Broadcom wireless]] page).
* If you have the correct broadcom DKMS driver (i.e. broadcom-wl-dkms) installed and your wifi card is still not being recognised, try rebuilding the driver (See [[Dynamic Kernel Module Support]]).


{{Note|
{{Note|
* If your connection frequently drops, you may have to turn off Wi-Fi power management.
* The previous command sets the color profile only for the current session. [[autostart]] it.
* Eduroam or similar may crash your network manager. Simply delaying the connection after login should do the trick
* GNOME will revert the profile set by xcalib. It is preferable to set the profile using '''Color''' in settings.}}
}}
 
=== Power management ===
 
[[Powerdown]] is a very simple to set up set of scripts what will maximize your battery duration. A MacBook Air 2013 with powerdown provides about 11 hours of light usage with just powerdown installed.
All the usual [[power management]] recomendations apply as well.
 
==== Disabling Thunderbolt ====
 
Linux still has poor power management for Thunderbolt adapters on Macs. This can cause the TB adapter(s) to be always-on and prevent the CPU from going into the deepest power-saving states [https://bugzilla.kernel.org/show_bug.cgi?id=92111], drawing ca. 2W additional power even when not in use [https://github.com/Dunedan/mbp-2016-linux/issues/24#issuecomment-310952415]. An easy way to see the CPU states is using powertop. The problem arises when the CPU does not go below C3 as a package (Pkg%pc3).
 
One workaround is to add {{ic|1=acpi_osi=!Darwin}} to the [[kernel parameters]], thereby telling the firmware that the system is not compatible with macOS [https://www.kernel.org/doc/html/latest/firmware-guide/acpi/osi.html]. This should disable the TB adapter (at least on older Macs), and thus reduce power consumption greatly, but will probably come with side-effects (e.g. no Thunderbolt, maybe others?).
 
It is also possible to [[blacklist]] the thunderbolt module and then putting the controllers to sleep with
 
# echo auto > /sys/bus/pci/devices/0000:07:00.0/power/control
 
Check the correct device number with lspci. This can also be [[systemd#systemd-tmpfiles - temporary files|automated]]. This method reduces power consumption slightly, but still consumes 0.9 W more than the previous method on a Macbook Air 2013.
 
==== Suspend and hibernate ====
 
Suspending (suspend to ram) and hibernating (suspend to disk) work fine out of the box:
 
systemctl suspend
 
Issues were reported where the machine would "suspend immediately after resume" in certain conditions when suspending by closing the lid. This was solved by setting the option "sleep-inactive-ac-type" to "nothing" using dconf-editor, option path: org &rarr; gnome &rarr; settings-daemon &rarr; plugins &rarr; power).
 
See [[Suspend and hibernate]] for details on how to configure hibernation. Noticably, you will need a swap partition or file (see the mentioned article for further instructions).
 
If after suspend laptop is woken up after few seconds, may help to disable all stuff in /proc/acpi/wakeup, exclude LID0:
 
# echo XHC1 > /proc/acpi/wakeup
 
{{hc|$ cat /proc/acpi/wakeup|
Device S-state   Status  Sysfs node
P0P2   S3 *disabled
EC   S3 *disabled
HDEF   S3 *disabled  pci:0000:00:1b.0
RP01   S3 *disabled  pci:0000:00:1c.0
RP02   S3 *disabled  pci:0000:00:1c.1
RP03   S3 *disabled  pci:0000:00:1c.2
ARPT   S4 *disabled  pci:0000:03:00.0
RP05   S3 *disabled  pci:0000:00:1c.4
RP06   S3 *disabled  pci:0000:00:1c.5
SPIT   S3 *disabled
XHC1   S3 *disabled  pci:0000:00:14.0
ADP1   S3 *disabled
LID0   S3 *enabled
}}
 
And for permanent disabling:
 
{{hc|/etc/udev/rules.d/90-xhc_sleep.rules|2=
 
# disable wake from S3 on XHC1
SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled"
}}
 
If this does not work, check that ARPT is disabled, and add a corresponding rule to udev, like this:
 
SUBSYSTEM=="pci", KERNEL=="0000:03:00.0", ATTR{power/wakeup}="disabled"
 
If this still does not work, try disabling LID0. This way suspending via lid-closing should be made impossible, so you might want to follow the instructions in [https://bbs.archlinux.org/viewtopic.php?pid=1556046#p1556046 this forum post] to make suspending via both lid-closing and systemd possible, by using systemd services.
 
Slow wake ups from a suspend state can be resolved by disabling Thunderbolt. See [[#Disabling Thunderbolt]].
 
=== Wake up after suspend ===
 
Occasionally the Macboook Air may wake up immediately after suspend.
 
In {{ic|/proc/acpi/wakeup}} check to see that XHC1 and LID0 are enabled. If they are, disabling them will fix the problem. After disabling them, the only way to wake up your computer from suspend is by using the power button.
 
To do this type to following command, edit {{ic|/etc/systemd/system/suspend-fix.service}}.
 
Then add the following text and save:
 
{{bc|1=
[Unit]
Description=Fix for the suspend issue
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo XHC1 > /proc/acpi/wakeup && echo LID0 > /proc/acpi/wakeup"
[Install]
WantedBy=multi-user.target
}}
 
And then [[enable]] and [[start]] {{ic|suspend-fix.service}}.
 
Disabling only XHC1 is not recommended if you have this bug, since it may result in glitchy behavior.
 
=== Light sensor ===
 
The values can be read from {{ic|/sys/devices/platform/applesmc.768/light}}.
 
A "cat" on this path returns two-tuples like (4,0). The below referenced lighter script ignores the second value - which always seems to be 0 - and uses the first number as measured environment lighting brightness value.
 
If you want to use the built in light sensor to automatically adjust screen and keyboard backlight brightness check out
'''Lighter''' [https://github.com/Janhouse/lighter] (simple perl script, easy to fine-tune) and '''Lightum''' [https://github.com/poliva/lightum] (Requires Gnome or KDE but is older and more complete than Lighter).
 
=== Sound ===
 
First of all follow [[ALSA]] wiki page, then if something does not work correctly, continue reading this part.
 
==== Kernel options ====
 
Edit your {{ic|/etc/modprobe.d/50-sound.conf}} or {{ic|/etc/modprobe.d/modprobe.conf}} appending this line:
 
options snd_hda_intel model=intel-mac-auto
 
This should automatically specify the codec in your MacBook.
 
{{Warning|Every time you change {{ic|/etc/modprobe.d}}, test it by rebooting.}}
 
Specific models may need more help. You can try specifying other options according to your hardware. All possible settings are listed in Kernel Documentation, available online:
 
* [https://www.kernel.org/doc/html/latest/sound/alsa-configuration.html Advanced Linux Sound Architecture - Driver Configuration guide]
* [https://www.kernel.org/doc/html/latest/sound/hd-audio/index.html HD-Audio]
* [https://www.kernel.org/doc/html/latest/sound/hd-audio/models.html HD-Audio Codec-Specific Models]
 
===== Model-specifics =====
 
For example, if you have a MacBookPro12,1, you might need
 
options snd-hda-intel index=1,0
 
instead. Alternatively, for MacBookPro5,X, you can use:
 
options snd_hda_intel model=mb5
 
(note that the jack output is controlled with "HP").
 
If you have an iMac8,1, you should instead use
 
options snd-hda-intel model=mbp3 position_fix=2
 
For Aluminium iMacs, see [[iMac Aluminium#Getting sound to work right]]
 
For MacBook2,1 (late 2008/early 2009)s with a [https://www.kernel.org/doc/html/v5.15/sound/hd-audio/models.html#stac9220-9221 SigmaTel STAC9221 A1] chip, use
 
options snd_hda_intel model=macbook
 
==== Disabling S/PDIF ====
 
Some (most?) Macbook models have an optical S/PDIF audio jack in the same jack as the headphone jack. You can see it when it is active as a red light glowing out of the headphone jack. It can trick PulseAudio into preferring it and routing all your audio out it.
 
If you are not getting any sound in or out, confirm that {{ic|pavucontrol}} > Configuration > Profile says "Analog Stereo Duplex" instead of "Digital"
 
or just run
 
$ pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
 
Also check if you need to edit {{ic|/usr/share/alsa-card-profile/mixer/paths/}} to workaround faulty plug detection causing PulseAudio to failover to "Digital".
 
'''and see [[#Microphone 2,1|below]]''' for how to edit this to get the macbook2,1's microphone to work.
 
==== Auto-Mute Mode ====
 
The internal speaker might not be disabled when using the headphone jack. To solve this, enable "Auto-Mute Mode".
 
You can either do this using {{ic|alsamixer}}:
 
# Run {{ic|alsamixer}}
# Press F6 and pick "default:0  HDA Intel" to get more detailed controls
# Use the arrow keys to select "Auto-Mute Mode"
# Press Space to enable it
# (optionally) Run {{ic|sudo alsactl store}} to make the change permanent
 
or with {{ic|amixer}}:
 
$ amixer -c 0 cset name='Auto-Mute Mode' 1 && sudo alsactl store
 
==== USB audio interface ====
 
In some cases, it can actually be easier to set up sound using a USB audio interface rather than the jack directly.
 
For example, after plugging in a Focusrite Scarlett Solo, open {{Pkg|pavucontrol}}, go to {{ic|Configuration}}, choose {{ic|Off}} for all devices and choose {{ic|Analog Stereo Duplex}} for {{ic|Scarlett Solo USB}}. You can then use the headphone jack on the Focusrite device for speakers or headphones. This should work immediately and on startup. This does not require any Focusrite software to be installed.
 
=== Bluetooth ===
 
Bluetooth should work out-of-the box. See the article on [[Bluetooth]] to install and configure all software needed.
 
=== Magic Mouse ===
 
If you use a magic mouse you will find it works nicely out of the box. You might want to tweak some settings such as ''scroll-speed'' or ''acceleration''. There is no GUI for this at this time. The only way to set these settings is to instruct the kernel driver ({{ic|hid_magicmouse}}) with parameters. Create a modprobe config file for your mouse.
 
{{hc|/etc/modprobe.d/magicmouse.conf|2=
options hid_magicmouse scroll-speed=55 scroll-acceleration=1 emulate_3button=0
}}
 
This will instruct the driver to have a fast scroll-speed, do exponential acceleration and do not emulate a 3 button mouse. You can find an overview of all parameters and their current settings in {{ic|/sys/module/hid_magicmouse/parameters}}.
 
To play with the settings without rebooting you can also set them through the command line, like so:
 
# echo 55 > /sys/module/hid_magicmouse/parameters/scroll_speed
 
{{Note|Using kernel ''4.10.10-1-macbook'' the Magic Mouse (''hid_magicmouse'') will cause a lot of system lock ups. If you experience random lock ups, try a different, wired, mouse to see if this is the case for you as well.}}
 
=== Webcam ===
 
==== iSight ====
 
{{Note|Linux kernel from 2.6.26 includes the Linux UVC driver natively. '''MBP 6,2+ (Kernel ~2.6.37+) iSight works out of the box''' without the need to use firmware from OS X. Only use {{ic|isight-firmware-tools}} if it does not work normally.}}
 
iSight webcams on MacBooks or pre 6,2 MacBook Pros (6,2 came out around 2010) require the Apple's proprietary firmware that cannot be redistributed. It must be extracted from OS X and loaded onto Arch.
 
There is a pre-extracted copy at https://archive.org/details/macbook-isight-webcam-linux.
 
If you want to do it yourself you will need to install {{AUR|isight-firmware-tools}} to extract the firmware. This package also includes a udev rule and ELF binary that are necessary, even once you have extracted the firmware file into {{ic|/lib/firmware/isight.fw}}, for the file to be loaded every time you boot your computer (namely {{ic|/etc/udev/rules.d/isight.rules}} which uses {{ic|/usr/lib/udev/ift-load}}).
 
Instructions:
 
First you need to get the firmware out of a particular file located on your OS X install. It is located in {{ic|/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport}}.
 
{{ Tip | The {{ic|AppleUSBVideoSupport}} file from a OS X 10.6 (Snow Leopard) installation may not work properly. If possible, use the file from OS X 10.5 or earlier.}}
 
To mount the OS X drive if multi-booting:
 
# mkdir /media/OSX
# mount -t hfsplus /dev/sda2 /media/OSX
 
Then, install the {{AUR|isight-firmware-tools}} package.
 
Locate the {{ic|AppleUSBVideoSupport}} file in the OS X directory listed above. Either copy it over to your Arch system (Any OS X installation should do, such as an iMac, not just one specific to your system) or, if multi-booting, mount the OS X drive and navigate to the directory. (On 10.6 (Snow Leopard) and 10.7 (Lion) the directory is {{ic|/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS}}.) In that directory you can go ahead and extract the driver:
 
# ift-extract --apple-driver AppleUSBVideoSupport
 
When it is done, check that the firmware has been found:
 
# ls /lib/firmware/isight.fw
 
Once successful, completely '''SHUTDOWN''' your Mac and start it back up again (to clear the hardware state of the webcam). Do ''not'' reboot.
 
It should be automatically loaded at boot; if it is not you can load the '''uvcvideo''' module [[Kernel modules|manually or load it at boot]].
 
==== FaceTime HD Camera ====
 
Recent Macbooks include the FaceTime HD Camera, which may be connected by PCIe. You can confirm this by looking for "FaceTime HD Camera" in the output of {{ic|lspci}}. The {{AUR|bcwc-pcie-git}} package installs a '''facetimehd''' module (and firmware) to support these devices. The module should be loaded automatically after installation.
 
If the webcam shows incorrect colors, this may be due to missing sensor calibration files. Instructions for extracting the calibration files from Apple BootCamp drivers are given in this page: https://github.com/patjak/bcwc_pcie/wiki/Extracting-the-sensor-calibration-files
 
You can use many applications to test the webcam:
 
* MPlayer
 
# mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -fps 30
 
* Cheese
* Skype
* Ekiga
 
A simple solution to take snapshots is:
 
# mplayer tv:// -vf screenshot
 
and the pressing the s key to take a snapshot. Files are of the format {{ic|shot\d\d\d\d.png}} and are reported in the standard output.
 
=== Temperature Sensors ===
 
For reading temperature just install {{Pkg|lm_sensors}}. See the [[lm_sensors]] page for more information.
 
=== Color Profile ===
 
We can use color profiles from OS X.
 
First, install the {{Pkg|xcalib}} package.
 
Second copy pre-saved color profiles placed in {{ic|/Library/ColorSync/Profiles/Displays/}} on OS X partition to {{ic|~/colorprofiles/}} for example.
 
There are color profile files agree with in MacBook models; select the right one:
 
* '''Color LCD-4271800.icc''' for MacBook Pro with CoreDuo CPU
* '''Color LCD-4271880.icc''' for MacBook with Core2Duo
* '''Color LCD-4271780.icc''' for MacBook (non-Pro) based on CoreDuo or Core2Duo.
 
{{Tip|Also OS X allows to save current color profile from ''Displays > Color'' section of the ''Mac OS System Preferences'', in this case file is saved to {{ic|/Users/<username>/Library/ColorSync/Profiles}}.}}
 
Finally you can activate it by running
 
# xcalib ~/colorprofile.icc
 
{{Note|Previous command set the color profile only for the current session; this mean that you must run it every time you login in your system. For automating it you can execute the command by '''Autostart Application''', concording with your DE (or add the command to your login manager's initialization script, e.g. /etc/gdm/Init/Default).}}
 
{{Warning|GNOME will revert the profile set by xcalib. It is preferable to set the profile using '''Color''' in settings.}}


=== Apple Remote ===
=== Apple Remote ===


First, to correctly install and configure the '''lirc''' software that control IR see [[LIRC]] wiki.
[[Install]] and configure {{Pkg|lirc}}. See [[LIRC]].


Then make LIRC use {{ic|/dev/usb/hiddev0}} (or {{ic|/dev/hiddev0}}) by editing {{ic|/etc/conf.d/lircd}}. Here is how mine look:
Make LIRC use {{ic|/dev/usb/hiddev0}} or {{ic|/dev/hiddev0}}:


{{bc|1=
{{hc|/etc/conf.d/lircd|2=
#
#
# Parameters for lirc daemon
# Parameters for lirc daemon
Line 860: Line 214:
}}
}}


Use '''irrecord''' (available when installing '''lirc''') to create a configuration file matching your remote control signals (alternatively, you can try to use the {{ic|lircd.conf}} below):
Use ''irrecord'' to create a configuration file matching your remote control signals:


  # irrecord -d /dev/usb/hiddev0 -H macmini output_conf_file
  # irrecord -d /dev/usb/hiddev0 -H macmini output_conf_file


Start '''lircd''' and use '''irw''' to check if it works.
[[Start]] {{ic|lircd.service}} and use ''irw'' to check if it works.


Example of an {{ic|/etc/lirc/lircd.conf}}:
Alternatively, use the following:  


{{bc|1=
{{hc|/etc/lirc/lircd.conf|2=
begin remote
begin remote


Line 896: Line 250:
}}
}}


=== HFS partition sharing ===
=== HFS+ Partitions ===


First, install the {{AUR|hfsprogs}} package.
==== HFS partition sharing ====


we have to list our partitions. Use [[fdisk]].
[[Install]] {{AUR|hfsprogs}} and use [[fdisk]] to list the partitions:
 
Example output:


{{hc|# fdisk -l /dev/sda|
{{hc|# fdisk -l /dev/sda|
Line 912: Line 264:
}}
}}


As we see, the "Unknown" partition is our OS X partition, which is located in {{ic|/dev/sda2}}.
The "Unknown" partition is our macOS partition, which is located in {{ic|/dev/sda2}}. We can use this in our [[fstab]]:  
 
Create a "mac" folder in /media:
 
# mkdir /media/mac
 
Add at the end of ''/etc/fstab'' this line:
 
/dev/sda2    /media/mac    hfsplus auto,user,rw,exec  0 0
 
Mount it :
 
# mount /media/mac
 
and check it:
 
$ ls /media/mac
 
=== HFS+ Partitions ===
 
==== Journaling ====
 
HFS+ partitions, now the default in OS X, are not fully supported by Linux and are mounted as read-only by default. In order to write to an HFS+ partition, the safe way is to disable journaling. This can be accomplished using the OS X Disk Utility. Refer to this [https://support.apple.com/kb/ht2355 Apple support page] for more information or try to do it from the command line:
 
Find your partition:
 
{{hc|# diskutil list|
/dev/disk0
  #:                      TYPE NAME                    SIZE      IDENTIFIER
  0:      GUID_partition_scheme                        *750.2 GB  disk0
  1:                        EFI EFI                    209.7 MB  disk0s1
  2:                  Apple_HFS OSX                    149.5 GB  disk0s2
  3:                  Apple_HFS Macintosh HD            599.2 GB  disk0s3
  4:                Apple_Boot Recovery HD            650.0 MB  disk0s4
}}
 
In this example we will use ''disk0s3'' partition named as ''Macintosh HD''. To know if journaling is activate or not you could execute:


{{hc|# diskutil info /dev/disk0s3 {{!}} grep -i journal|
{{hc|/etc/fstab|
     File System Personality:  Journaled HFS+
/dev/sda2    ''/path/to/shared/hfs_partition''     hfsplus auto,user,rw,exec  0 0
    Name (User Visible):      Mac OS Extended (Journaled)
    Journal:                  Journal size 49152 KB at offset 0x1176000
}}
}}


As you can read the journaling is active. To turn off the journaling you could execute:
It can then be mounted, and the content accessed.
 
# diskutil disableJournal disk0s3


To verify it is done execute the info command again.
==== Bad Superblock Error ====
 
If you get noting as output, then journaling is disabled.
 
However, if you fail to disable journaling. You can change "auto,user,rw,exec" in {{ic|/etc/fstab}} to "auto,user,force,rw,exec" and mount it.
 
==== Yosemite and later ====


This section addresses error message when mounting hfsplus partition:
This section addresses error message when mounting hfsplus partition:
Line 1,018: Line 324:
   mount /dev/sdX -t hfsplus -o ro,sizelimit=318841946112
   mount /dev/sdX -t hfsplus -o ro,sizelimit=318841946112


=== Home sharing ===
==== Disable Journaling ====


'''''UID synchronization'''''
HFS+ partitions are not fully supported by Linux and are mounted as read-only by default. In order to write to an HFS+ partition, the safe way is to disable journaling. This can be accomplished using the macOS Disk Utility. Refer to this [https://support.apple.com/kb/ht2355 Apple support page] for more information or try to do it from the command line:


==== In OS X ====
Find your partition:


{{Note|It is strongly recommended that UID/GID manipulation be done immediately after a new user account is created, in OS X as well as in Arch Linux. If you installed OS X from scratch, then this operation is guaranteed to work after logging into your account for the first time.}}
{{hc|# diskutil list|
/dev/disk0
  #:                      TYPE NAME                    SIZE      IDENTIFIER
  0:      GUID_partition_scheme                        *750.2 GB  disk0
  1:                        EFI EFI                    209.7 MB  disk0s1
  2:                  Apple_HFS macOS                  149.5 GB  disk0s2
  3:                  Apple_HFS Macintosh HD            599.2 GB  disk0s3
  4:                Apple_Boot Recovery HD            650.0 MB  disk0s4
}}


===== Step 1: change UID and GID(s) =====
In this example we will use ''disk0s3'' partition named as ''Macintosh HD''. To know if journaling is activate or not you could execute:


'''''Pre-Leopard'''''
{{hc|# diskutil info /dev/disk0s3 {{!}} grep -i journal|
    File System Personality:  Journaled HFS+
    Name (User Visible):      Mac OS Extended (Journaled)
    Journal:                  Journal size 49152 KB at offset 0x1176000
}}


# Open '''NetInfo Manager''' located in the ''/Applications/Utilities'' folder.
As you can read the journaling is active. To turn off the journaling you could execute:
 
# diskutil disableJournal disk0s3
 
To verify it is done execute the info command again.
 
If you get noting as output, then journaling is disabled.
 
However, if you fail to disable journaling. You can change "auto,user,rw,exec" in {{ic|/etc/fstab}} to "auto,user,force,rw,exec" and mount it.
 
=== UID synchronization for home sharing ===
 
If you want to access your macOS user directories from Linux, write down the UID and GID for the users. macOS begins with the first user's UID at 501 while Arch defaults to 1000.
 
{{Warning | Never change any file permissions in your macOS partition from Linux.}}
 
==== In macOS ====
 
{{Note|It is strongly recommended that UID/GID manipulation be done immediately after a new user account is created, in macOS as well as in Arch Linux.  If you installed macOS from scratch, then this operation is guaranteed to work after logging into your account for the first time.}}
 
===== Change UID and GID(s) =====
 
The default UID and GID on Arch Linux for a user is 1000, adjust the following steps according to your setup.
 
====== Pre-Leopard ======
 
# Open '''NetInfo Manager''' located in the {{ic|/Applications/Utilities}} folder.
# If not done for you already, enable access to user account transactions by clicking on the closed lock at the bottom of the window, and entering your account password, or root password if you have created a root account.
# If not done for you already, enable access to user account transactions by clicking on the closed lock at the bottom of the window, and entering your account password, or root password if you have created a root account.
# Navigate to ''/users/<new user name>'' where <new user name> is the name of the account that will have read/write access to the folder that will be shared with the primary user in Arch.
# Navigate to {{ic|/users/''new_user_name''}}
# Change the '''UID''' value to 1000 (the value used by default for first user created in Arch).
# Change the '''UID''' value to 1000  
# Also change the '''GID''' value to 1000 (the value used by default for user account creation in Arch).
# Change the '''GID''' value to 1000
# Navigate to {{ic|/groups/<new user name>}}, automatically saving the changes you have made so far.
# Navigate to {{ic|/groups/''new_user_name''}}, automatically saving the changes you have made so far.


{{Note|If you get an error message that the transaction is not allowed, log out and log back in.}}
{{Note|If you get an error message that the transaction is not allowed, log out and log back in.}}


'''''Leopard'''''
====== Leopard ======


In Leopard, the '''NetInfo Manager''' application is not present. A different set of steps is required for UID synchronization:
In Leopard, the '''NetInfo Manager''' application is not present. A different set of steps is required for UID synchronization:
Line 1,047: Line 391:
# Unlock the pane if not already done so.
# Unlock the pane if not already done so.
# Right-click on the desired user and select '''Advanced Options'''.
# Right-click on the desired user and select '''Advanced Options'''.
# Write down the value of the '''User ID''' field, you will need it later on. Change both the UID and GID to match the UID and GID of the account wished to be shared with in Arch (1000 by default for the first user created in Arch).
# Write down the value of the '''User ID''' field, you will need it later on. Change both the UID and GID to match the UID and GID of the account to be shared with in Arch.


===== Step 2: change "Home" permissions =====
===== Change "Home" permissions =====


# Open up '''Terminal''' in the {{ic|/Applications/Utilities}} folder.
# Open up '''Terminal''' in the {{ic|/Applications/Utilities}} folder.


# Enter the following command to reclaim the permission settings of your home folder, replacing <your user name>, <your user group> and <your old UID> with the user name whose UID and GID values you just changed, the group name whose GID value you just changed and the old UID number, respectively.
# Enter the following command to reclaim the permission settings of your home folder:


  # find /User/<your user name> -user <your old UID> -exec chown <your user name>:<your user group> {} \;
  # find /User/''your_user_name'' -user ''your_old_UID'' -exec chown ''your_user_name'':''your_user_group'' {} \;


==== In Arch ====
==== In Arch ====
Line 1,062: Line 406:
It is therefore recommended that you do this as soon as you install Arch Linux.
It is therefore recommended that you do this as soon as you install Arch Linux.


Now you must substitute Arch's home with OS X's home, by modify entries of {{ic|/etc/fstab}}.
  # useradd -m -u [uid] -g [gid] -G [additional_groups] -s [login_shell] [username]
 
=== Avoid long EFI wait before booting ===
 
If your MacBook spends 30 seconds with "white screen" before booting you need to tell the firmware where the booting partition is.
 
Boot OS X, if you do not have it installed, you can use the install DVD (select language, then click Utilities->Terminal) or another MacBook with OS X (connect the two computers via firewire or thunderbolt, start the other MacBook while holding the T button, boot your MacBook while holding the Options button (alt)).
 
Either way, once you have got a OS X terminal running on your MacBook you need to execute a different command (as root) depending on if you use EFI or not:
 
  # bless --device /dev/disk0s1 --setBoot            # if the booting partition is EFI
 
or
 
# bless --device /dev/disk0s1 --setBoot --legacy  # if the booting partition is not EFI


(given that if your GRUB or EFI is on sda1, /dev/disk1s2 if it is on sdb2, etc). See also https://bbs.archlinux.org/viewtopic.php?pid=833215.
Now you must substitute Arch's home with macOS's home, by modify entries of {{ic|/etc/fstab}}. In order to be able to access a macOS user's directory, only the uid and gid need to match (usernames can differ).


=== Mute startup chime ===
=== Mute startup chime ===
Line 1,092: Line 422:
After that, run the {{ic|printf}} command and it should overwrite the file properly. Verify the file's contents and then set the immutable bit again with {{ic|chattr +i}} once satisfied.
After that, run the {{ic|printf}} command and it should overwrite the file properly. Verify the file's contents and then set the immutable bit again with {{ic|chattr +i}} once satisfied.


Alternatively, you can use a OS X install disk to mute the chime. Boot from it, select language, then click ''Utilities > Terminal'', and enter
Alternatively, you can use a macOS install disk to mute the chime. Boot from it, select language, then click ''Utilities > Terminal'', and enter


  # /usr/sbin/nvram SystemAudioVolume=%01
  # /usr/sbin/nvram SystemAudioVolume=%''percentage''


(or whatever volume you want).
{{Note|Required formatting of the value provided for key SystemAudioVolume may differ depending on models and perhaps the version of macOS install media. If the above command fails to work, try enclosing the value in double quotes.}}


{{Note|Required formatting of the value provided for key SystemAudioVolume may differ depending on MacBook model and perhaps the version of OS X install media. If the above command fails to work, try enclosing the value in double quotes.}}
=== Custom icon in the boot loader ===


=== kworker using high CPU ===
The Mac boot loader supports loading custom icons for each volume it detects. The custom icon must be in the {{ic|.icns}} format, and be located at the root of the volume containing the boot loader, with the file name {{ic|.VolumeIcon.icns}}.


Sometime with the addition of Yosemite, some users found that kworker CPU usage will spike, as disccused [https://bbs.archlinux.org/viewtopic.php?id=171883&p=11 here]. This is sometimes the result of runaway ACPI interrupts.
The following example downloads an Arch logo SVG with {{Pkg|wget}}, converts it to PNG with {{Pkg|librsvg}} and then converts it to an {{ic|.icns}} with {{Pkg|libicns}}:


To check and see, you can count the number of recent ACPI interrupts and see if any of them are out of control.
$ wget -O /tmp/archlinux.svg https://archlinux.org/logos/archlinux-icon-crystal-64.svg
$ rsvg-convert -w 128 -h 128 -o /tmp/archlogo.png /tmp/archlinux.svg
# png2icns /boot/.VolumeIcon.icns /tmp/archlogo.png


$ grep . -r /sys/firmware/acpi/interrupts/
Obviously, you can replace the Arch logo with any other icon you like.
 
If you see that one particular interrupt is out of control (possibly GPE66), i.e., registering hundreds of thousands of lines, you can try disabling it (replace XX with the runaway interrupt):
 
# echo "disable" > /sys/firmware/acpi/interrupts/gpeXX
 
Disabling random ACPI interrupts could cause all kinds of problems, so do this at your own risk. If this fixes the problem, there is discussion about how to make a systemd service that automatically disables an interrupt at every boot [https://bbs.archlinux.org/viewtopic.php?pid=1488371 here].
 
== rEFIt ==
 
{{Note|
* You probably want to have a look at [https://www.rodsbooks.com/refind/ rEFInd], which is some type of successor of rEFIt.
* This is not a requirement.  It only gives you a menu to choose between OS X and Arch Linux upon every boot.
}}
 
For more see, [http://refit.sourceforge.net/myths/ rEFIt myths].
 
In OS X, download the ".dmg" from [http://refit.sourceforge.net/ rEFIt Homepage] and install it.
 
{{Note|If you have already partitioned your hard disk in preparation for the Arch installation, rEFIt may not be enabled by default.  You will have to run the "enable.sh" script installed in /efi/refit/.}}
 
Open up '''Terminal''' and enter:
 
# cd /efi/refit;
# ./enable.sh
 
=== Problems with rEFIt ===
 
If you experience problems after the install of Arch or rEFIt, especially is the right OS is not showing up to boot to or if it dumps you at a GRUB prompt stuck like the following:
 
GRUB>_
 
Then have a look at this link:
 
http://mac.linux.be/content/problems-refit-and-grub-after-installation
 
It can give you a basic idea on how to boot off the Arch live cd, mount the problem Arch install, chroot, use gptsync, and reinstall GRUB. This is probably for more advanced users who can translate the commands from a debian system to an Arch system and also apply it to the partitions on their machine. Be careful not to install GRUB in the wrong spot.
 
If you need gptsync, install {{AUR|gptsync}}.
 
==== Mavericks upgrade breaks Arch boot option ====
 
For some multi-boot users who utilize a separate Linux boot partition, the OS X Mavericks upgrade may overwrite the boot partition with Apple's own recovery boot filesystem. This breaks the Arch Linux boot option in rEFIt/rEFInd. The best way to proceed in this situation is to abandon a separate boot partition and use the EFI system partition (ESP) to install the boot loader of your choice. It is also recommended that you use rEFInd instead of rEFIt as development on the latter has halted.
 
Assuming grub2 as the boot loader:
 
Use the Arch LiveCD to boot to a shell and [[chroot]] to your broken Arch Linux environment.
 
Mount the ESP on /boot.
 
Edit the fstab and remove the old boot partition and make ESP the new boot partition. Now mount the ESP as the new {{ic|/boot}} parition.
 
# mount -a
 
[[install|Reinstall]] the {{pkg|linux}} package.
 
Create a new initramfs and vmlinuz in /boot.
 
# mkinitcpio -p linux
 
Install grub.
 
# grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub --recheck --debug
 
Create a new grub.cfg file.
 
# grub-mkconfig -o /boot/EFI/grub/grub.cfg
 
Make sure that grub.cfg is in the same directory as grubx64.efi.
 
Generate a new refind_linux.conf file in /boot simply by running mkrlconf.sh which comes with rEFInd.
 
Exit the chroot environment.
 
Reboot. You should see a new entry for Arch Linux in rEFInd and it should boot to your Arch Linux installation.
 
== Model-specific information ==
 
=== MacBook ===
 
==== April 2016 12" - Version 9,1 ====
 
* Booting from USB via EFI works fine, when giving the {{ic|1=intremap=nosid}} kernel option. Remember to hold the Alt key on booting to enter the boot menu. In order to allow Linux boot directly from your system disk, you will first need to install https://www.rodsbooks.com/refind/ from within OSX recovery mode (hold cmd+r during boot, then open terminal, then run refind-install script).
* The wireless card works out of the box with {{ic|brcmfmac}}.
* Suspend / hibernate does not work. The problem seems to be the NVMe that does not wake up. When booting from an external drive, suspend / hibernate works out of the box.
* Audio recording works out of the box. Audio playback works out of the box for headphones, not for built-in speakers. Cirrus driver patch needed for making the speakers work: https://github.com/leifliddy/macbook12-audio-driver
* The keyboard and the touchpad do ''not'' work out of the box. There is a work-in-progress driver available that works well: {{AUR|macbook12-spi-driver-dkms}}. Sometimes the touchpad does not work after booting but this can be fixed by reloading the driver with {{ic|rmmod applespi && modprobe applespi}}.
* The keyboard backlight does not work (no solution yet). 
* For Bluetooth driver, see {{AUR|macbook12-bluetooth-driver}}
 
==== Mid 2007 13" - Version 2,1 ====
 
===== Boot loader =====
 
The macbook2,1 is an unusual system, being a x86_64 machine that runs a 32-bit pre-boot EFI OS. This means that while you should (and will, if you are using official Arch ISOs) install a 64 bit Linux, you need to make sure the boot loader you choose is compiled for 32-bits.
 
With [[GRUB]], this is done by
 
# grub-install --target i386-efi --efi-directory=/boot/ --removable
 
You can also use rEFInd, as explained next.
 
===== Installation via 201212 ISO image =====
 
Since older Macbooks have a 32bit EFI running, the usual installation image is not recognized. You need to either remove the UEFI support from the disc ([[Unified Extensible Firmware Interface#Remove UEFI boot support from optical media]]) or build a 32bit EFI version of the disc. The paragraphs below will take the first path to success, booting into BIOS mode and its pitfalls. For a try the other way round, read [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]] first.
 
First prepare your harddisc according to your wishes. In this scenario it was a "Linux only" approach with
 
/dev/sda1 HFS+ AF00 200M -> EFI boot system on Apple HFS+ partition
/dev/sda2 ext4 8300 147G -> arch system
/dev/sda3 swap 8200 1G  -> swap
 
The {{AUR|hfsprogs}} package contains the tools to handle HFS/HFS+ filesystems. The rEFInd boot loader recognizes it on its own. Usually the partition for the EFI boot loader is a FAT32 (vfat) partition. In this case I tried rEFIt first, which apparently needs the HFS+ filesystem to work, and kept it at that.
 
The mount points are:
 
/dev/sda2 -> /
/dev/sda1 -> /boot
 
The boot loader in use was [https://www.rodsbooks.com/refind/index.html rEFInd] instead of rEFIt. To install it, the rEFInd homepage provides a good guide. Usually it is simply done by copying rEFInd:
 
# mkdir /boot/EFI
# cp -vr /usr/share/refind/drivers_ia32 /boot/EFI/refind/
# cp -vr /usr/share/refind/tools_ia32 /boot/EFI/refind/
# cp -vr /usr/share/refind/fonts /boot/EFI/refind/
# cp -vr /usr/share/refind/icons /boot/EFI/refind/
# cp -v /usr/share/refind/refind_ia32.efi /boot/EFI/refind/
# cp -v /usr/share/refind/refind.conf-sample /boot/EFI/refind/refind.conf
# cp -v /usr/share/refind/refind_linux.conf-sample /boot/refind_linux.conf
 
{{Note|I'm using the 32bit version of Arch and refind, since the EFI of the old MacBooks is 32bit. I'm not sure about 32bit rEFInd booting a 64bit Arch...}}
 
The pitfall here is, that the system bootet in BIOS compatibility mode and not in EFI mode. You cannot therefore use {{ic|efibootmgr}}, because the EFI variables (even with 'modprobe efivars') are not available. While installing the system get {{AUR|mactel-boot}}. The {{ic|hfs-bless}} utility comes in handy, when blessing the EFI boot loader. This is done by calling:
 
# hfs-bless /boot/EFI/refind/refind_ia32.efi
 
Since the Linux kernel does come with EFI stub enabled, it seems a good idea to run it through a boot loader first. Especially if it runs not out of the box. But using rEFInd makes GRUB (or any other boot loader) obsolete, because of that.
 
{{Note|In the refind_linux.conf you add any kernel option you may want as long as you use the EFI stub of your kernel. In refind.conf you adjust your needs for the boot loader itself, like menu entries. If you use them (menu entries), rEFInd should not look for these EFI stub kernels itself, so blacklist the directories used in here, like {{ic|/boot/}}.}}
 
Not running out of the box is unfortunately the initial stage for the kernel. Since we installed it in BIOS mode, two modules are missing to grant access to the root partition while booting. Hence the 'initfsram-linux.img' can not be found/loaded. Adding the following modules to your {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}} solved this ([https://bbs.archlinux.org/viewtopic.php?pid=1139226#p1139226 original post]).
 
{{hc|/etc/mkinitcpio.conf|2=
MODULES=(ahci sd_mod)
}}
 
[[Regenerate the initramfs]].
 
The boot loader rEFInd can scan kernels even out of the {{ic|/boot/...}} directory and assumes an efi kernel even without the extension ''.efi''. If you do not want to try out special kernels, this should work without the hassle to copy each kernel after building to some spot special.
 
If you happen to get multiple entries for one boot image, it often results of a previous installation of a boot loader within the MBR. To remove that, try the following - taken from the [https://ubuntuforums.org/showpost.php?p=7828260&postcount=4 original post]. This is valid for GPT partitioned discs, so please check your environment and save your MBR first.
 
# dd if=/dev/zero of=/dev/sda bs=440 count=1
 
===== Installation via 202104 ISO image =====
 
===== Rebooting =====
 
The MacBook will not reboot properly by default. It [https://askubuntu.com/a/7132 needs] the kernel command line parameter {{ic|1=reboot=pci}}. To add it, if you are using [[GRUB]], [[GRUB#Additional_arguments|add the parameter]] with:
 
(echo;
  echo '# Repair macbook rebooting: https://askubuntu.com/a/7132';
  echo 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX reboot=pci"') >> /etc/default/grub
 
Then make sure to [[GRUB#Generate_the_main_configuration_file|regenerate]] with
 
grub-mkconfig -o /boot/grub/grub.cfg
 
If you are using [[syslinux]] then [[Syslinux#Kernel_parameters|use its APPEND operation]].
 
===== Microphone 2,1 =====
 
If your microphone is not working, you have probably run into [https://www.mail-archive.com/pulseaudio-discuss@lists.freedesktop.org/msg20703.html a driver bug] which makes the macbook think the digital microphone is always plugged in, disabling the normal microphone.
 
To work around it, disable the pulseaudio plug detector with this patch:
 
--- a/usr/share/pulseaudio/alsa-mixer/paths/analog-input-mic.conf
+++ b/usr/share/pulseaudio/alsa-mixer/paths/analog-input-mic.conf
@@ -23,6 +23,8 @@
 
  [Jack Mic]
  required-any = any
+state.plugged = unknown
+state.unplugged = unknown
 
  [Jack Mic Phantom]
  required-any = any
@@ -31,6 +33,8 @@
 
  [Jack Mic - Input]
  required-any = any
+state.plugged = unknown
+state.unplugged = unknown
 
  [Element Capture]
  switch = mute
 
{{Warning|This needs to be reapplied manually after every pulseaudio upgrade. Pulseaudio does not seem to support any kind of system-local customization files that could make this patch permanent.}}
 
=== MacBook Pro ===
 
==== Mid 2010 - Version 6,2 ====
On this model only the open source NVIDIA driver [[nouveau]] is installable in UEFI mode (The proprietary driver {{AUR|nvidia-340xx-dkms}} causes a black blank screen when Xorg loads).
 
{{Note|A kernel option enabled in recent kernels causes suspension and hibernation to become dysfunctional when using the open source nouveau driver [https://wiki.debian.org/InstallingDebianOn/Apple/MacBookPro/7-1#Fix_Suspending_and_Hibernating_on_Bullseye (Debian) ]}}
 
The solution is to provide the {{ic|1=init_on_alloc=0}} [[Kernel parameters|kernel parameter]].
 
==== Early 2015 13"/15" - Version 12,x/11,4+ ====
 
===== Wireless =====
 
The {{ic|brcmfmac}} driver is working as of 2015-11-20, with newer firmware necessary for working 5GHz support ([https://bugzilla.kernel.org/show_bug.cgi?id=100201#c65 see here.])
 
{{Note|On the Macbook Pro 12,1 if the {{ic|brcmfmac}} driver can not be started and the following errors occur in the journal:
 
{{bc|
brcmfmac: brcmf_chip_recognition: chip backplane type 15 is not supported
brcmfmac: brcmf_pcie_probe: failed 14e4:43ba
}}
 
Then check whether [[Power_management#PCI_Runtime_Power_Management|PCI runtime power management]] is enabled on the device, and disable it if so.
}}
 
===== Bluetooth =====
 
Bluetooth is fully supported starting from kernel-4.4.0.
 
===== Suspend and power Off (11,4+) =====
 
The 11,4 and 11,5 MacBook Pros do not shutdown or suspend correctly with the default kernel. This issue is being addressed in [https://bugzilla.kernel.org/show_bug.cgi?id=103211 Bug 103211] and a temporary patch is currently available in {{AUR|linux-macbook}}. Note that [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/x86/pci/fixup.c?h=v4.13-rc1&id=13cfc732160f7bc7e596128ce34cda361c556966 Linux 4.13.0] has this patch included, and will be released shortly.
 
===== Keyboard and trackpad =====
 
Haptic feedback works out of the box due to the trackpad's built-in firmware.
 
There are several drivers available that provide multitouch support. The following have been confirmed working with the MacBookPro12,1.
 
For {{Pkg|xf86-input-libinput}} the following configuration emulates some features from the OS X functionality. For more options see {{man|4|libinput}}.
 
{{hc|/etc/X11/xorg.conf.d/90-libinput.conf|2=
Section "InputClass"
    Identifier "libinput touchpad catchall"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"
    Driver "libinput"
    Option "NaturalScrolling" "true"
EndSection
}}
 
For {{Pkg|xf86-input-synaptics}} the following configuration is necessary to make the touchpad work fully.
 
{{hc|/etc/X11/xorg.conf.d/60-magictrackpad.conf|2=
Section "InputClass"
    Identifier "Trackpad"
    Driver "synaptics"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"
EndSection
}}
 
Further, some US/ANSI keyboards suffer from an issue where the tilde key (~, the key vertically between Esc and Tab) registers as < and >. The following config file fixes this issue.
 
{{hc|/etc/modprobe.d/hid_apple.conf|2=
options hid_apple iso_layout=0
}}
 
See [https://bugzilla.kernel.org/show_bug.cgi?id=96771 this kernel bugzilla] for more details and the relevant patches for earlier kernels.
 
===== Graphics =====
 
For Intel-only graphics, install the {{Pkg|xf86-video-intel}} package. For more information or OpenGL/3D support, follow instructions at [[Intel graphics]].
 
As of {{Pkg|linux}} kernel 4.16.6 dual graphics switching does work on the 11,5 (2015) with Intel modesetting and the AMD GPU utilizing the radeon driver (amdgpu is untested). See [[MacBookPro11,x#Graphics]] to enable the integrated graphics. Once the laptop boots with integrated graphics enabled you can use VGA Switcheroo controls to power down the discrete GPU. However, if you keep it powered on you will be able to utilize HDMI connections and using {{AUR|switcheroo-control}} you can run applications on the AMD GPU.
 
{{Note|
* The kernel parameters {{ic|acpi_backlight}}, {{ic|i915.lvds_downclock}}, {{ic|i915.enable_ips}}, and {{ic|intel_iommu}} are no longer necessary as of kernel 4.2.
* (Kernel 4.10.8, MacBook Pro 11,4+) If you experience system lock ups and/or tearing in Xorg, remove the .{{Pkg|xf86-video-intel}} completely, including any config file you made for it. Xorg will default to its modesetting DDX driver. The performance of this driver is good and the locks go away. See also [[Intel graphics]].
* If you are experiencing flickering issues with Xorg, you can set {{ic|i915.enable_rc6}} to {{ic|0}} parameter into the kernel parameters which will disable to power saving of [[Intel graphics]].
}}
 
==== 2012 - 2014 models ====
 
* [[MacBookPro11,x]] (Late 2013—Mid 2014)
* [[MacBookPro10,x]] (Mid 2012—Early 2013)
 
=== MacBook Air ===
 
==== Early 2014 11" - Version 6,1 ====
 
This is almost the same as the 2013 version, where the only known difference is a slightly faster processor. The version numbers have not been changed since the 2013 version.
 
It works excellently after following the instructions for the MBA 2013 13" here and in the forum thread.
Bluetooth, which has been reported not working for some people with the 2013 version, works without trouble for the 2014 version, although it should be exactly the same.
 
{{Note| Unless you have a local repository on a USB disk, you need a USB to ethernet adaptor or a USB wireless adaptor supported natively by the kernel to easily install Arch Linux, since you have to install the {{Pkg|broadcom-wl-dkms}} package to make the internal wireless adaptor work.}}
 
Unresolved issues:
 
* There is no driver for the webcam yet.
* rEFInd uses 30 seconds to start booting. Using the bless trick stops rEFInd from loading, and it has to be re-installed.
 
==== Mid 2013 13" - Version 6,2 ====
 
[https://bbs.archlinux.org/viewtopic.php?id=165899 Dedicated forum thread]
 
===== Installing and booting =====
 
Booting from a normal 2013.6 USB key works fine, but I could not seem to get either GRUB or Syslinux working.
 
I was able to boot by first installing Arch Linux following the MacBook guide at the wiki (having a separate FAT32 /boot partition). Skip the boot loader installation.
 
Installing [https://www.rodsbooks.com/refind/getting.html rEFInd] from OS X (important!) and installing the EFI stub loader made me able to boot fine.
 
[https://bbs.archlinux.org/viewtopic.php?id=165710 Dedicated thread].
 
{{Note| Installing [https://www.rodsbooks.com/refind/getting.html rEFInd] from Linux (or from OS X, but to the esp) also works fine}}
 
===== Arch Only Installation =====
 
This method works without rEFInd and uses grub to boot EFI.  Partition as follows:
 
/dev/sda1 200M Microsoft basic data
/dev/sda2 256M Linux filesystem
/dev/sda3 4G Linux swap
/dev/sda4 108.6G Linux filesystem
 
sda1 can also be a HFS+ partition for EFI.  This example chooses to use FAT32 (vfat). Although swap is optional, it is required for hibernation. Instead of sda4 for root and home, an alternative partition scheme would be to make sda4 as root and sda5 as home.
 
Format and mount:
 
# mkfs.vfat -F 32 /dev/sda1
# mkfs.ext2 /dev/sda2
# mkswap /dev/sda3
# swapon /dev/sda3
# mkfs.ext4 /dev/sda4
 
# mount /dev/sda4 /mnt
# mkdir /mnt/boot
# mount /dev/sda2 /mnt/boot
# mkdir /mnt/efi
# mount /dev/sda1 /mnt/efi
 
Finish the installation according to the [[Installation guide]] and skip anything after the boot loader.  After you have generated your initramfs and set root passwd follow below to setup grub. First, install {{Pkg|grub}} {{Pkg|efibootmgr}}, then:
 
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
# grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=grub --recheck --debug
# grub-mkconfig -o /efi/EFI/grub/grub.cfg
# cp /efi/EFI/grub/grub.cfg /boot/grub/grub.cfg
# cp /efi/EFI/grub/grubx64.efi /efi/EFI/boot/bootx64.efi}}
 
Now you can exit/unmount/reboot:
 
# exit
# umount -R /mnt
# reboot
 
===== Stability problems =====
 
{{Style|Section is written like a blog post}}
 
{{Note| Passing {{ic|<nowiki>libata.force=1:noncq</nowiki>}} to the kernel parameters solves the problem.}}
This is the big worry for me. Every now and then my system hangs for a brief moment and everything involving net or disk access just hangs there for a while and then it seems to work.
So far it only seems to happen when I run something disk or CPU-intensive. Also had an occasion when I could not start X and just got this repeating all over my screen:
 
ata1.00: failed command: WRITE FPDMA QUEUED
ata1.00: cmd 61/08:f0:10:8c:c2/00:00:0b:00:00/40 tag 30 ncq 4096 out
res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
 
On the next attempt it worked fine.
I did SMART short and long tests on my disk and they returned fine:
[https://web.archive.org/web/20140908060927/http://pastebin.com/vRE4T2Ld smartctl -a]
 
There are some messages in my boot that indicate this could be disk and/or ACPI related.
 
These are with 2013-06 ISO, 3.9.7-1 2013 x86_64 kernel.
 
[https://web.archive.org/web/20140908060925/http://pastebin.com/mjTJaPFa journalctl -b]
Seems to only work with the headphone jack, not with the speakers.
 
[https://web.archive.org/web/20140908060928/http://pastebin.com/SdAcHuKh dmesg]
 
{{Note | Same problem in 2017 with a Macbook Air early 2014. Updating the firmware (via migration to macOS Sierra) solved the issue.}}
 
===== Marvell ATA suspend bugs =====
 
If you have 2013 MacBook Air with a Marvell 128 or 256 GB drive, you might get the following ata errors instead after pm-suspend/resumes:
 
ata1: exception Emask 0x10 SAct 0x0 SErr 0x10000 action 0xe frozen
ata1: irq_stat 0x00400000, PHY RDY changed
ata1: SError: { PHYRdyChg }
ata1: hard resetting link
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
ata1.00: unexpected _GTF length (8)
ata1.00: unexpected _GTF length (8)
ata1.00: configured for UDMA/33
ata1: EH complete
 
Try what Patrick and Tejun figured out on the [https://bugzilla.kernel.org/show_bug.cgi?id=62351 linux bug]. I followed what Patrick describes with sata_alpm, and I have not seen the issue since.
 
There are more steps on how to resolve this issue in [https://bbs.archlinux.org/viewtopic.php?pid=1562168#p1562168 this thread on the Arch forum]
 
===== Suspend/Resume =====
 
Brightness is either 0% or 100% after resuming from suspend.  Adding the kernel parameter "acpi_osi=!Darwin" to your boot loader fixes the problem, though may have other side effects including disabling the thunderbolt port.
 
===== WiFi =====
 
WiFi does not work out of the box. Install {{Pkg|broadcom-wl-dkms}} to connect to a network.  If booting from the official Arch Linux ISO, one needs to unload a few standard modules in order to use the included wl module.  Do so as follows:
 
# rmmod b43 ssb bcma wl
 
Now simply load the wl module:
 
# modprobe wl
 
This should automatically load the onboard wifi which can be seen by issuing: {{ic|ip a}}.  From here follow the [[wpa_supplicant#Connecting with wpa_cli]] article to bring up the wireless network.
 
===== Touchpad =====
 
Since 3.10.3 kernel touchpad works perfectly with {{Pkg|xf86-input-synaptics}}.
 
===== Audio =====
 
ALSA may recognise the HDMI audio out as card 0 which will be the default card. Confirm this by checking the output of
 
$ aplay -l
 
If that is the case, you may need to create a {{ic|/etc/asound.conf}} with below entries:
 
defaults.pcm.card 1
defaults.ctl.card 1
 
to use the HDA Intel card, ie. the built-in speakers / headphones.
 
==== Mid 2012 11.5" — Version 5,1 ====
 
If you have issues with waking from sleep while in X11 such as a black screen or showing the console with a frozen mouse cursor then remove {{Pkg|xf86-input-synaptics}} and install {{AUR|xf86-input-mtrack-git}}. This fixed errors such as
  (EE) [dix] bcm5974: unable to find touch point 0
and backtraces that causes X11 to crash. This might apply to Version 5,2 assuming they use the same trackpad.
 
==== Mid 2011 — version 4,x ====
 
Works out-of-the-box since kernel 3.2.
 
==== Mid 2009 — version 2,1 ====
 
Everything works, except the WIFI. You need to [[install]] the {{Pkg|b43-fwcutter}} and {{AUR|b43-firmware}} packages.
 
[[Append]] {{ic|1=options b43 pio=1 qos=0}} to {{ic|/etc/modprobe.d/b43.conf}}.
 
==== Early 2008 — version 1,1 ====
 
Everything works out of the box though you will need the {{Pkg|b43-fwcutter}} package (or simply {{AUR|b43-firmware}}) for the wireless adapter to work.
 
Since this model has only one USB port, you may find it easiest to install Arch with a powered USB hub. Plug a USB network adapter (wireless or ethernet adapter to plug into a USB port) and your Arch installation media into the USB hub.
 
If you cannot get any result by scanning wireless network after boot, unload modules {{ic|b43}} and {{ic|ssb}} and load them again:
 
# rmmod ssb
# rmmod b43
# modprobe b43
 
There is a good chance you will find what's wrong with DMA from the ''dmesg'' log.
 
Even if you can scan wireless networks after reloading the modules, it is still possible that you will only be able to connect to some networks, but not all of them. According to a more detailed discussion here: https://crunchbang.org/forums/viewtopic.php?id=17368, adding {{ic|1=pio=1,qos=0}} options to the b43 module can solve this problem.
 
I tested this for a 13' MacBookAir1,1 with a BCM4321 chipset, and it works.
 
=== Mac Mini ===
 
==== 2018 ====
 
{{Warning|
Attempting to modify UEFI boot parameters with efibootmgr is likely to crash in the kernel. Including GRUB install phase
}}
 
Luckily firmware on this model can function without it, using following adaptation of the [[#Using the native Apple boot loader with GRUB]]
 
* Instead of creating HFS+ partition create a fat32 partition for the boot loader
* Instead of using grub-install create grub image and installation manually OR boot with efi=noruntime parameter
* Manual installation:
 
# mkdir -p /boot/grub/fonts
# grub-mkimage -O x86_64-efi -o /boot/System/Library/CoreServices/boot.efi -p /boot/grub part_gpt hfsplus fat ext2 btrfs normal chain boot configfile linux appleldr minicmd loadbios reboot halt search font gfxterm png all_video
# cp -r /usr/lib/grub/x86_64-efi /boot/grub/
# cp /usr/share/grub/unicode.pf2 /boot/grub/fonts/
* Touching {{ic|/boot/mach_kernel}} is not necessary anymore.


== See also ==
== See also ==


* '''MacBook Air'''
* [[Laptop/Apple]]
* [[MacBookPro10,x]]
* [[MacBookPro11,x]]
* https://wiki.t2linux.org/
* MacBook Air
** [https://dabase.com/blog/2014/Macbook_Air_Early_2014_Archlinux/ Macbook Air Early 2014 — dabase.com]
** [https://dabase.com/blog/2014/Macbook_Air_Early_2014_Archlinux/ Macbook Air Early 2014 — dabase.com]
** [https://github.com/d4ve01f/ArchLinux-on-MacBook-Air How to install Archlinux on Macbook Air (6,2) — Davide Di Francesco]
** [https://www.nico.schottelius.org/blog/macbook-air-42-archlinux/ Installing Linux on a Macbook Air (4,2) — Nico Schottelius]
** [https://www.nico.schottelius.org/blog/macbook-air-42-archlinux/ Installing Linux on a Macbook Air (4,2) — Nico Schottelius]
** [https://github.com/AdhamNasr/Apple_mba-Arch-i3 MacBook Air (7,2) - Adham Nasr]
** [https://github.com/AdhamNasr/Apple_mba-Arch-i3 MacBook Air (7,2) - Adham Nasr]
* '''MacBook Pro'''
* MacBook Pro
** http://allanmcrae.com/2010/04/installing-arch-on-a-macbook-pro-5-5/
** http://allanmcrae.com/2010/04/installing-arch-on-a-macbook-pro-5-5/
** http://allanmcrae.com/2012/04/installing-arch-on-a-macbook-pro-8-1/
** http://allanmcrae.com/2012/04/installing-arch-on-a-macbook-pro-8-1/

Latest revision as of 23:44, 1 February 2024

This page complements the Installation guide with instructions specific to Apple Macs. The Arch installation image supports Apple Macs with Intel processors, but neither PowerPC nor Apple Silicon processors.

Overview

Summed up, the procedure for installing Arch Linux on a Mac is:

  1. Pre-installation: Miscellaneous steps before partitioning.
  2. Partitions: Resizing or deleting the macOS partition to create partitions for Arch Linux.
  3. Installation: Actual installation.
  4. Setup boot loader: Making sure that the new partition is bootable.
  5. Post-installation: Device-specific configuration.

Pre-installation

Before proceeding with the installation of Arch Linux, follow these steps.

  1. Install macOS and install its updates. macOS is the only known method for installing firmware updates, even though the OS will not be necessary after installing Arch. See Apple's instructions.
  2. Open ColorSync Utility, find the current .icc color profile, and save the file elsewhere. The profile can later be used to set the display colors correctly. See color profile.
  3. Set the volume on macOS, which will be the volume of the startup chime. If the volume is muted, the startup chime will also be muted. See mute startup chime.

Partitions

If only Arch Linux is desired, then format the entire disk according to Installation guide#Partition the disks. To set up dual boot, follow these steps. Once done, go to #Installation.

Arch Linux with macOS or other operating systems

Macs typically have the following partition table. In Macs that use the Apple Fusion Drive, the partition scheme could be different.

  • EFI: the ~200 MB EFI system partition.
  • macOS: the main partition containing your macOS installation, either HFS+ or APFS.
  • Recovery: If not using APFS, a recovery partition is present. If using APFS, this partition is not present.

To install Arch with macOS, keep these partitions, and follow these steps.

  1. You may need to turn off FileVault before resizing the macOS partition. See Apple's instructions.
  2. Run Disk Utility, select the drive to be partitioned in the left-hand column, and click Partition. Do not create a container.
  3. Add a new partition by pressing the + button and choose how much space you want to leave for macOS, and how much for the new partition. The new partition will be formatted in Arch Linux, so you can choose any partition type you want.
  4. Optionally, make any other partitions you may need for your setup. See Partitioning#Partition scheme for more information.

Here is an example setup with five discrete partitions:

partition  mountpoint  size          type  label
/dev/sda1  /efi        200MiB        vfat  EFI
/dev/sda2  -           ?             hfs+  macOS
/dev/sda3  -           ?             hfs+  Recovery
/dev/sda4  -           100MiB        hfs+  Boot Arch Linux from the Apple boot loader (optional)
/dev/sda5  /boot       100MiB        boot  boot
/dev/sda6  -           ?             swap  swap (optional)
/dev/sda7  /           15-20GiB      ext4  root
/dev/sda8  /home       remaining     ext4  home
Note:

Installation

These steps install Arch, assuming #Pre-installation and #Partitions are done.

  1. Boot the live environment by holding down Alt (Option on an Apple keyboard) during boot.
  2. If the keyboard has long delays or character doubling, reboot with the following kernel parameters: arch noapic irqpoll acpi=force.
  3. Proceed through the installation as described in the Installation guide except in the following areas:
    1. Skip the partition the disks stage, do only the partition formatting and mounting steps, taking care to assign the correct partitions. Partitions have already been created if you followed #Partitions
    2. When at the install boot loader stage, follow #Setup boot loader
    3. (for booting with BIOS-compatibility) Add reboot=pci as a kernel parameter. This will allow your Mac to reboot correctly from Arch.
  4. When the install process is complete, reboot your computer.
  5. During boot, if using optical disk, hold down the eject key to eject the disk.
  6. During boot, if using systemd-boot or GRUB, hold down the Alt key to bring up the Apple boot menu, and select "EFI Boot." If using rEFInd, boot without holding any keys.

Setup boot loader

Macs use UEFI for booting, so any UEFI boot loader will work. The built-in boot loader (shown when holding Alt during boot) will detect any EFI system partition that has a /EFI/BOOT/BOOTX64.EFI file, showing it as a "EFI Boot" entry. Most UEFI boot loaders support installing directly to this location, making a dual boot setup easy.

The boot loader also has an alternate partition discovery method described in #Installing a boot loader to a separate HFS+ partition which is the method used for booting macOS, but can also be used for Linux.

Tip:
  • The UEFI firmware on a Mac can also be configured via efibootmgr.
  • To set a volume as the default boot entry using the Apple boot loader, hold down Ctrl while selecting it.

Installing to the EFI system partition

systemd-boot

Follow the instructions at systemd-boot#Installing the UEFI boot manager. After installing, a copy of systemd-boot will be present at /EFI/BOOT/BOOTX64.EFI.

rEFInd

To install rEFInd to the /EFI/BOOT/BOOTX64.EFI location, run:

# refind-install --usedefault /dev/sdXY

Where /dev/sdXY is the EFI system partition. After installing, see rEFInd#Configuration to finish setup.

Installing from macOS

These steps assume macOS is still installed on a partition, and the steps of the Installation guide were completed up to Installation guide#Boot loader. Boot into Safe Mode by holding down Command+R, then disable SIP.

# csrutil disable

Boot macOS, and run the rEFInd install script,

# ./refind-install --alldrivers

rEFInd installed itself into Apple's boot partition, and replaced Apple's boot menu with its own. Boot into Safe Mode by holding down Command+R, and enable SIP.

# csrutil enable

Reboot without holding down any keys. Arch should be recognized as vmlinuz-linux by default. If it is not, uncomment the lines scan_all_linux_kernels and also_scan_dirs in refind.conf. For configuration, see rEFInd#refind_linux.conf. Since rEFInd by default mounts root as ro, it is recommended to create refind-linux.conf.

GRUB

To install GRUB to /EFI/BOOT/BOOTX64.EFI, follow the instructions at GRUB#Installation, adding the --removable option when running grub-install.

Installing a boot loader to a separate HFS+ partition

Despite using UEFI, the Mac native EFI boot loader does not use the EFI system partition for booting macOS. Instead, it uses the following conditions to find existing macOS installations inside all the partitions in internal and external drives and shows them as possible boot options if they are satisfied:

  • The partition is formatted as HFS+
  • The partition type ID is af00 ("Apple HFS/HFS+")
  • In the root of the partition, there is a file called mach_kernel
  • Inside that partition, there a boot.efi file inside /System/Library/CoreServices

The advantage of this method to boot Arch over using a BOOTX64.EFI file in the EFI system partition is that it can coexist with macOS nicely, showing the partition as a bootable volume in the macOS Startup Disk settings. However, this method requires manual configuration. The following steps will illustrate how to perform this configuration using GRUB.

First, create a new HFS+ partition. This can be done through the macOS Disk Utility, or the mkfs.hfsplus tool in the hfsprogsAUR package. The size and mount point of the partition depend on how you plan to use it:

  • If you plan on using it as the /boot directory, give it at least 300 MB;
  • If you are going to keep your kernels in another partition and use a boot loader that can load other file systems, like rEFInd or GRUB, the partition can be smaller and be mounted anywhere you want.

Mount the partition, then create the mach_kernel file:

# touch /mountpoint/mach_kernel

Create the directory structure for the boot loader:

# mkdir -p /mountpoint/System/Library/CoreServices

Now you can install any UEFI boot loader you want. For example, to do a manual install of rEFInd:

# cp -r /usr/share/refind/* /mountpoint/System/Library/CoreServices/
# mv /mountpoint/System/Library/CoreServices/refind_x64.efi /mountpoint/System/Library/CoreServices/boot.efi

Finally, you can create an optional /mountpoint/System/Library/CoreServices/SystemVersion.plist file that will display some information about the volume in the macOS Startup Disk settings:

/mountpoint/System/Library/CoreServices/SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
       <key>ProductBuildVersion</key>
       <string>rolling</string>
       <key>ProductName</key>
       <string>Arch Linux</string>
       <key>ProductUserVisibleVersion</key>
       <string></string>
       <key>ProductVersion</key>
       <string></string>
</dict>
</plist>

After following these instructions, the new volume will appear on the Mac boot loader when holding down Alt during boot, and it will also appear as a bootable volume in the macOS Startup Disk options.

Using blessing

It is possible to boot directly from GRUB in EFI mode without using rEFIt through what is known as "blessing" after placing GRUB on a separate partition. These instructions are known to work on a MacBook7,1. It is advisable to host GRUB on either a FAT32 or HFS+ partition, but ext2 or ext3 may also work.

After the GRUB install is in the desired location, the firmware needs to be instructed to boot from that location. This can be done from either an existing macOS install or an macOS install disk. The following command assumes that the GRUB install is in /efi/grub/ on an existing macOS partition:

# bless --folder /efi/grub --file /efi/grub/grub.efi

Tips and tricks

Color Profile

Macs use ICC profiles which can easily be loaded in Arch. The current profile can be shown using ColorSync Utility or System Preferences > Displays > Color. These files correspond to particular models,

  • Color LCD-4271800.icc for MacBook Pro with CoreDuo CPU
  • Color LCD-4271880.icc for MacBook with Core2Duo
  • Color LCD-4271780.icc for MacBook (non-Pro) based on CoreDuo or Core2Duo.
  • Color LCD-68FE312B-5EF0-E0A1-BCD8-8890B73C7B3A.icc for MacBookPro9,2 (Mid-2012)
Note:
  • The previous command sets the color profile only for the current session. autostart it.
  • GNOME will revert the profile set by xcalib. It is preferable to set the profile using Color in settings.

Apple Remote

Install and configure lirc. See LIRC.

Make LIRC use /dev/usb/hiddev0 or /dev/hiddev0:

/etc/conf.d/lircd
#
# Parameters for lirc daemon
#
LIRC_DEVICE="/dev/usb/hiddev0"
LIRC_DRIVER="macmini"
LIRC_EXTRAOPTS=""
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"

Use irrecord to create a configuration file matching your remote control signals:

# irrecord -d /dev/usb/hiddev0 -H macmini output_conf_file

Start lircd.service and use irw to check if it works.

Alternatively, use the following:

/etc/lirc/lircd.conf
begin remote

  name  lircd.conf.macbook
  bits            8
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  pre_data_bits   24
  pre_data       0x87EEFD
  gap          211994
  toggle_bit_mask 0x87EEFD01

      begin codes
          Repeat                   0x01
          Menu                     0x03
          Play                     0x05
          Prev                     0x09
          Next                     0x06
          Up                       0x0A
          Down                     0x0C
      end codes

end remote

HFS+ Partitions

HFS partition sharing

Install hfsprogsAUR and use fdisk to list the partitions:

# fdisk -l /dev/sda
   Device  Boot     Start         End      Blocks   Id  Type
/dev/sda1               1          26      204819   ee  GPT
/dev/sda2              26       13602   109051903+  af  Unknown
/dev/sda3   *       13602       14478     7031250   83  Linux
/dev/sda4           14478       14594      932832+  82  Linux swap / Solaris

The "Unknown" partition is our macOS partition, which is located in /dev/sda2. We can use this in our fstab:

/etc/fstab
/dev/sda2    /path/to/shared/hfs_partition     hfsplus auto,user,rw,exec   0 0

It can then be mounted, and the content accessed.

Bad Superblock Error

This section addresses error message when mounting hfsplus partition:

# mount -t hfsplus dev/sdX force,ro
wrong fs type, bad option, bad superblock on /dev/sdX, missing codepage or helper program, or other error.

Since Yosemite, HFS+ partitions are now wrapped a CoreStorage volume. Verify that you have an CoreStorage volume.

# fdisk -l /dev/sdX
Disk /dev/sdX: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1* 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Device      Start      End         Sectors    Size     Type
/dev/sdX1   40         409639      409600     200M     EFI System
/dev/sdX2   409640     623872871   623463232  297.3G   Apple Core storage
/dev/sdX3   623872872  625142407   1269536    916.0M   Apple boot

HFS+ uses two volume headers, one 1024 bytes into the device and one 1024 from the end of the device. With the HFS+ partition wrapped in the CoreStorage volume the end of the partition is not actually 1024 bytes from the end of the /dev/sdX2 partition. To fix this you need to specify sizelimit=X when mounting.

To determine sizelimit do the following:

  1. Run testdisk /dev/sdX and select your drive
  2. Select EFI GPT
  3. Select Analyse and then Quick Search

Sample output:

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

Disk /dev/sdX  - 320 GB / 298 GiB - CHS 38913 255 63
    Partition     Start      End        Size in sectors
P  EFI System     40         409639     409600  [EFI]
P  Mac HFS        409640     623147815  622738176
P  Mac HFS        623872872  625142407  1269536

What you see now is the output of the HFS partition itself without the CoreStorage volume. Take the size in sectors (622738176 in this example) and multiply by the number of bytes in your logical sector size (512 in this example).

622738176 * 512 = 318841946112

Finally, mount your disk with the sizelimit=X option.

 mount /dev/sdX -t hfsplus -o ro,sizelimit=318841946112

Disable Journaling

HFS+ partitions are not fully supported by Linux and are mounted as read-only by default. In order to write to an HFS+ partition, the safe way is to disable journaling. This can be accomplished using the macOS Disk Utility. Refer to this Apple support page for more information or try to do it from the command line:

Find your partition:

# diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS macOS                   149.5 GB   disk0s2
   3:                  Apple_HFS Macintosh HD            599.2 GB   disk0s3
   4:                 Apple_Boot Recovery HD             650.0 MB   disk0s4

In this example we will use disk0s3 partition named as Macintosh HD. To know if journaling is activate or not you could execute:

# diskutil info /dev/disk0s3 | grep -i journal
    File System Personality:  Journaled HFS+
    Name (User Visible):      Mac OS Extended (Journaled)
    Journal:                  Journal size 49152 KB at offset 0x1176000

As you can read the journaling is active. To turn off the journaling you could execute:

# diskutil disableJournal disk0s3

To verify it is done execute the info command again.

If you get noting as output, then journaling is disabled.

However, if you fail to disable journaling. You can change "auto,user,rw,exec" in /etc/fstab to "auto,user,force,rw,exec" and mount it.

UID synchronization for home sharing

If you want to access your macOS user directories from Linux, write down the UID and GID for the users. macOS begins with the first user's UID at 501 while Arch defaults to 1000.

Warning: Never change any file permissions in your macOS partition from Linux.

In macOS

Note: It is strongly recommended that UID/GID manipulation be done immediately after a new user account is created, in macOS as well as in Arch Linux. If you installed macOS from scratch, then this operation is guaranteed to work after logging into your account for the first time.
Change UID and GID(s)

The default UID and GID on Arch Linux for a user is 1000, adjust the following steps according to your setup.

Pre-Leopard
  1. Open NetInfo Manager located in the /Applications/Utilities folder.
  2. If not done for you already, enable access to user account transactions by clicking on the closed lock at the bottom of the window, and entering your account password, or root password if you have created a root account.
  3. Navigate to /users/new_user_name
  4. Change the UID value to 1000
  5. Change the GID value to 1000
  6. Navigate to /groups/new_user_name, automatically saving the changes you have made so far.
Note: If you get an error message that the transaction is not allowed, log out and log back in.
Leopard

In Leopard, the NetInfo Manager application is not present. A different set of steps is required for UID synchronization:

  1. Open System Preferences.
  2. Click on Users & Groups.
  3. Unlock the pane if not already done so.
  4. Right-click on the desired user and select Advanced Options.
  5. Write down the value of the User ID field, you will need it later on. Change both the UID and GID to match the UID and GID of the account to be shared with in Arch.
Change "Home" permissions
  1. Open up Terminal in the /Applications/Utilities folder.
  1. Enter the following command to reclaim the permission settings of your home folder:
# find /User/your_user_name -user your_old_UID -exec chown your_user_name:your_user_group {} \;

In Arch

To synchronize your UID in Arch Linux, you are advised to perform this operation while creating a new user account. It is therefore recommended that you do this as soon as you install Arch Linux.

# useradd -m -u [uid] -g [gid] -G [additional_groups] -s [login_shell] [username]

Now you must substitute Arch's home with macOS's home, by modify entries of /etc/fstab. In order to be able to access a macOS user's directory, only the uid and gid need to match (usernames can differ).

Mute startup chime

The startup chime volume is controlled by the EFI variable SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82. So it can be muted with

# printf "\x07\x00\x00\x00\x00" > /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82

Bear in mind that the file may have the immutable bit set by default, which will prevent even root from overwriting the file. See File permissions and attributes#File attributes. To remove it, issue the following:

# chattr -i /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82

After that, run the printf command and it should overwrite the file properly. Verify the file's contents and then set the immutable bit again with chattr +i once satisfied.

Alternatively, you can use a macOS install disk to mute the chime. Boot from it, select language, then click Utilities > Terminal, and enter

# /usr/sbin/nvram SystemAudioVolume=%percentage
Note: Required formatting of the value provided for key SystemAudioVolume may differ depending on models and perhaps the version of macOS install media. If the above command fails to work, try enclosing the value in double quotes.

Custom icon in the boot loader

The Mac boot loader supports loading custom icons for each volume it detects. The custom icon must be in the .icns format, and be located at the root of the volume containing the boot loader, with the file name .VolumeIcon.icns.

The following example downloads an Arch logo SVG with wget, converts it to PNG with librsvg and then converts it to an .icns with libicns:

$ wget -O /tmp/archlinux.svg https://archlinux.org/logos/archlinux-icon-crystal-64.svg
$ rsvg-convert -w 128 -h 128 -o /tmp/archlogo.png /tmp/archlinux.svg
# png2icns /boot/.VolumeIcon.icns /tmp/archlogo.png

Obviously, you can replace the Arch logo with any other icon you like.

See also