Build Home Router with OpenWrt – USB Storage Auto Mount

less than 1 minute read

Block mount

Add CONFIG_PACKAGE_block-mount=y to target/linux/brcm2708/configs/rpi3b_defconfig to get block mount support

USB storage auto mount

I wanna share movies on the usb disk to phone, tablet, TV and laptop, so I expect OpenWrt will auto mounting my usb disk when inserted, this can be done through fstab like this:

diff --git a/target/linux/brcm2708/base-files/etc/config/fstab b/target/linux/brcm2708/base-files/etc/config/fstab
new file mode 100644
index 0000000..7fea64a
--- /dev/null
+++ b/target/linux/brcm2708/base-files/etc/config/fstab
@@ -0,0 +1,14 @@
+config 'global'
+       option  anon_swap       '0'
+       option  anon_mount      '0'
+       option  auto_swap       '1'
+       option  auto_mount      '1'
+       option  delay_root      '5'
+       option  check_fs        '0'
+
+config mount
+       option target   /mnt/sda1
+       option device   /dev/sda1
+       option fstype   auto
+       option options  rw,sync
+       option enabled  1

By applying this patch the router will detect if /dev/sda1 exists, if true it will be mounted to /mnt/sda1 automatically, so minidlna server will see this disk and scan the media in it.

Next post will show how to add minidlna support for OpenWrt.