Formatting, partitioning, and mounting drives for NTFS with FreeBSD and Mac OS X


  • FreeBSD uses sysutils/fuse-ntfs for NTFS read/write capability.  Fast formatting requires mkntfs with environment variable NTFS_USE_UBLIO=0.  Once mounted, writing files is unusably slow.
  • Mac OS X also uses fuse and has better performance than FreeBSD, but writes are still pretty slow.
  • The best performance was mounting the drive on a Windows guest OS in VirtualBox.  I used a Windows XP guest on an OS X host.


I’d like to copy .mkv video files to the USB drive for the LG TV’s webOS, but the common FAT filesystems have a 2G limit on file size.  The only other option is NTFS.

webOS doesn’t recognize GPT, so you have to format using MBR.

Using FreeBSD

Wiping the Drive

Here’s the magic incantation for wiping the beginning & end of your disk(s).  Replace
ada3 with your disk/device.

# dd if=/dev/zero of=/dev/ada3 bs=1m count=1
# dd if=/dev/zero of=/dev/ada3 bs=1m oseek=`diskinfo ada3 | awk ‘{print int($3 /  (1024*1024)) – 4;}’`

Mounting an NTFS Partition Read/Write on FreeBSD

This page has a good overview of the steps for mounting an existing NTFS partition r/w on FreeBSD.  In summary,

  1. Use fdisk or gpart to find the NTFS partition
  2. To mount in read-only mode:
    # mount -t ntfs /dev/da0s1 /mnt
  3. To mount r/w:
    1. install sysutils/fuse-ntfs
    2. # ntfs-3g /dev/da0s1 /mnt
      Note: mount -t ntfs-3g /dev/da0s1 /mnt will give the error
      Operation not supported by device

Creating the NTFS Partition

Some excellent background is in this thread.

Important Points

The gpart create Command does not allow the Microsoft ‘ntfs’ Type to be used with the GPT Partition Scheme, and it returns an invalid argument error. You have to use the MBR Scheme in order to create the ‘ntfs’ Type, and you cannot use the ‘-l LABEL’ Argument with the MBR Scheme which also returns an error.

To create an NTFS partition under GPT you need to specify type ms-basic-data.

The Steps

    1. gpart create -s MBR da0
      Note: MBR doesn’t take -l label flags
    2. gpart add -t ntfs da0
      This puts NTFS on a single partition on the rest of the drive.
    3. Now the drive needs a filesystem:
      mkntfs /dev/da0s1
      This command takes a long time and then fails. There is a -Q (also -f) for quick format, which hangs at creating the backup boot sector when displayed with -v.
      Solution: set the environment variable NTFS_USE_UBLIO=0 before running the above command. Details below.

This post says there’s a bug in ublio, and his solution was to uninstall/reinstall sysutils/fusefs-ntfs with ublio disabled, then restore.  However, I couldn’t build the port without showing => /usr/local/lib/ (0x800c7b000)
in the mkntfs binary.  I tried excluding the USE_UBLIO in the port configure screen, and even undefined it in


Ultimately, the solution was right in the sysutils/fusefs-ntfs/files/README.FreeBSD in section 4:

The UBLIO layer is configured through environment variables, which are read when mounting the filesystem. The following are available:

NTFS_USE_UBLIO – Enable the UBLIO cache.

In section 5, the same document also notes

– For mkntfs(8) -F must be used to allow non-block device to be processed.

– Current implementation does not properly work with partitions of size which
is not a multiply of UBLIO_BLOCKSIZE (cannot read/write last cluster). For
instance, you may not be able to create ntfs filesystem because of this with

Initializing device with zeroes: 99%Failed to complete writing to
/dev/ada0s1 after three retries.

which happened to me when not using the quick format flag.

Thus, with
# export NTFS_USE_UBLIO=0
this command specifying hardware parameters successfully completed
# mkntfs -vFIQ -p 63 -S 63 -H 255 /dev/da0s1
as did the simpler
# mkntfs -vFQ /dev/da0s1

Now mount the partition:
# ntfs-3g /dev/da0s1 /mnt

