Installing recent CentOS versions on Macs is not as straight forward as I wish it to be. I repeatedly had issues even getting the installation media to boot. In this snippet I gather my findings and present a way to successfully install CentOS on a Mac.
Tested using CentOS Stream 8 on a Late 2014 Mac Mini.
When using the usual methods of creating a bootable USB drive (e.g. by using balenaEtcher) I was greeted by a black screen. In order to successfully get to the CentOS installer I did the following things:
- Format the USB drive
- Copy the ISO onto the USB drive
- Replace the EFI boot file
- Edit
grub.cfg
- Copy
repair-grub.sh
andmount-lvm.sh
to the USB drive
This step is mainly necessary in order to be able to modify files on the USB drive in macOS. By default the system wasn't able to read the filesystem of the CentOS ISO or the drive created by Etcher. If you are using a Linux machine you can probably skip steps 1.1 and 1.2 and instead copy the contents of the ISO to the USB drive using dd
.
On a Mac however I erased the USB drive using Disk Utility:
- Choose a name for the volume. This name will be important later. This name will be referred to as
<USB>
. - Format the volume with a FAT filesystem
- Use the GUID partition table (apparently some macs are especially picky about this setting).
Edit the create-ush.sh
script with your <USB>
name and the location of the CentOS ISO file. Then run the script. The script will perform the following actions in a docker container:
- Mount the ISO
- Copy its contents to the installation media
- Create a EFI boot image that does not result in a black screen but actually gets you into grub.
- Fix the
grub.cfg
file to use your<USB>
name. By default it expects a certain name for the volume, depending on the ISO you used.
Copy the contents of repair-grub.sh
and mount-lvm.sh
onto the installation media. We will use them in step 3. Alternatively you type the commands in the script manually in step 3.
Remember to adjust the values in mount-lvm.sh
to your environment.
Installing CentOS is relatively straight forward. However we have to do some custom partitioning. Here are the relevant steps, slightly adjusted:
- Select your disk
- At the bottom, click the "Full disk summary and boot loader" text
- Click on the disk in the list
- Click "Do not install boot loader"
- Close
- Select "Custom" (I didn't try automatic, but it probably would not create the EFI partition)
- Done in the top left to get to the partitioning screen
- Delete existing partitions if needed
- Click +
- Create /foo mountpoint, 600M, Standard partition, then edit the partition to be on /boot/efi and change the file system to 'EFI System Partition'.
- Click + repeatedly to create the rest of the partitions as usual (
/boot
,/swap
,/home
, etc.). - Done
In my case the package installation from install media was not possible. Instead I used a package repository URL as the installation source, more specifically http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
.
When starting the installation there will be an error about a missing mactel-boot
package. Ignore the error and continue the installation.
When the installation finishes the system is not quite usable yet. We need to fix two things:
- Reinstall grub (to avoid the booting-to-black-screen problem)
- Create a
grub.cfg
.
To do this, boot from the installation media again and enter the rescue mode.
- Choose 1 to mount the system on
/mnt/sysimage
. If you chose to use a LVM root partition there may be an error that no linux filesystem could be found. Runbash /mnt/install/repo/mount-lvm.sh
to fix this issue. This is themount-lvm.sh
script copied in step 1.5. Alternatively you can type the commands from the script manually. - Run
bash /mnt/install/repo/repair-grub.sh
. This is therepair-grub.sh
script from step 1.5. Alternatively you can type the commands from the script manually. - Exit the rescue mode and reboot the machine. It should reboot once after SELinux relabelling and then boot into CentOS.
First of all - thanks for putting this together.
When running the create-usb.sh, I received the error
[Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist]
After some research, I found the solution here:
(https://stackoverflow.com/questions/70963985/error-failed-to-download-metadata-for-repo-appstream-cannot-prepare-internal)
I added
before the first yum install and the script finished w/o errors.
I can boot the installer from the USB, but I also could not get packages installed from the installation media. My problem is that I cannot use a package repository URL, as my Network devices are not detected by the installer (Nvidia MCP79 and Broadcom 4321). It's a late 2009 Mac Mini. Not sure I will get that resolved.