User Tools

Site Tools


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.



  1. Obtain Basic USB support and USB Storage on your OpenWrt
  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.


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,big_writes

To auto mount a partition at startup (with hard drive plugged) edit the file /etc/rc.local :

sleep 1

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

exit 0

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 sleep 10 #more apps installed, need more time to load kernel modules! 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)

Improved hotplug script

Below is a modified version of the script which should work fine even if you are using root file system using extroot. The original script tries to re-mount all the filesystems, including mtdblock* filesystems at boot which is not what we want.

Code is added to dismiss disks which can be managed by block_mount. It should be preferred if it supports the file system you are using but it has limited filesystem type support.

The mount binary seem to figure out what filesystem type it is trying to mount, therefore the code sections for checking this is removed. The script should be able to mount any supported filesystem. (so should it be in ntfs section?)

Some sensible mount options which should be suitable for both solid state and normal drives is also added. In addition, hdparm is called to set drive APM setting so drive can go to standby if not used (the correct setting may be drive dependent). The hd-idle does not seem to work on USB drives properly, but the APM setting is able to make the drive to use its internal logic if supported by the drive.

One other problem with the original script was related to unmounting. Once a drive is disconnected, it disappears from /dev therefore it can not be unmounted by giving the original /dev path (you would just get 'No such file or directory' error). Therefore the script finds where the drive was mounted and uses the mount point for unmounting.

The script was tested on OpenWrt Chaos Calmer 15.05 and requires blkid and hdparm to be installed. Modify the script to suit your needs. It currently mounts to /export

#!/bin/sh # Copyright (C) 2015 # 0 yes blockdevice handles this - 1 no it is not there blkdev=`dirname $DEVPATH` basename=`basename $blkdev` device=`basename $DEVPATH` skip=`block info | sed 's/\(.*\): .*/\1/' | grep -q $device ; echo $?` path=$DEVPATH if [ $basename != “block” ] && [ -z “${device##sd*}” ] && [ $skip -eq 1 ]; then islabel=`blkid /dev/$device | grep -q LABEL ; echo $?` if [ $islabel -eq 0 ] ; then mntpnt=`blkid /dev/$device |sed 's/.*LABEL=“\(.*\)” UUID.*/\1/'` else mntpnt=$device fi case “$ACTION” in add) mkdir -p /export/$mntpnt # Set APM value for automatic spin down /sbin/hdparm -B 127 /dev/$device # Try to be gentle on solid state devices mount -o rw,noatime,discard /dev/$device /export/$mntpnt ;; remove) # Once the device is removed, the /dev entry disappear. We need mountpoint mountpoint=`mount |grep /dev/$device | sed 's/.* on \(.*\) type.*/\1/'` umount -l $mountpoint ;; esac fi
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
docs/guide-user/storage/writable_ntfs.txt · Last modified: 2020/06/11 00:14 by palebloodsky