HOWTO: Create a Windows-readable disk with FreeBSD
This HOWTO will describe the process of using FreeBSD to format a disk with the FAT32 filesystem so that it can be read by Windows and macOS.
Steps
-
Open a terminal and run
geom disk list
to view all attached disks. You should be able to identify it by the size of the disk (“mediasize”) and the manufacturer’s name (“descr”).Sample output of
geom disk list
:Geom name: da0 Providers: 1. Name: da0 Mediasize: 8166703104 (7.6G) Sectorsize: 512 Mode: r0w0e0 descr: Verbatim micro USB ident: 11122488000854 rotationrate: unknown fwsectors: 63 fwheads: 255
The name is what we need. Here that’s
da0
, but for the remainder of this document I’ll refer to it asXXX
to prevent copy/paste accidents. - Run
su
to switch to root. -
As root, run the following commands.
WARNING
The following commands are destructive. The disk’s existing data will be overwritten and will become impossible to retrieve. Only proceed if you’re sure you’re using the correct disk.
-
Destroy the existing partition scheme (if any).
gpart destroy -F XXX
-
Create a new MBR partition scheme.
gpart create -s MBR XXX
-
Create a FAT32 (LBA) partition.
gpart add -t fat32lba XXX
-
Write a filesystem to the partition we just created.
newfs_msdos XXXs1
mount -t msdos XXXs1 /mnt
- Put some files on
/mnt
. umount /mnt
- It is now safe to remove the disk.
-
Notes
gpart
supports two FAT32 partition types: fat32
and fat32lba
(also known as 0x0b
and 0x0c
). It's unclear what the precise difference is, but some random forum posts seem to suggest the LBA variant supports filesystems larger than 2GiB.