Zum Inhalt

USB Storage Device

This article describes how to mount an USB storage device in OpenWrt.

All articles of the OpenWrt series

To mount a USB device in OpenWrt follow these steps:

The software packages need to be installed on the device:

opkg install block-mount kmod-usb-storage usbutils libblkid gdisk

After the installation a new menu appears System --> Mount Points. If the menu is not displayed just reboot OpenWrt.

reboot

After the reboot login via LuCi.

USB Storage Device

Attach your USB storage device to your OpenWrt device. Please refer to ➡️ Prepare USB Storage for detailed manual how to format the USB device.

Click Edit.

USB Storage Device

The mount point needs to be added via custom field. It is not listed in the drop-down menu.

Configuration In LuCi

General Settings

Select your USB storage device from the drop down.

USB Storage Device

Click int to --cutom-- field

USB Storage Device

Enter the mount point of the USB storage device manually. The root directory is /mnt.

USB Storage Device

Click Save.

USB Storage Device

The USB storage device can get mounted by OpenWrt. Click Enabled and Save & Applythe changes.

USB Storage Device

On the CLI you can check if the USB storage device is mounted.

root@OpenWrt:~# cd /mnt/
root@OpenWrt:/mnt# ls -lah
drwxr-xr-x    1 root     root           0 Nov 30 10:22 .
drwxr-xr-x    1 root     root           0 Nov 30 08:29 ..
drwxr-xr-x    2 root     root           0 Nov 30 10:22 sda1

Advanced Settings

USB Storage Device

Configuration on CLI

On the CLI the configuration looks as following:

root@OpenWrt:~# ls -l /dev/sd*
brw-------    1 root     root        8,   0 Nov 23 12:20 /dev/sda
brw-------    1 root     root        8,   1 Nov 23 12:20 /dev/sda1

root@OpenWrt:~# block info | grep "/dev/sd"
/dev/sda1: UUID="637E-0193" LABEL="usb-drive" TYPE="exfat"

root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'

# Generate a config entry for the fstab file:
root@OpenWrt:~# block detect | uci import fstab

# Now enable automount on that config entry:
root@OpenWrt:~# uci set fstab.@mount[-1].enabled='1'
root@OpenWrt:~# uci commit fstab

# uci show fstab
root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='637E-0193'
fstab.@mount[0].enabled='1'

# Show mount point details
root@OpenWrt:~# ls -l /mnt/sda1
root@OpenWrt:~# block info
/dev/mtdblock13: UUID="9b0b81c6-8dfd6cb8-6b633c0f-b2292799" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock14: MOUNT="/overlay" TYPE="jffs2"
/dev/mtdblock15: TYPE="jffs2"
/dev/sda1: UUID="637E-0193" LABEL="usb-drive" TYPE="exfat"

# Restart service fstab
root@OpenWrt:~# service fstab boot

Prepare USB Storage

Start disk utility program

USB Storage Device

Click on Delete

USB Storage Device

Select ExFAT and click on Delete

USB Storage Device

Eject the storage device.

USB Storage Device

Attach the usb storage device to OpenWrt and follow the steps described above.

All articles of the OpenWrt series

Gib mir gerne einen Kaffee ☕ aus ❗️

Wenn dir meine Beiträge gefallen und geholfen haben, dann kannst du mir gerne einen Kaffee ☕️ ausgeben.

Donation via PayPalDonation via LiberaPay

Donation via Bitcoin
Bitcoin Address: bc1qfuz93hw2fhdvfuxf6mlxlk8zdadvnktppkzqzj

Source

Image: Official OpenWrt Logo - https://OpenWrt.org/_media/docs/guide-graphic-designer/OpenWrt-logo-usage-guidelines.pdf