Once you have obtained Basic USB support, you may want to connect a USB storage device (USB stick, USB harddisk, etc) to your router. This HowTo will tell you the steps. You should be aware that any storage device has to be partitioned and formated with a File system (ie. ext3) before data can be addressed as files by the OS.
- obtain Basic USB support on your OpenWrt-powered device
- install storage and file system requirements (Required Packages), as shown below. Minimum you need kmod-usb-storage to see usb disk devices.
- connect the already partitioned and formatted storage device (e.g. hard disc) to your OpenWrt-powered device; the device itself and its partitions should immediately be available as Device files under
/dev/, for example
|✘||We do NOT recommend using NTFS. While it is possible, it has serious performance issues under Linux.|
|✔||We recommend the file systems ext2, ext3, or ext4 (all supported by kmod-fs-ext4)|
If you are planning on sharing your USB storage with Samba, and/or using it to share large multimedia content over UPnP, e.g. with ushare, you should use ext3 or ext4 rather than ext2. Default Ext2 partitions will be limited to files of no more than 4 Gb, but this restriction is eliminated with the newer filesystems. To retain good performance with the newer filesystems, particularly on flash USB storage, you should also consider disabling journaling with the "
-O ^has_journal" when using
mkfs.ext4 to format the filesystem. Also for ext4, the "extent" formatting option (e.g. "
-O ^has_journal,extent") will make filesystem access to large files more performant.
|As of r26314
kmod-usb-storagerequired Kernel support for USB Mass Storage devices
kmod-usb-storage-extrasoptional Kernel support for some more drivers, such as for SmartMedia card readers
block-mountoptional & recommended Scripts used to mount and check block devices (filesystems and swap). Required for
- Since Attitude Adjustment it includes:
blkidCommand-line utility to locate/print block device attributes
swap-utilsThis package contains a collection of tools for managing swap space:
kmod-fs-????required the filesystem you formated your partition in
kmod-usb2optional USB2.0 support, needed for stable USB1.0 usage with some devices (e.g. La Fonera 2), too.
kmod-usb-ohci or kmod-usb-uhcioptional USB1.0 support
kmod-scsi-genericprobably required Any mass storage is a generic SCSI device.
|As of r26645 the modules for ext2 and ext3 (kmod-fs-ext2 and kmod-fs-ext3) are no longer available. You can use the module for ext4 kmod-fs-ext4 to mount ext2/ext3 as well, but then you have to mount your ext2 or ext3 partition like ext4 partition:
Available file systems and their packages can be listed with
opkg update; opkg list "kmod-fs*".
|kmod-fs-autofs4||Kernel module for AutoFS4 support|
|kmod-fs-btrfs||Kernel module for Btrfs support|
|kmod-fs-cifs||Kernel module for CIFS support|
|kmod-fs-exportfs||Kernel module for exportfs. Needed for some other modules.|
|kmod-fs-ext4||Kernel module for ext2, ext3 and ext4 filesystem support1)|
|kmod-fs-hfs||Kernel module for HFS filesystem support|
|kmod-fs-hfsplus||Kernel module for HFS+ filesystem support|
|kmod-fs-isofs||Kernel module for ISO9660 filesystem support|
|kmod-fs-minix||Kernel module for MINIX file system support|
|kmod-fs-msdos||Kernel module for MSDOS filesystem support|
|kmod-fs-nfs||Kernel module for NFS support|
|kmod-fs-nfs-common||Common NFS filesystem modules|
|kmod-fs-nfsd||Kernel module for NFS kernel server support|
|kmod-fs-ntfs||Kernel module for NTFS read only filesystem support|
|kmod-fs-reiserfs||Kernel module for ReiserFS support|
|kmod-fs-udf||Kernel module for UDF filesystem support|
|kmod-fs-vfat||Kernel module for VFAT filesystem support|
|kmod-fs-xfs||Kernel module for XFS support|
|You are not required to use NTFS or FAT in order to access the disk from Microsoft Windows! See http://wiki.ubuntuusers.de/Linux-Partitionen_unter_Windows on HowTo access Linux filesystems from Windows. Thus native Linux file systems like ext2 or ext3 are the first choice when working with Linux. Don't bother with NTFS, VFAT and the like. They all have some quirks we could do without.|
If, for whatever reasons, you insist to utilize NTFS as file system, you may find Writable NTFS helpful.
For some filesystems, like for VFAT, you need to additionally install language packages (codepages / charsets) to handle the filenames. If your mount fails, look in dmesg - a message like
FAT: codepage cp437 not found
means that you need NLS codepage 437, and a message like
FAT: IO charset iso8859-1 not found
means that you need NLS ISO 8859-1.
***''kmod-nls-base''** Kernel module for NLS (Native Language Support)
Available NLS files and their packages can be listed with
opkg update; opkg list "kmod-nls*".
|kmod-nls-cp1250||Kernel module for NLS Codepage 1250 (Eastern Europe)|
|kmod-nls-cp1251||Kernel module for NLS Codepage 1251 (Russian)|
|kmod-nls-cp437||Kernel module for NLS Codepage 437 (United States, Canada)|
|kmod-nls-cp775||Kernel module for NLS Codepage 775 (Baltic Rim)|
|kmod-nls-cp850||Kernel module for NLS Codepage 850 (Europe)|
|kmod-nls-cp852||Kernel module for NLS Codepage 852 (Europe)|
|kmod-nls-cp866||Kernel module for NLS Codepage 866 (Cyrillic)|
|kmod-nls-iso8859-1||Kernel module for NLS ISO 8859-1 (Latin 1)|
|kmod-nls-iso8859-13||Kernel module for NLS ISO 8859-13 (Latin 7; Baltic)|
|kmod-nls-iso8859-15||Kernel module for NLS ISO 8859-15 (Latin 9)|
|kmod-nls-iso8859-2||Kernel module for NLS ISO 8859-2 (Latin 2)|
|kmod-nls-koi8r||Kernel module for NLS KOI8-R (Russian)|
|kmod-nls-utf8||Kernel module for NLS UTF-8|
mkdir -p /mnt/shares
To manually mount a partition:
mount -t ext3 /dev/sda2 /mnt/shares -o rw,sync
To mount a swap partition:
To unmount a swap partition:
opkg update opkg install kmod-usb-storage block-mount block-hotplug kmod-fs-ext4 swapon /dev/sda1 mkdir -p /mnt/share mount -t ext3 /dev/sda2 /mnt/share -o rw,sync
Other example is how to external usb stick with FAt32 partition (but we'll keep ext4 support also)
opkg update opkg install kmod-usb-storage block-mount block-hotplug kmod-fs-ext4 kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 mkdir -p /mnt/usb mount -t vfat /dev/sda1 /mnt/usb
|As of r26314
Install the packages
block-hotplug, they will take care of this and also enable automatic mount when device is plugged in.
The configuration file is
Example settings in
fstab for mounting to
/mnt/share with automatic detection of the file system:
And to make the fstab settings effective in current session run:
To make the fstab settings effective after every reboot run:
UCI CLI commands:
/etc/init.d/fstab stop uci add fstab mount uci set fstab.@mount[-1].device=/dev/sda1 uci set fstab.@mount[-1].options=rw,sync uci set fstab.@mount[-1].enabled_fsck=0 uci set fstab.@mount[-1].enabled=1 uci set fstab.@mount[-1].target=/mnt/share uci commit fstab /etc/init.d/fstab start
Delete with UCI CLI commands:
/etc/init.d/fstab stop uci delete fstab.@mount uci commit fstab /etc/init.d/fstab start
Note: In order to do
fsck (aka CHKDSK) of FAT32/VFAT partitions before mounting (i.e. during the boot process), you should read the following tickets:
Incorrect log output for mount point file systems without a fsck, and
Missing fsck function for block-mount/-hotplug of dos/vfat filesystems
Actually there are packages in the OpenWrt repositories with which you can partition, format and check filesystems:
fdisk(for help with partitioning see TLDP)
e2fsprogsContains the essential ext2 filesystem utilities
tune2fs, and also most of the other core ext2 filesystem utilities available. for help with formatting see TLDP
Note: In order to perform a
e2fsck on 1 GiB partition, you will need at least 1 MiB of RAM.2) The same is true for
mke2fs. You can solve this by mounting a SWAP partition (or by using a device with enough RAM).
Once you successfully mounted your partition, you may want to install packages onto it. Please see Installation.Destination for that.
If you plan to install kernel modules on a USB drive you might want to read this: https://dev.openwrt.org/ticket/10739
You may create an empty file to indicate that the disk is not plugged in so that you don't put files directly onto NAND by doing
touch /mnt/usbstorage/USB_DISK_NOT_PRESENT chmod 444 /mnt/usbstorage -RThis will prevent only processes not running as root from writing onto NAND. You can of course also use this file in your own scripts.
mount the external drive:
(where sda1 is your drive, see fdisk -ls, and /mnt/hdd is the point where you wish to mount. Use md to make the directories)
ntfs-3g -o rw,noatime /dev/sda1 /mnt/hdd
Then make the following script:
And the contents:
(In this script, You can control other processes, like transmission, whitch uses Your external drive)
Enter the required permissions to it.
chmod a+x /etc/init.d/hdd
create a swapfile, then format and turned on.
dd if=/dev/zero of=/mnt/hdd/swapfile bs=1M count=64 mkswap /mnt/hdd/swapfile swapon /mnt/hdd/swapfile
To see if work:
Now let's do a virtual disk. You need an additional package.
opkg update opkg install kmod-fs-ext3 kmod-loop e2fsprogs insmod ext3 insmod loop
Then, create, and format the disk:
dd if=/dev/zero of=/mnt/hdd/owrt_loop bs=1M count=128 mke2fs -j -F -b 1024 /mnt/hdd/owrt_loop
To be able to use, plug-in for OpenWrt:
mkdir /mnt/loopdisk mount -o loop /mnt/hdd/owrt_loop /mnt/loopdisk
Now our system is not only the OpenWrt xMB, but x+128 MB
/etc/opkg.conf file into the following line
To install package:
opkg -dest usb install package
To delete package:
opkg -dest usb remove package
Prefer EXT2 or EXT3 file system.
Symptoms: I have installed
kmod-usb-storage, but I don't see
sda2 or similar in
Solution: Make sure you have started and enabled
usb startup script:
/etc/init.d/usb start /etc/init.d/usb enable
Symptoms: You are trying to mount ext2 or ext3 partition and you have installed only kmod-fs-ext4. Neither
mount command nor
fstab works. The kmod-fs-ext4 issue definitely applies to Backfire, but is not an issue for Attitude Adjustment (tested on Attitude Adjustment RC1).
Solution a): you have to make sure that you are trying to mount the ext2 or ext3 partition like it was ext4 partition. Example /etc/config/fstab config and mount command follows:
mount -t ext4 /dev/sda1 /mnt -o rw,sync
Solution b): install
opkg update opkg install kmod-fs-ext3
Note: If you are having trouble with fstab, see fstab troubleshooting.
Note: If you are having trouble using storage on a Huaweu 3G dongle, you should read the following ticket:Mass storage missing from 3G dongle
doc/howto/usb.storage.txt · Last modified: 2013/02/13 19:31 by stephenc01