Mounting NTFS and exFAT filesystems on OpenBSD

       589 words, 3 minutes

I often try various OSes on my spare laptops. This is where Ventoy turned out to be really useful. If you don’t know, Ventoy is a free bootloader that looks like Grub and let you boot whichever ISO files you put on the USB key it is installed. Just copy / paste the ISO on the dedicated USB key partition and it’s ready to boot.

It works from Windows, Linux but not on OpenBSD. Well… until I discovered some error messages didn’t mean what I thought they did…

What a USB key looks like on OpenBSD

First of all, read the Disk Setup FAQ section on the OpenBSD website.
This should give you a better understanding of what I’m doing here.

When you plug a USB drive in an OpenBSD machine, you get a message that looks like the following:

$ dmesg | tail
(...)
sd3 at scsibus4 targ 1 lun 0: <SanDisk, Extreme Pro, 0> removable serial.07815588000000000000
sd3: 122112MB, 512 bytes/sector, 250085376 sectors

Unfortunately, that doesn’t tell you how the drive is partionned. To get the information, use the disklabel(8) command.

$ disklabel sd3
# /dev/rsd3c:
type: SCSI
disk: SCSI disk
label: Extreme Pro
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 15567
total sectors: 250085376
boundstart: 0
boundend: 250085376

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:        250085376                0  unused
  i:        250017792             2048    NTFS
  j:            65536        250019840   MSDOS

Most of the time, USB drives used on Windows will only contain an i partition that hosts either an MSDOS or an NTFS partition. In the case of the Ventoy USB key, the MSDOS partition is the system part and the NTFS partition is where you drop the ISO files.

An MSDOS partition can be accessed using stock tools like so:

$ doas mount -t msdos /dev/sd3j /mnt

$ ls /mnt
/                                       System Volume Information/
../                                      grub/
EFI/                                     tool/
ENROLL_THIS_KEY_IN_MOKMANAGER.cer        ventoy/

$ doas umount /mnt

Access an NTFS partition

When it comes to NTFS, you may use the stock mount_ntfs(8). The problem is that you will be limited to read-only access. If this is a problem, the ntfs_3g package can be installed and the partition can be access using the FUSE userspace filesystem framework.

$ doas pkg_add ntfs_3g
$ pkg_info -L ntfs_3g | grep 'bin/'
$ doas ntfs-3g /dev/sd3i /mnt

This works for any proper NTFS partition. But Ventoy seem to not fall into this category. When issuing the mount command, the following error raises:

$ doas ntfs-3g /dev/sd3i /mnt
NTFS signature is missing.
Failed to mount '/dev/sd3i': Invalid argument
The device '/dev/sd3i' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

I’ve called Ventoy names several times for not providing “a valid” NTFS partition. But after tries&fails and a lot of forum readings, it turns out the partition is not NTFS. It is exFAT.

Access an exFAT partition

The “Extensible File Allocation Table” filesystem is not supported by the stock OpenBSD mount_msdos(8) command. To deal with such partition, you need the exfat package.

$ doas pkg_info -Q exfat
$ doas pkg_add exfat-fuse
$ pkg_info -L exfat-fuse | grep 'bin/'

$ doas mount.exfat /dev/sd3i /mnt
$ ls /mnt
./
../
Fedora-Workstation-Live-x86_64-40-1.14.iso
FreeBSD-14.1-RELEASE-amd64-memstick.img
alpine-standard-3.18.4-x86_64.iso
debian-12.2.0-amd64-netinst.iso
install75.img
install76.img
linuxmint-21.3-cinnamon-64bit.iso
omnios-r151050.iso
omnios-r151050.usb-dd
slackware64-15.0-install-dvd.iso

$ doas umount /mnt

And there we are. You now know how to deal with NTFS and exFAT partitions on OpenBSD. And I can update my Ventoy’s data partition from OpenBSD! 🥳