Posted: Thu Apr 11, 2019 13:44 Post subject: Usb drive mount points
I have two external drives attached to my R7800 using Kongs latest build. Why after rebooting do they sometimes mount differently. What was originally mounted as/mnt/sda1 is now mounted as /mnt/sdb1 and visa versa. How can I make certain they mount at the same mount point every time.
Thank you
Don't enable automount. Mount them manually. I happen to use Tomato, but I'm sure it's the same for dd-wrt. In the following example, my single USB drive has two partitions, one label optware, the other dropbox. I update /etc/fstab w/ those partitions and tell it exactly where I want them mounted.
Code:
### always a good idea, in case things go wrong!
sleep 60
### mount optware and dropbox partitions
mkdir -p /mnt/dropbox
echo "LABEL=optware /opt ext2 defaults 1 1" >> /etc/fstab
echo "LABEL=dropbox /mnt/dropbox ext2 defaults 1 1" >> /etc/fstab
mount -a
Of course, you'd have to make some adjustments for the correct filesystem type (ext4, ntfs, etc.). Mine just happen to be ext2. Note, I only had to create the /mnt/dropbox directory since /opt is always created by the system automatically.
Don't enable automount. Mount them manually. I happen to use Tomato, but I'm sure it's the same for dd-wrt. In the following example, my single USB drive has two partitions, one label optware, the other dropbox. I update /etc/fstab w/ those partitions and tell it exactly where I want them mounted.
Code:
### always a good idea, in case things go wrong!
sleep 60
### mount optware and dropbox partitions
mkdir -p /mnt/dropbox
echo "LABEL=optware /opt ext2 defaults 1 1" >> /etc/fstab
echo "LABEL=dropbox /mnt/dropbox ext2 defaults 1 1" >> /etc/fstab
mount -a
Of course, you'd have to make some adjustments for the correct filesystem type (ext4, ntfs, etc.). Mine just happen to be ext2. Note, I only had to create the /mnt/dropbox directory since /opt is always created by the system automatically.
The above goes in the startup script.
Long time user here (3-routers, 8+ yrs, and still reading, reading, and more reading....
Pardon my ignorance, but my root filesystem in read-only which prevents editing /etc/fstab. Thought I read somewhere a way to overcome this, but can't find it anymore.
Can someone lead me in the right direction? Thanks
@eibgrad's code works great. fstab editable. Thanks again.
But my problem continues. During the mount (mount -a), I get a mount device/file unknown error for all partitions identified by LABEL. Testing, and more testing ...... LABEL, PARTLABEL, and UUID options return error. No problems using /dev/sd[ab][123]
Interestingly, Services/USB auto mount via UUID works (I think b/c All partitions on both USB's now have labels) Unfortunately, this doesn't guarantee the sd* name.
Thinking about thoroughly cleaning (dd) USB's, and formatting as single part. In the meantime, I'm using a cludge using dmesg | grep sdb3 to identify which device has multiple parts and mount accordingly. A crazy cludge I know.
Ideas or suggestions are appreciated
USB drives have GPT table with 1 & 4 partitions respectively.
DD-WRT v3.0-r39296 std (03/27/19)
Joined: 05 Oct 2008 Posts: 667 Location: Helsinki, Finland / nr. Alkmaar, Netherlands
Posted: Sun Oct 29, 2023 21:58 Post subject:
I don't currently use the following script on my R7800 or XR500, but at the time it solved the problem of random device order for me. Perhaps it can help you, too.
#!/bin/sh
# Startup script for an R7800 router running DD-WRT firmware with several partitions
# on external drives connected to a USB or eSata port either directly or through a hub.
# Mounting is controlled by the UUID's set in this script and independent from the
# device names assigned in random order by the automount function.
# The desired mountpoint for each partition is set in variables MountPoint[i];
# Finding an automatically assigned device name.
# Original code: eval Device$i="$(eval findfs UUID=$tmp_id)"
# However findfs is not available in f/w, therefore using code
# by <Kong> in post of 16-10-2018 (https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1144412#1144412):
# eval Device$i="$(blkid | grep $tmp_id | cut -d ':' -f 1)"
# UUID of a partition on an external USB or eSATA drive; leave empty if none.
UUID1='<redacted>' # UUID of NTFS partition on a LaCie 2TB external USB drive.
#MountPoint1="/opt/NAS1"
MountPoint1="/opt/WinBackup"
# UUID of a partition on an external USB or eSATA drive; leave empty if none.
UUID2='<redacted>' # UUID of ext4 partition on a LaCie 2TB external USB drive.
#MountPoint2="/opt/NAS2"
MountPoint2="/opt/LinuxBackup"
# UUID of a partition on an external USB or eSATA drive; leave empty if none.
UUID3=
MountPoint3="/opt/NAS3"
logger -t $0 "Setting UUID's & mounting points"
delay='2'
# Find device name for each UUID and mount device to set mountpoint.
for i in 1 2 # List of sequence numbers as used above.
do
eval tmp_id=\$UUID$i
# Find automatically assigned device name, if any.
eval Device$i="$(blkid | grep $tmp_id | cut -d ':' -f 1)"
if [ \$Device$i ]; then
if [ $i != 1 ]; then
logger -t $0 "Sleeping for $delay seconds..."
sleep $delay
fi
eval logger -t $0 "Mounting \$Device$i to \$MountPoint$i \(UUID=\$UUID$i\)"
eval mount -o noatime \$Device$i \$MountPoint$i || eval logger -t $0 "ERROR Mounting \$Device$i"
fi
done