Author: Rohan Barar
Date: 03/09/2023
The following is based on this guide.
-
Download
rEFIndfrom here. Choose to download the binary zip file version. Note that the version used at the time of writing wasv0.14.0.2. -
Disable SIP (System Integrity Protection). This is required to modify the EFI partition.
- Reboot into recovery mode (hold
Command (⌘) + Ron boot). - Run
csrutil disablein the terminal. - Reboot.
- Reboot into recovery mode (hold
-
Install
rEFIndin the EFI partition.-
Mount the EFI partition.
sudo mkdir /Volumes/EFI sudo mount -t msdos /dev/disk0s1 /Volumes/EFI
-
Create a new
rEFIndfolder on the EFI partition.cd /Volumes/EFI/EFI sudo mkdir REFIND -
Copy the contents of the following folders (NOT the folders themselves) into this new folder.
-
refind/drivers_x64/ -
refind/icons/ -
refind/tools_x64/sudo cp -r ~/Desktop/refind-bin-0.14.0.2/refind/drivers_x64/ /Volumes/EFI/EFI/REFIND sudo cp -r ~/Desktop/refind-bin-0.14.0.2/refind/icons/ /Volumes/EFI/EFI/REFIND sudo cp -r ~/Desktop/refind-bin-0.14.0.2/refind/tools_x64/ /Volumes/EFI/EFI/REFIND
-
-
Copy
refind/refind_x64.efiandrefind/refind.conf-sampleinto this new folder as well.sudo cp ~/Desktop/refind-bin-0.14.0.2/refind/refind_x64.efi /Volumes/EFI/EFI/REFIND sudo cp ~/Desktop/refind-bin-0.14.0.2/refind/refind.conf-sample /Volumes/EFI/EFI/REFIND
-
Rename
refind.conf-sampletorefind.conf.sudo mv refind.conf-sample refind.conf -
Edit
refind.conf.- Can add
default_selection Prebootto set booting into macOS as the default option. - Can change
timeout 20totimeout 5to reduce the timeout to 5 seconds before booting the default selection.
- Can add
-
Bless
rEFInd.sudo bless --mount /Volumes/EFI --setBoot --file /Volumes/EFI/EFI/REFIND/refind_x64.efi --shortform
-
-
Enable SIP (System Integrity Protection).
- Reboot into recovery mode (hold
Command (⌘) + Ron boot). - Run
csrutil enablein the terminal. - Reboot.
- Reboot into recovery mode (hold
Note: Whenever you install a new OS or OS updates, one of the operating systems may incorrectly determine that your EFI boot selection is broken and that it 'needs to be fixed'. When this happens, the mac will boot directly into that OS and will skip rEFInd.
- Disable SIP.
- Restart and hold down
Option (⌥). This has the effect of invoking the default bootloader, thereby bypassing the broken EFI settings. - Select the macOS partition to boot from.
- In terminal, run the following:
sudo mkdir /Volumes/EFI sudo mount -t msdos /dev/disk0s1 /Volumes/EFI sudo bless --mount /Volumes/EFI --setBoot --file /Volumes/EFI/EFI/REFIND/refind_x64.efi --shortform
- Enable SIP.
-
Run
diskutil list./dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *251.0 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_APFS Container disk1 250.8 GB disk0s2 /dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +250.8 GB disk1 Physical Store disk0s2 1: APFS Volume Apple SSD - Data 54.2 GB disk1s1 2: APFS Volume Preboot 584.7 MB disk1s2 3: APFS Volume Recovery 624.2 MB disk1s3 4: APFS Volume VM 1.1 MB disk1s4 5: APFS Volume Apple SSD 15.3 GB disk1s5 6: APFS Snapshot com.apple.os.update-... 15.3 GB disk1s5s1 -
Consider the amount of space you would like to dedicate to Debian. Ensure you account for the additional space a Swap partition.
-
Shrink the APFS container to the desired size. In this case, we will shrink the APFS container
disk0s2to a size of180 GiB. Note that you can specify whether to use gigabytes withgor gibibytes withgi.sudo diskutil apfs resizeContainer disk0s2 180gi
-
Confirm the desired changes have been made using
diskutil list./dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *251.0 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_APFS Container disk1 193.3 GB disk0s2 (free space) 57.5 GB - /dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +250.8 GB disk1 Physical Store disk0s2 1: APFS Volume Apple SSD - Data 54.2 GB disk1s1 2: APFS Volume Preboot 584.7 MB disk1s2 3: APFS Volume Recovery 624.2 MB disk1s3 4: APFS Volume VM 1.1 MB disk1s4 5: APFS Volume Apple SSD 15.3 GB disk1s5 6: APFS Snapshot com.apple.os.update-... 15.3 GB disk1s5s1
- Prepare a Debian amd64 install USB.
- Restart and hold down
Option (⌥). SelectEFI Boot.- Note: If using
Ventoy, ensure the.isois booted ingrub2 modeinstead ofnormal mode.
- Note: If using
- Once at the
GRUBbootloader, add the kernel argumentintel_iommu=off. This is required so that the Debian installer can see the internal SSD.-
Press
eon the keyboard with theInstalloption highlighted inGRUB. This will open the boot option for editing. -
Add
intel_iommu=offto thelinuxentry. For example:setparams 'Install' set background_color=black linux /install.amd/vmlinuz vga=788 intel_iommu=off --- quiet initrd /install.amd/initrd.gz -
Press
F10to boot using the modified entry.
-
- Partition disks:
- Select
Manualfor the partitioning method. - Select the
FREE SPACEon the internal SSD and create an8GBswap areapartition. - Select the remaining
FREE SPACEon the internal SSD and create anExt4 journaling file systemat the mount point/namedDebian. - Select
Finish partitioning and write changes to disk.
- Select
We do not currently have any WiFi drivers installed. Assuming you do not have access to an ethernet-to-thunderbolt adapter, connect your mobile phone via USB to the computer and enable USB Tethering on the phone to share the phone's internet connection with the computer. This worked flawlessly using a Samsung Galaxy S22.
We need to edit the GRUB configuration file so that intel_iommu=off does not need to be specified manually at each boot.
- Open
/etc/default/grub. - Find the line starting with
GRUB_CMDLINE_LINUX_DEFAULT. Modify this to includeintel_iommu=off. For example:GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=off" - Run
sudo update-grub.
Since Debian was installed without an internet connection, the system lacks a list of sources.
- Open
/etc/apt/sources.list. - Comment out the first line (starting with
deb cdrom:) by appending a#at the start of the line. - Add the following lines to the file:
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware deb http://security.debian.org/ bookworm-security non-free contrib main non-free-firmware deb http://deb.debian.org/debian/ bookworm-updates non-free contrib main non-free-firmware deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware - Run
sudo apt update && sudo apt upgrade.
sudo apt install broadcom-sta-dkmsNote: Although these steps worked for people with the same or similar hardware online, I was unable to get this completely working. The webcam only 'partially' works when using Qt V4L2 test Utility. The video feed is blown out, distorted and completely unusable. Although the webcam is detected as Apple Facetime HD by other applications, they all fail to display the video feed entirely.
-
Check if the webcam is detected using
lspci.sudo lspci -v | grep BroadExpected output:
02:00.0 Multimedia controller: Broadcom Inc. and subsidiaries 720p FaceTime HD Camera Subsystem: Broadcom Inc. and subsidiaries 720p FaceTime HD Camera 03:00.0 Network controller: Broadcom Inc. and subsidiaries BCM4360 802.11ac Wireless Network Adapter (rev 03)Here, the webcam is detected as
720p FaceTime HD Camera. -
Create a folder named
facetimehdinside/usr/lib/firmware/.sudo mkdir /usr/lib/firmware/facetimehd
-
Place the following inside a new file named
install_facetime_camera.sh. This bash script was originally obtained from here.#!/bin/bash set -e export CONFIG_MODULE_SIG=n export CONFIG_MODULE_SIG_ALL=n # For current kernel export KERNELRELEASE=$(cat /proc/version | awk '{print $3}') temp_dir=$(mktemp -d) echo "Installing FacetimeHD camera for $KERNELRELEASE" cd $temp_dir git clone https://github.com/patjak/facetimehd-firmware.git git clone https://github.com/patjak/bcwc_pcie.git cd $temp_dir/facetimehd-firmware pwd make make install cd $temp_dir/bcwc_pcie pwd make make install rm -rf $temp_dir if [ ! -d "/etc/modules-load.d" ]; then mkdir -p "/etc/modules-load.d" fi cat > "/etc/modules-load.d/facetimehd.conf" << EOL videobuf2-core videobuf2_v4l2 videobuf2-dma-sg facetimehd EOL # Workaround for depmod being skipped above with error: # Warning: modules_install: missing 'System.map' file. Skipping depmod echo "Generate modules.dep and map files" sudo depmod echo "Adding kernel modules" sudo modprobe -r bdc_pci sudo modprobe facetimehd echo "Install complete"
-
Make the script executable using
chmodand run it.chmod +x install_facetime_camera.sh sudo ./install_facetime_camera.sh
Expected output:
Installing FacetimeHD camera for 6.1.0-11-amd64 Cloning into 'facetimehd-firmware'... remote: Enumerating objects: 899, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (9/9), done. remote: Total 899 (delta 5), reused 12 (delta 5), pack-reused 885 Receiving objects: 100% (899/899), 294.35 KiB | 4.39 MiB/s, done. Resolving deltas: 100% (590/590), done. Cloning into 'bcwc_pcie'... remote: Enumerating objects: 1148, done. remote: Counting objects: 100% (65/65), done. remote: Compressing objects: 100% (32/32), done. remote: Total 1148 (delta 41), reused 46 (delta 33), pack-reused 1083 Receiving objects: 100% (1148/1148), 415.53 KiB | 5.01 MiB/s, done. Resolving deltas: 100% (768/768), done. /tmp/tmp.u7XlGZByq0/facetimehd-firmware Checking dependencies for driver download... /usr/bin/curl /usr/bin/xzcat /usr/bin/cpio Downloading the driver, please wait... Found matching hash from OS X, El Capitan 10.11.5 ==> Extracting firmware... --> Decompressing the firmware using gzip... --> Deleting temporary files... --> Extracted firmware version 1.43.0 Copying firmware into '//usr/lib/firmware/facetimehd' /tmp/tmp.u7XlGZByq0/bcwc_pcie make -C /lib/modules/6.1.0-11-amd64/build M=/tmp/tmp.u7XlGZByq0/bcwc_pcie modules make[1]: Entering directory '/usr/src/linux-headers-6.1.0-11-amd64' CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_ddr.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_hw.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_drv.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_ringbuf.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_isp.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_v4l2.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_buffer.o CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/fthd_debugfs.o LD [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/facetimehd.o MODPOST /tmp/tmp.u7XlGZByq0/bcwc_pcie/Module.symvers CC [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/facetimehd.mod.o LD [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/facetimehd.ko BTF [M] /tmp/tmp.u7XlGZByq0/bcwc_pcie/facetimehd.ko Skipping BTF generation for /tmp/tmp.u7XlGZByq0/bcwc_pcie/facetimehd.ko due to unavailability of vmlinux make[1]: Leaving directory '/usr/src/linux-headers-6.1.0-11-amd64' make -C /lib/modules/6.1.0-11-amd64/build M=/tmp/tmp.u7XlGZByq0/bcwc_pcie modules_install make[1]: Entering directory '/usr/src/linux-headers-6.1.0-11-amd64' INSTALL /lib/modules/6.1.0-11-amd64/extra/facetimehd.ko DEPMOD /lib/modules/6.1.0-11-amd64 Warning: modules_install: missing 'System.map' file. Skipping depmod. make[1]: Leaving directory '/usr/src/linux-headers-6.1.0-11-amd64' Generate modules.dep and map files Adding kernel modules modprobe: FATAL: Module bdc_pci not found. -
Manually run
sudo modprobe facetimehdsince the script fails atsudo modprobe -r bdc_pci. This error can be ignored, as it simply means the kernel did not have thebdc_pcimodule installed in the first place, so attempting to unload it would obviously fail.sudo modprobe facetimehd
-
Confirm the kernel module has been installed.
find /lib/modules/$(uname -r) -type f -name '*.ko' | grep facetime
Expected output:
/lib/modules/6.1.0-11-amd64/extra/facetimehd.koNote: The kernel version may differ.
-
Install the sensor calibration files. This step is optional, but helps avoid the
facetimehd 0000:02:00.0: firmware: failed to load facetimehd/1871_01XX.dat (-2)error on system startup. The instructions to do this were originally obtained from here.- Download
Boot Camp Support Software 5.1.5769from here. - Unzip the downloaded archive.
- Navigate to
BootCamp/Drivers/Apple/. - Run
unrar x AppleCamera64.exe. - Run the following commands to extract the calibration files from
AppleCamera.sys:dd bs=1 skip=1663920 count=33060 if=AppleCamera.sys of=9112_01XX.datdd bs=1 skip=1644880 count=19040 if=AppleCamera.sys of=1771_01XX.datdd bs=1 skip=1606800 count=19040 if=AppleCamera.sys of=1871_01XX.datdd bs=1 skip=1625840 count=19040 if=AppleCamera.sys of=1874_01XX.dat
- Confirm the SHA-256 hashes match using
sha256sum(e.g.sha256sum '/home/user/Desktop/1871_01XX.dat').9112_01XX.dat:4dd756fa8460d8dc3d78d0d76944b2f92275d1fe9c83181bbc8292c81c005f1a1771_01XX.dat:756c2bb7c5e55b395449e43a0be1cb7c40c37dfc6c2b5abfaffb8ae70ff0fc4b1871_01XX.dat:bf36fbde0668ab7e44368b584f9fa64b5945b01003d04c6e3c6f22c0be0fd5f31874_01XX.dat:ffde89e7819ac16a9eb1c8f0bc6dba0e980b508b2022507679d901c190f7cef8
- Copy the calibration files to the firmware directory:
sudo cp ~/Desktop/9112_01XX.dat /lib/firmware/facetimehd/sudo cp ~/Desktop/1771_01XX.dat /lib/firmware/facetimehd/sudo cp ~/Desktop/1871_01XX.dat /lib/firmware/facetimehd/sudo cp ~/Desktop/1874_01XX.dat /lib/firmware/facetimehd/
- Download
-
Add
facetimehdto/etc/modules.sudo nano /etc/modules
-
Shut down and then power on the system (restarting does not work).
-
Test the webcam using
Qt V4L2 test Utility.
The following is based on this and this.
Attempting to delete the Debian and swap partitions from inside macOS can render the entire system unbootable. This happened to me when I wanted to restart the entire installation process. A partition of the correct size with an APFS filesystem was visible using GParted and diskutil, but the system failed to boot from this partition.
This issue appears to be due to the corrupting of the APFS container GUID, and can be fixed from a terminal instance running from a bootable macOS Big Sur recovery USB.
- Run
gpt -r show /dev/disk0.gpt show: disk0: Suspicious MBR at sector 0 start size index contents 0 1 MBR 1 1 Pri GPT header 2 32 Pri GPT table 34 6 40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B 409640 348937392 2 GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF 349347032 140887687 490234719 32 Sec GPT table 490234751 1 Sec GPT header
Notice the FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF. For APFS containers, this should be 7C3457EF-0000-11AA-AA11-00306543ECAC.
-
NOTE DOWN THE ABOVE OUTPUT!!! The start positions, sizes and indices of the partitions will be required later.
-
Unmount the disk.
diskutil unmountDisk /dev/disk0
-
Remove the problematic partition.
gpt remove -i 2 /dev/disk0
-
Attempt to recreate the problematic partition by using the parameters noted down in step 2 alongside the correct GUID.
gpt add -b 409640 -s 348937392 -i 2 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk0
If this worked, you are done! If instead you received:
gpt add: disk0: Suspicious MBR at sector 0
gpt add: disk0: error: no space available on device
Then you need to complete a few more steps...
-
Ensure the disk is still unmounted.
diskutil unmountDisk /dev/disk0
-
Destroy the GPT.
gpt destroy /dev/disk0
-
Overwrite the MBR with zeroes.
dd if=/dev/zero count=1 of=/dev/disk0
-
Create new MBR and GUID partition tables.
gpt create -f /dev/disk0
-
Add the previous partitions back using the parameters noted down in step 2 alongside the correct GUID. Here, we first add the EFI partition and then the APFS container.
gpt add -b 40 -s 409600 -i 1 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk0 gpt add -b 409640 -s 348937392 -i 2 -t 7C3457EF-0000-11AA-AA11-00306543ECAC /dev/disk0
-
Reboot the system.
-
(Optional) Using disk utility, resize the APFS container to reclaim any free space left over after deletion of the Debian partitions.