Packetwatch.net

USB hard drive in FreeBSD



Last modified: Jun. 13, 2009

Contents
1 - Summary
2 - Kernel options
3 - Dependencies
4 - NTFS-3g installation
5 - Service configuration
6 - Plug in USB hard drive
7 - Mount NTFS partition


1 - Summary

This guide will show how to use a USB hard drive in FreeBSD. It explains how
to mount an NTFS partition with read/write access on a USB hard drive using
the ntfs-3g driver. The ntfs-3g driver is driver that supports read/write for
NTFS filesystems. This has been tested in FreeBSD 7.1.


2 - Kernel options

You will need to have the following options in your kernel.
  device          scbus                   # SCSI bus (required for SCSI)
  device          da                      # Direct Access (disks)
  device          pass                    # Passthrough device (direct SCSI access)
  device          uhci                    # UHCI PCI->USB interface
  device          ohci                    # OHCI PCI->USB interface
  device          ehci                    # EHCI PCI->USB interface (USB 2.0)
  device          usb                     # USB Bus (required)
  device          umass                   # Disks/Mass storage - Requires scbus and da
If you didn't already have them in your kernel you will need to reboot before
using the USB hard drive.


3 - Dependencies

The following dependencies will need to be installed. Install the packages
from a FreeBSD FTP mirror server.
# su - root
# setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/$arch/packages-$rel-release/All/
# pkg_add -r libublio-*.tbz
# pkg_add -r fusefs-libs-*.tbz
# pkg_add -r fusefs-kmod-*.tbz
# logout


4 - NTFS-3g installation

Install the fusefs-ntfs package from an FreeBSD FTP mirror server.
# su - root
# setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/$arch/packages-$rel-release/All/
# pkg_add -r fusefs-ntfs-*.tbz
# logout


5 - Service configuration

Find where the ntfs-3g binary was installed to.
# pkg_info -L fusefs-ntfs-* | grep bin
/usr/local/bin/ntfs-3g
/usr/local/bin/ntfs-3g.probe

Rename the default program used to mount NTFS partitions and make a link to
the new program.
# sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.original
Password:
# sudo ln -s /usr/local/bin/ntfs-3g /sbin/mount_ntfs
Password:

Edit /etc/rc.conf.local so that the fusefs service will start when the system
starts up. Somewhere in the file add the following.
  fusefs_enable="YES"
# sudo vi /etc/rc.conf.local
Password:

Start the fusefs service.
# sudo /usr/local/etc/rc.d/fusefs start
Password:
Starting fusefs.
# sudo /usr/local/etc/rc.d/fusefs start
Password:
fusefs is already running.
# logout


6 - Plug in USB hard drive

Log in with a normal user account. Plug in the USB hard drive into the
computer and check to make sure it was detected properly.
# dmesg | tail -n 6
umass0: Seagate FreeAgent Go, class 0/0, rev 2.00/0.00, addr 2 on uhub3
da0 at umass-sim0 bus 0 target 0 lun 0
da0: Seagate FreeAgent Go 102D Fixed Direct Access SCSI-4 device 
da0: 40.000MB/s transfers
da0: 238475MB (488397168 512 byte sectors: 255H 63S/T 30401C)
GEOM_LABEL: Label for provider da0s1 is ntfs/PORTABLE.


7 - Mount NTFS partition

Mount the NTFS partition with read/write access.
# sudo mount_ntfs /dev/da0s1 /mnt
Password:

Create a test file on the hard drive.
# echo Test > /mnt/test.txt
# ls -l /mnt/test.txt 
-rwxrwxrwx  1 root  wheel  5 May 20 21:51 /mnt/test.txt
# cat /mnt/test.txt 
Test

Unmount the NTFS partition.
# sudo umount /mnt
Password:


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2017.