Apple - How can I create a bootable drive for ArchLInux on macOS?
There is no command in macOS to format a partition to use a linux file system. In other words, there is no equivalent for the Arch Linux mkfs.ext4
command. There are many possible solutions to this problem. Below is one such solution.
I propose that the best way, to accomplish the creation of the bootable drive, is to boot the Arch Linux operation system on your Mac. This will allow you to use the commands shown in the web link you provided. This boot of Arch Linux will be done from a 1 GB or larger flash drive. The advantage to using a flash drive is that you will not have to install Arch Linux on any of your internal drives.
Manual Approach to Creating a Mac Bootable Arch Linux Flash Drive
Note: You can copy and paste each command below into the Terminal application window. This will reduce the amount of typing and the risk of type errors.
- Download an
.iso
file. The Mac compatible file I chose to download is namedarchlinux-2017.12.01-x86_64.iso
. You can find this file at this Arch Linux web site. This file was downloaded to my "Downloads" folder. I will assume you will do the same. Open a Terminal application window. Enter the following command to navigate to your "Downloads" folder.
cd ~/Downloads
Convert this
.iso
file to a format that is compatible with flash drives. The command below accomplishes this task.hdiutil convert archlinux-2017.12.01-x86_64.iso -format UDRW -o target.img
The
.dmg
characters may be appended to the output file name. Enter the following command to check if this occurred.ls target.img.dmg
If file named
target.img.dmg
appears, then enter the next command to rename this file.mv -f target.img.dmg target.img
Enter the command below to get a before list of drives.
ls /dev | egrep ^disk\\d+$
Insert your flash drive.
Enter the command below again to get an after list of drives. Next, determine the identifier assigned to your flash drive (e.g. The identifier that did not appear in step 5)
ls /dev | egrep ^disk\\d+$
Note: In the subsequent steps, replace
diskN
with the identifier assigned to the flash drive.Enter the command below to unmount the flash drive.
diskutil unmountdisk diskN
Note: If you see the error
Unmount of diskN failed: at least one volume could not be unmounted
, open the Disk Utility application and unmount the volume(s) (don't eject).Enter the command below to copy
target.img
to your flash drive.sudo dd if=target.img bs=1m of=/dev/diskN
Note the following:
- This command will require you to enter your login password.
- To view the progress of the copy operation, press the control+T key, while the command is executing.
- Using
/dev/rdisk
instead of/dev/disk
may be faster. - If you see the error
dd: Invalid number '1m'
, you are using the GNUdd
command. Use the same command but replacebs=1m
withbs=1M
. - If you see the error
dd: /dev/diskN: Resource busy
, make sure the drive is not in use. Open the Disk Utility application and unmount the volume(s) (don't eject).
When the 'dd' command completes, you will receive the following pop up message. You should select "Ignore".
Note: The the disk (flash drive) is readable by your computer. The message should have said: "The disk you inserted was not readable by macOS."
To continue to the next part of this procedure, you will need to leave the flash drive plugged in. If you do need to eject the flash drive, you can either use the Disk Utility application or enter the command given below.
diskutil eject /dev/diskN
Initialization of the Micro SD Card
The instructions, you referenced, assume the micro SD card is either uninitialized or has been MBR initialized with no partitions. You may want to preform the following steps to insure your micro SD card is properly initialized.
Enter the command below to get a before list of drives.
ls /dev | egrep ^disk\\d+$
Using the adapter, plug the micro SD card into the Mac.
Enter the command below again to get an after list of drives. Next, determine the identifier assigned to your micro SD card (e.g. The identifier that did not appear in step 1)
ls /dev | egrep ^disk\\d+$
Note: In the subsequent steps, replace
diskN
with the identifier assigned to the micro SD card.Enter the following command to initialize the micro SD card.
diskutil partitiondisk diskN 1 mbr free none r
Enter the command below to unmount the micro SD card.
diskutil eject diskN
Boot Your Mac to Arch Linux
- If the Mac bootable Arch Linux flash drive is not plugged in, do so now.
- Restart your Mac and immediately hold down the option key, until the Startup Manager appears.
- Select the icon labeled "EFI Boot", then select the arrow below the label.
- Select "Arch Linux archiso x86_64 UEFI CD" or wait for this to happen automatically.
A Note About Drive Identifiers
Hardware used by machines running the Linux, Unix, macOS and legacy OS X operating systems are given character string device identifiers. In the context of your question, we are only dealing with devices that are drives. The macOS operating system uses diskN
to identify HDD, SSD, SD cards, micro SD cards, USB flash drives, etc. The value N
is some integer greater than zero. The Arch Linux operating system uses a different scheme. Here, the form of the drive identifier is sdX
, where X
is a lower case letter in the English alphabet.
Micro SD Card Creation
Note: Since you are booting to a "Live" version of Arch Linux, I made some changes to the procedure you referenced.
- Insert a micro SD card into your computer and record which device identifier it is (
dmesg | tail
) - Make sure it's not mounted (
umount /dev/sdX*
orumount /dev/mmcblk*
) Start
fdisk
to partition the SD card:fdisk /dev/sdX
At the
fdisk
prompt, create the new partitions:a. Type
n
, thenp
for primary,1
for the first partition on the drive, the return key to accept the default starting sectors, and+100M
for the ending sector.b. Type
t
to set the type, thenc
to set it to FAT.c. Type
n
, thenp
for primary,2
for the second partition, and press the return key twice to accept default values.d. Exit by typing
w
.Create and mount the vfat filesystem:
mkfs.vfat /dev/sdX1 mkdir boot mount /dev/sdX1 boot
Create and mount the ext4 filesystem:
mkfs.ext4 /dev/sdX2 mkdir root mount /dev/sdX2 root
Download and extract the root filesystem:
cd ~/root wget http://os.archlinuxarm.org/os/ArchLinuxARM-utilite-latest.tar.gz cd ~ bsdtar -xpf root/ArchLinuxARM-utilite-latest.tar.gz -C root rm root/ArchLinuxARM-utilite-latest.tar.gz
Copy boot files to the boot partition:
cp root/boot/* boot
Unmount the partitions:
umount boot root
Remove the micro SD card from your computer and insert it into the Utilite on the front panel