1 de Agosto, 2021

DD-WRT: Mount USB Storage Predictably

DD-WRT, Informática, ISP, Linux, Open-Source

DD-WRT: Mount USB Storage Predictably

1 de Agosto, 2021 | DD-WRT, Informática, ISP, Linux, Open-Source

DD-WRT’s WebUI includes an “Automatic Drive Mount” feature that works just fine until you’ve multiple USB drives. It seems that when the router reboots USB drives get mounted in different/unpredictable paths. At the end of this article you’ll be able to have predictable USB mount points.

The first step to fix this annoyance is to disable Automatic Drive Mount under Services > USB:

Now in my case I’ve two USB devices, 1) a flash drive for Entware that I want to mount to /opt and 2) an extra HDD for bulk data storage that I want to mount at /mnt/data.

Lets’s find out the UUIDs of the partitions by using blkid:

root@router:~# blkid
/dev/sdb3: LABEL="DATA" UUID="C0E4F8AFE4F8A934"                        # --> MY BULK STORAGE
/dev/sdb1: LABEL="SYSTEM" UUID="AE4F-0B66"
/dev/sda1: LABEL="SWIFT" UUID="90a42e1e-f700-40b1-b6c9-efdbdc46b9a1"   # --> MY ENTWARE PARTITION

Now under Administration > Commands we can add the following Startup commands:

# Mount OPT
insmod crc16
insmod mbcache
insmod jbd2
insmod ext4
mkdir -p /opt
mount -t ext4 $(findfs UUID="90a42e1e-f700-40b1-b6c9-efdbdc46b9a1") /opt -o rw,noatime,nodiratime,nobarrier,data=ordered,init_itable=0

# Start Entware
#sleep 5
/opt/etc/init.d/rc.unslung start

Don’t forget to change the UUID in the command above to match your Entware partition. At this point if you reboot you should have Entware working again.

Now, since my bulk storage is an NTFS partition, at v3.0-r47097 we need to load yet another module:

# Mount Data Storage
insmod ntfs3
mkdir -p /mnt/data
mount -t ntfs3 -o compression,direct_io,big_writes $(findfs UUID=C0E4F8AFE4F8A934) /mnt/data

If you’re using DD-WRT < v47000 you’ll need to use fuse instead:

# Mount Data Storage
insmod fuse
mkdir -p /mnt/data
ntfs-3g -o compression,direct_io,big_writes $(findfs UUID=C0E4F8AFE4F8A934) /mnt/data 

Congratulations! 🎉
Now your storage will be in the same predictable path at every reboot.

Note: If you’re using MiniDLNA you’ll to restart it right after mounting your storage with:

# Restart MiniDLNA
killall minidlna
minidlna -f /tmp/minidlna.conf