For the complete documentation index, see llms.txt. This page is also available as Markdown.

26.1 Windows File Systems

FreeBSD currently requires the user-space driver ntfs-3g for NTFS read/write, and the user-space driver fusefs-exfat for exFAT read/write; FAT32 is natively supported by the kernel for both reading and writing.

NTFS File System

NTFS is a file system developed by Microsoft, commonly used in Windows operating systems. FreeBSD provides full read/write support for NTFS through the fusefs-ntfs package (corresponding to Port filesystems/ntfs), facilitating access to and modification of NTFS-formatted storage devices.

Installing ntfs-3g

Install using pkg:

# pkg install fusefs-ntfs

Alternatively, build through the Ports system:

# cd /usr/ports/filesystems/ntfs
# make BATCH=yes install clean

Configuring ntfs-3g

Insert an NTFS-formatted device, such as a USB flash drive, into the computer. The device name can then be identified, for example da0 (corresponding to the device file /dev/da0p1).

Edit the /etc/rc.conf configuration file to add the fusefs kernel module to the system startup load list:

# sysrc kld_list+="fusefs"

The above command makes the configuration persistent. To apply it immediately, run:

# kldload fusefs

Manual Mounting

To manually mount an NTFS partition:

Use ntfs-3g to mount /dev/da0p1 to /mnt, set read/write permissions, and specify appropriate owner and permission mask for files:

Perform some read/write operations:

Automatic Mounting

NTFS partitions can be configured to mount automatically at boot.

Edit the /etc/fstab file and add the following mount information:

Verify the mount status:

Then view the file contents:

Appendix: Formatting a New Device as NTFS

First, a partition table must be created: the device can be set up with either an MBR or GPT partition table.

MBR partition tables are older, so the GPT scheme is used in the following demonstration.

Creating an MBR Partition Table

Creating a GPT Partition Table

Formatting an NTFS Partition

Warning

mkntfs will format the specified partition, and all data on the partition will be permanently lost. Please confirm the device path is correct.

Create an NTFS file system on the /dev/da0p1 partition:

Parameter description:

  • -f: fast format

  • -v: verbose output

  • NTFS_USE_UBLIO=0: UBLIO (User space Block I/O) is a user-space block I/O library used to improve FUSE file system performance. However, in the FreeBSD environment, UBLIO may cause file system corruption and data loss when working with ntfs-3g. In this example, without this parameter to disable UBLIO, the command will become unresponsive.

References

FAT32 File System

The FAT file system is simple and reliable. Although it falls behind modern solutions in performance, reliability, and scalability, it remains a common choice for data exchange between devices due to its availability across multiple operating systems.

When using the gpart show command, FAT32 file systems are typically displayed as the ms-basic-data type.

The following command displays detailed information about the nda1 disk and its partitions, including start position, size, and type:

Note

The file system type must be explicitly specified for mounting.

Mount the /dev/nda1p3 partition as an msdosfs file system:

  • The -v parameter is used for verbose output;

  • The -t parameter is used to specify the file system type.

List the contents of the mount directory:

When no longer needed, unmount the file system:

exFAT File System

exFAT (Extended File Allocation Table) is a lightweight file system optimized for flash storage devices (such as USB drives and SD cards). It supports large-capacity files and is widely used across multiple platforms, making it suitable for external storage devices.

To use exFAT on FreeBSD, install the filesystems/exfat package, load the FUSE kernel module, and mount the file system as follows:

Installing the exFAT Package

Install the exFAT package using pkg:

Install using Ports:

Loading the fusefs(4) Kernel Module

Before using FUSE file systems, the fusefs(4) kernel module must be loaded:

Use sysrc(8) to configure the module to load automatically at boot:

Formatting a Disk as exFAT File System

The Port filesystems/exfat-utils must be installed separately; it provides the mkexfatfs tool for formatting disks to exFAT format.

  • Create a GPT partition table

  • Create a partition containing all remaining space

  • Format as exFAT

The -n option specifies the volume label Mytest.

  • Verify the file system used by the /dev/ada1p1 partition:

Test Mounting an exFAT Volume

Mount the exFAT volume by specifying its FreeBSD partition name and an existing mount point. The following example mounts /dev/ada1p1 to /mnt:

Verify the exFAT volume mount status:

Try reading and writing some files:

References

Last updated