Usb drive mount points

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
Mrmad1966
DD-WRT Novice


Joined: 19 Oct 2017
Posts: 37

PostPosted: Thu Apr 11, 2019 13:44    Post subject: Usb drive mount points Reply with quote
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
Sponsor
Mrmad1966
DD-WRT Novice


Joined: 19 Oct 2017
Posts: 37

PostPosted: Fri Apr 12, 2019 10:03    Post subject: Reply with quote
eibgrad wrote:
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.


Thanks. Hadn't even noticed the auto drive mount.
MesMurized
DD-WRT User


Joined: 08 Aug 2017
Posts: 84

PostPosted: Fri Apr 26, 2019 20:21    Post subject: Reply with quote
eibgrad wrote:
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

WRT32X v3.0-r39296 std (03/27/19)
MesMurized
DD-WRT User


Joined: 08 Aug 2017
Posts: 84

PostPosted: Sat Apr 27, 2019 3:45    Post subject: Reply with quote
MesMurized wrote:

Code:
cp /etc/fstab /tmp/fstab
mount -o bind /tmp/fstab /etc/fstab
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

That was the trick. Thank you, thank you, thank you
MesMurized
DD-WRT User


Joined: 08 Aug 2017
Posts: 84

PostPosted: Mon Apr 29, 2019 0:54    Post subject: Reply with quote
@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)
Sp1derman
DD-WRT User


Joined: 16 Jun 2006
Posts: 152
Location: Germany, BW

PostPosted: Wed Oct 25, 2023 22:00    Post subject: Reply with quote
maybe this works for you
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=335297
ArjenR49
DD-WRT Guru


Joined: 05 Oct 2008
Posts: 667
Location: Helsinki, Finland / nr. Alkmaar, Netherlands

PostPosted: Sun Oct 29, 2023 21:58    Post subject: Reply with quote
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];

# Setting UUID's & mounting points
logger -t $0 "Mounting USB/eSATA drives"

# 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
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum