How do I use MacOS Terminal or other app to format an MBR FAT32 SD card as a 0x0C partition, rather that 0x0B?
If macOS defaults to type 0B
and you wanted 0C
, then you do not need a third party tool to make the change. Just use the command fdisk
with the -e
option to make the change. In your case, the commands would be as follows.
diskutil unmountdisk disk3
sudo fdisk -e /dev/disk3
s 1
c
q
Note: The
diskutil unmountdisk disk3
unmounts of all volumes ondisk3
. Thefdisk -e /dev/disk3
command needs to entered immediately afterwards or the volumes may automatically remount. (In this case, there should be only one volume.) Failure to do so may cause afdisk
tp attempt a shared lock. If successful, then ay
(foryes
) will need to be entered after entering theq
command.
An example is given below.
Marlin-3:~ davidanderson$ diskutil unmountdisk disk3
Unmount of all volumes on disk3 was successful
Marlin-3:~ davidanderson$ sudo fdisk -e /dev/disk3
Password:
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> s 1
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: 0B 1023 254 63 - 1023 254 63 [ 2 - 1953186] Win95 FAT-32
Partition id ('0' to disable) [0 - FF]: [B] (? for help) c
fdisk:*1> q
Writing current MBR to disk.
Marlin-3:~ davidanderson$
The rest of this answer is just background information. You can skip if you like.
The fdisk
command with the -e
option is interactive. The s
command is short for setpid
and the q
command is short for quit
. Below is a list of the interactive commands. This was taken from the output of man fdisk
.
help Display a list of commands that fdisk understands in the interac-
tive edit mode.
manual Display this manual page.
reinit Initialize the currently selected, in-memory copy of the boot
block.
auto Partition the disk with one of the automatic partition styles.
disk Display the current drive geometry that fdisk has probed. You
are given a chance to edit it if you wish.
edit Edit a given table entry in the memory copy of the current boot
block. You may edit either in BIOS geometry mode, or in sector
offsets and sizes.
setpid Change the partition identifier of the given partition table
entry. This command is particularly useful for reassigning an
existing partition to OpenBSD.
flag Make the given partition table entry bootable. Only one entry
can be marked bootable. If you wish to boot from an extended
partition, you will need to mark the partition table entry for
the extended partition as bootable.
update Update the machine code in the memory copy of the currently
selected boot block. Note that this option will overwrite the NT
disk signature, if present.
select Select and load into memory the boot block pointed to by the
extended partition table entry in the current boot block.
print Print the currently selected in-memory copy of the boot block and
its MBR table to the terminal.
write Write the in-memory copy of the boot block to disk. You will be
asked to confirm this operation.
exit Exit the current level of fdisk, either returning to the previ-
ously selected in-memory copy of a boot block, or exiting the
program if there is none.
quit Exit the current level of fdisk, either returning to the previ-
ously selected in-memory copy of a boot block, or exiting the
program if there is none. Unlike exit it does write the modified
block out.
abort Quit program without saving current changes.
Note: The warning message
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
is correct. The/usr/standalone/i386/boot0
file is not part of macOS. Instead of reading this file,fdisk
substitutes zeros. This results in theupdate
command erasing any existing machine code instead of updating with actual machine code.
Your fdisk
invocation should have already partitioned it as type 12. You can press the Ignore button and verify via Terminal that that's the case, then simply eject the disk from your computer and use it wherever you intend to use it.
If you intend to use this drive on your Mac, you will need to format and mount it after running fdisk
:
sudo newfs_msdos /dev/disk3s1
sudo mkdir /Volumes/FLASH
sudo mount -t msdos /dev/disk3s1 /Volumes/FLASH
Here FLASH
is an arbitrary volume name that I chose for sample purposes; feel free to choose your own.
As a clarifying point, the s1
portion of /dev/disk3s1
targets the first partition of disk3
. If you were to specify just disk3
instead, the newfs_msdos
command would overwrite the partition table.