User Tools

Site Tools


doc:howto:writable_ntfs

Writable NTFS

Once you have obtained Basic USB support, you now want to connect a storage (USB stick, USB harddisk, etc) device to your router. Using kmod-fs-ntfs only provides read support. This HowTo will show you how to obtain read/write support for NTFS volumes.

Preparations

Prerequisites

  1. Obtain Basic USB support on your OpenWrt and
  2. Connect your storage device to your OpenWrt router, the device and its partitions should immediately be available as Device files under /dev, for example /dev/sda, /dev/sda1, /dev/sda2, etc.

Required Packages

  • ntfs-3g
  • fdisk optional Required to autodetect the filesystem type when using the hotplug script.

Configuration

There is nothing to configure! Note however, you can only mount a partition to an existing directory. You can create on with mkdir, for example mkdir -p /mnt/usb-ntfs.

To manually mount a partition:

ntfs-3g /dev/sda1 /mnt/usb-ntfs -o rw,sync

To unmount:

umount /dev/sda1

Hotplug Mounting

By enabling the Busybox mount helper option (self built OpenWrt required)

This forum post might be relevant if you already have built OpenWrt by yourself you have to rebuild the firmware with the Busybox's mount melper option enabled and reflash the new image. If you have not yet built OpenWrt once, Documentation - Building may help.

As of Backfire r25816 and trunk r25815 this option is already enabled by default.

With a custom hotplug script

Now that you can get your volume to mount on command, the next step is mounting it when it's plugged in automatically.

To get our drive to mount on plugin, we utilize the hotplug system. Create the following files as /etc/hotplug.d/block/10-mount.

#!/bin/sh # Copyright (C) 2011 OpenWrt.org blkdev=`dirname $DEVPATH` if [ `basename $blkdev` != "block" ]; then device=`basename $DEVPATH` case "$ACTION" in add) mkdir -p /mnt/$device # vfat & ntfs-3g check if [ `which fdisk` ]; then isntfs=`fdisk -l | grep $device | grep NTFS` isvfat=`fdisk -l | grep $device | grep FAT` isfuse=`lsmod | grep fuse` isntfs3g=`which ntfs-3g` else isntfs="" isvfat="" fi # mount with ntfs-3g if possible, else with default mount if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then ntfs-3g /dev/$device /mnt/$device elif [ "$isvfat" ]; then mount -o iocharset=utf8 /dev/$device /mnt/$device else mount /dev/$device /mnt/$device fi ;; remove) umount -l /dev/$device ;; esac fi

(The script above comes from this blog post)

Now, whenever you plug in an NTFS USB disk, it should automatically mount. (Note that this will be a different path than /mnt/usb-ntfs)


doc/howto/writable_ntfs.txt · Last modified: 2014/02/13 22:21 by ejurgensen