mount shows
/dev/fuse on /mnt (fusefs, local, synchronous)

Ultimately, as noted in the TL;DR section above, the fastest large file copying was achieved mounting the drive in a VirtualBox Windows guest OS, i.e., not using fusefs.

Blast from the Past: How to add an item to the Opera 12 Browser context menu on FreeBSD (and probably Linux)

This could also be titled, “Opera 12: How to open links in a different browser.

TL;DR: Create and edit ~/.opera/menu/standard_menu.ini and add something like this line to the [Link Popup Menu] section:

Item, "Open in Firefox" = Execute program, "/usr/local/bin/firefox", "%l"


Opera 12 is my favorite browser of all time.  With it’s excellent standards compliance, it is still a workhorse today, so I was disappointed to find that it could not display certain secure websites, failing with this error:

Secure connection: fatal error (40) from server.

This is due to there being no EC support for issued free SSL certs.  Solutions I found online were to use a kproxy service or to create a shortcut or mouse gesture to open URLs in another browser.  I didn’t want to use a proxy, and I was unable to get the shortcut or mouse gesture configuration to work after many tries.  Perhaps it works on Windows but not FreeBSD.

The solution I found was to add a menu item to the context menu.  At first, I couldn’t find where this was configured, so I used ktrace while launching the application to see that the file ~/.opera/menu/standard_menu.ini was being read.  The following steps produced a menu item which allows me to right-click on a link an open it in a different browser.

  1. cd ~/.opera && mkdir menu
  2. Find the corresponding system file (try /usr/local/etc/operaprefs_default.ini or /usr/local/share/opera/ui/standard_menu.ini) and copy it into the menu/ directory, naming it standard_menu.ini.
  3. Edit the file, adding this line (for Firefox) to [Link Popup Menu] and [Image Link Popup Menu]
    Item, "Open in Firefox" = Execute program, "/usr/local/bin/firefox", "%l"
  4. Restart Opera.

It’s also worth noting that on already-opened pages, you can right-click for the context menu and select “Open With…” to access a list of other installed browsers.

Thunderbird NS_ERROR_NOT_AVAILABLE error when trying to open attachments.

TL;DR: Reselect your helper application.

When trying to open a PDF attachment in Thunderbird 31.4.0 (FreeBSD 10.1, recently upgraded from 9.x), nothing would happen for PDFs.  Checking Tools -> Error Console showed this error:

Timestamp: 03/19/15 22:19:19
Error: [Exception… “Cannot call openModalWindow on a hidden window”  nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)”  location: “JS frame :: resource://gre/components/nsPrompter.js :: openModalWindow :: line 357”  data: no]
Source File: resource://gre/components/nsPrompter.js
Line: 357

I went into Edit -> Preferences -> Attachments where the KDE program “okular” was correctly defined for PDF files.  On a hunch, I selected “Use other…” and reselected okular by browsing to the program on the filesystem, and magically, opening my PDFs work again.  Okular was shown in the drop-down, but the full path to the program was not correct.

The problem stems from a change to the location of the helper applications, which are stored in your profile directory (e.g., $HOME/.thunderbird/blahblah.default/) in the file mimeTypes.rdf.  This was the result of my operating system upgrade, as it included an upgrade to KDE4 from 4.8.4 to 4.12.2.  Previously, the KDE4 programs that I used were in /usr/local/kde4/bin/ , but now they’re in /usr/local/bin/ .

An alternative to reselecting every application which changed location is to edit the mimeTypes.rdf file and search and replace to update the directory locations.

Why FreeBSD background fsck works

How does background fsck work, i.e., how is it ok to mount a dirty filesystem, and why doesn’t it get worse? The penultimate paragraph has the explanation:

The upshot is that background fsck in FreeBSD works with soft updates, and the only corrupt state that such a filesystem can be in after a crash is when resources are marked as “used” which are actually “free.” Thus, this doesn’t compromise the mounted filesystem, and fsck can free up these resources when it runs in the background. File systems that do not use soft updates still need the usual foreground fsck.