In this guide, we will walk you through the process of safely labeling an APFS drive for dual-booting macOS and Linux without data loss. This procedure is essential for Mac users who want to install Linux alongside macOS and access both operating systems using the same drive.
Prerequisites
Before we begin, ensure that your Mac disk is properly labeled in the file manager. If you have already renamed the volume, you can proceed with the following steps.
Step 1: Create a Linux Partition
To dual-boot macOS and Linux, you need to create a separate partition for Linux. Use a Linux live USB or CD to boot your Mac and start the partitioning process.
Using GParted
Open the GParted application and identify the APFS drive you want to partition. Right-click on the unallocated space and select "New." Set the size of the new partition according to your preference, then format it as ext4.
sudo fdisk /dev/sda # Replace /dev/sda with your drive name
n # Press Enter to create a new partition
p # Press Enter to create a primary partition
1 # Press Enter to set the first partition
+ # Set the size of the new partition
t # Change the partition type to Linux (ext4)
w # Write the changes to the disk and exit
Using fdisk
Alternatively, you can use the fdisk command to create a new Linux partition. Open the terminal and type:
sudo fdisk /dev/ # Replace with your drive name
n # Press Enter to create a new partition
p # Press Enter to create a primary partition
1 # Press Enter to set the first partition
+ # Set the size of the new partition
t # Change the partition type to Linux (ext4)
w # Write the changes to the disk and exit
Step 2: Install GRUB Bootloader
After creating the Linux partition, you need to install the GRUB bootloader to manage the boot menu. Boot your Mac using the macOS installation media and open the terminal:
sudo fdisk /dev/ # Replace with your macOS drive name
a # Add a new partition to the bootloader
# Replace with the number of the macOS partition
t # Change the partition type to C (Wintel)
w # Write the changes to the disk and exit
sudo grub-install --force --boot-directory=/boot/efi --target=x86_64-efi /dev/ # Replace with your macOS drive name
Step 3: Label APFS Drive
Now that you have created the Linux partition and installed the GRUB bootloader, you can label the APFS drive for macOS. Open the Disk Utility application:
sudo diskutil rename # Replace with the current name of the APFS drive and with the desired name
Step 4: Update EFI Bootloader
Finally, you need to update the EFI bootloader to include the Linux partition. Boot your Mac using the Linux live USB or CD and open the terminal:
sudo mkdir /boot/efi/EFI/ # Replace with the name of the Linux distribution (e.g., Ubuntu)
sudo mount /dev/ /mnt
sudo cp -R /mnt/EFI/* /boot/efi/EFI// # Replace with the number of the Linux partition
sudo umount /mnt
- Create a Linux partition using a Linux live USB or CD
- Install the GRUB bootloader on the macOS partition
- Label the APFS drive for macOS using Disk Utility
- Update the EFI bootloader to include the Linux partition
With these steps, you have successfully labeled an APFS drive for dual-booting macOS and Linux without data loss.