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.
Thanks for your installation guide. I have managed to install the OS into my 2015 13’ MBP.
However, when I was trying to execute the following command:
yum install -y grub2-efi-x64-modules
I got the following error
Subsequent commands also failed because
/usr/lib/grub/x86_64-efi/modinfo.sh
doesn’t exist. I believe it is due to the missing module above.I have little experience in dealing with bootloaders, so I really don’t know what’s gone wrong after hours of searching.
Do you have any idea what I have done wrong? What should I try instead? Thank you!
FYI:
The MBP uses a 3rd party 500GB NVMe SSD. Partitions as follow:
EFI: 600MB EFI
BOOT: 1GB ext4
/: rest of the drive ext4
SWAP: 16GB
None is set as a LVM partition.
I wrote the CentOS installer image onto a 120GB external SSD using your method. So there is definitely more than 60MB of space in my external SSD.
I have also tried
df -h
and found that/dev/mapper/live-rw
mounted on/
still has 442M available.