I am trying to format my SD card on a mac (macOS Mojave 10.14.6)
I am using a card reader hooked up to the computer and the SD card adapter is on the unlocked position. My SD card is a samsung evo 32GB.
This is what the terminal looks like, its a modified archlinux script:
Deannes-MBP:~ dena$ SD_CARD=/dev/disk2s1
Deannes-MBP:~ dena$ echo "o p n p 1 +100M t c n p 2 w"| fdisk $SD_CARD
fdisk: /dev/disk2s1: Permission denied
I also tried this to have a look:
ls -l /dev/disk2s1
brw-r----- 1 root operator 1, 9 1 Mar 16:14 /dev/disk2s1
Not sure if it helps.
I am totally new to this and have little computer knowledge (especially coding). I have looked at other posts/problems online, and I have tried to blow into the card reader (someone said that it helped). But it didn't do anything.
When I look at sharing and permissions for the SD card it says you have custom access.
So if anyone has any ideas about how I can format this, it would be great.
Best Answer
Below itemizes some of the problems with procedure posted in your question.
fdisk
command withsudo
.fdisk
command in your question is not being applied to a drive. The identifierdisk2s1
could represent a partition, container, session or volume. While thefdisk
command can allow for this, there is no logical reason for doing so. The device should be of the form/dev/diskN
whereN
is a positive integer. Care should be taken to confirm you are actually referring to the SD card.fdisk
can be an interactive command. This means the command can require text read from standard input. This text is often referred to a input commands. Under Linux,fdisk
defaults to interactive. However under macOS,fdisk
does not. To makefdisk
interactive under macOS, the‑e
option must be included. In your question, this option was omitted.fdisk
. Each individual command was separated by a space (). However, each command should have been separated by a newline (
\n
). Basically a newline is the same as entering a return from the keyboard. Also the string should have be enclosed by the characters$''
instead of""
.The input commands to
fdisk
presented in your questions would be valid if the operating system was Arch Linux. The equivalent commands which would be correct under macOS are given below.The correcting for the above errors would lead to the command shown below. Here, the input commands have be abbreviated.
Below is the output that should appear when executing the above command for your SD card.
The first input command was
erase
, therefore the output above contains mostly zeroes. To see the results, you would need enter the command given below.After entering the above command, you should see the output shown below.
This raspberrypi.org website offers advice when certain error messages appear. I have repeated some of this advice below. You will need to replace
diskN
with the correct identifier.If the command reports
Resource busy
, you need to unmount the drive first using the command given below.If the command reports
Operation not permitted
you need to disable SIP before continuing.If the command reports
Permission denied
, the partition table of the SD card is being protected against being overwritten by macOS. Erase the SD card's partition table using this command:That command will also set the permissions on the device to allow writing.
IMO, I believe you should attempt to use Arch Linux instead of macOS. I tried installing the latest Arch Linux in a VirtualBox virtual machine. (VirtualBox is a a free product). However, I could not get the virtual machine to work with the builtin SD card reader on my iMac (21.5-inch, Late 2013). I had no better luck with an external USB SD card reader. Maybe I did not have the correct settings or maybe different hardware would make the difference. Also, I did not try using the
sudo vboxmanage internalcommands createrawvmdk ...
commands to expose the SD card to the virtual machine.Instead of a virtual machine, I opted to try a live version of Arch Linux. Here, Arch Linux was able to access the external SD card reader, but not the internal reader. Live means you create a Arch Linux bootable USB flash drive. Once you boot from the flash drive, you can enter the commands to install Arch Linux on the SD card. The Arch Linux ISO file was name
archlinux-2020.03.01-x86_64.iso
and came from this website, although other mirrors can be found here.The instructions for using macOS to create the bootable flash drive can be found here. An image taken from this website is shown below.
I did hypothesize that your question came from a website such as this one. An image of the installation instructions is shown below.
In testing, I modified the above instructions so the downloaded file would be stored on the SD card. After installing this file can be deleted. To stored the file on the SD card, replace the commands given in step 5 with the commands shown below