USB mount after reboot the dev/sdxy changes on mounts

Hi all. I'm hoping to get some help as I have been working on this for days. I have added a 4 port USB hub to my Archer A7 v5 router with the latest firmware. 24.10.5. Here is the situation... I am new to openwrt and linux.

I plugged in the hub and have a USB dongle with 2 partitions 1 swap and one for overlay. I have them setup in Luci to mount the swap at /dev/sda1 /mnt/sda1 and the overlay at /dev/sda2 /mnt/sda2.
If I then hot plug or just reboot with the second usb, hard drive and setup the 2 partitions mounting /dev/sdb1 /mnt/sdb1 and the second one as /dev/sdb2 /mnt/sdb2.. These 2 partitions will be shared with windows so they are formatted as ntfs. I GAVE UP ON GETTING NTFS TO WORK NOW USING EXT4 with DISKGenios installed in windows .) I finally get all of this to work and I do a reboot and my mounts are messed up. What was dev/sda1 becomes /dev/sdb1 etc. No matter what I do I cannot keep them from changing on a reboot. I have tried putting the devices into different ports on the hub to no avail. Not sure what to provide here but let me try. Here is Luci mount points and FSTAB with 2 drives and lsusb. So what I end up with is the wrong device connected to the mount points.

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 swap
option uuid '8becd8d3-0196-4c07-8ad3-9f4b06b2b3eb'
option enabled '0'

config mount
option target '/overlay'
option uuid '41705ab3-5fa0-418a-b6f0-3d3ad141cdc6'
option enabled '1'

config mount
option target '/mnt/sdb1'
option uuid '77cb29d7-759f-dc01-704b-29d7759fdc01'
option enabled '1'

config mount
option target '/mnt/sdb2'
option uuid 'e6bff1d8-759f-dc01-60af-f1d8759fdc01'
option enabled '1''

/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=ehci-platform/1p, 480M
ID 1d6b:0002
|__ Port 001: Dev 002, If 0, Class=[unknown], Driver=hub/4p, 480M
ID 2109:2812
|__ Port 003: Dev 006, If 0, Class=[unknown], Driver=usb-storage, 480M
ID 1908:1320
|__ Port 004: Dev 003, If 0, Class=[unknown], Driver=usb-storage, 480M
ID 058f:6387

After

Put the image in a reply as the system would not let me imbed it.

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 swap
option uuid '8becd8d3-0196-4c07-8ad3-9f4b06b2b3eb'
option enabled '0'

config mount
option target '/overlay'
option uuid '41705ab3-5fa0-418a-b6f0-3d3ad141cdc6'
option enabled '1'

config mount
option target '/mnt/sdb1'
option uuid '77cb29d7-759f-dc01-704b-29d7759fdc01'
option enabled '1'

config mount
option target '/mnt/sdb2'
option uuid 'e6bff1d8-759f-dc01-60af-f1d8759fdc01'
option enabled '1'

root@OpenWrt:~# lsusb -vt
/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=ehci-platform/1p, 480M
ID 1d6b:0002
|__ Port 001: Dev 002, If 0, Class=[unknown], Driver=hub/4p, 480M
ID 2109:2812
|__ Port 003: Dev 003, If 0, Class=[unknown], Driver=usb-storage, 480M
ID 1908:1320
|__ Port 004: Dev 004, If 0, Class=[unknown], Driver=usb-storage, 480M
ID 058f:6387

Thanks in advance.

here is the second pic of mount points

But the mount points don't change, correct?

The device name assigned to each USB device may change depending on the order they are detected / powered up.

When mounting the uuid is usually used to match a file system to a mount point independent of which device it showed up on.

1 Like

No the Mount points stay the same. Here is my concern and reason I thing this is a problem. Maybe I am not seeing this correctly...or I do not understand linux enough which could be...

If I create a swap on dev1 and mount it on mnt1 and then on the next boob mnt1 is now pointing to dev2 isn't that a problem? isn't the dev number pointed to the hardware dev?

Same for overlay. It was created on dev2 mount on mnt2 but on next boot mnt2 points back to dev1 which was my swap device.

Same for shared devices. The share points to a mnt and if the mnt now points to a different device then that would be a problem. I have not tested the share which I will do now and update this.

I see the same partitions have the same mount point, and most importantly, the same UUID.

Your post is quite verbose, but I don’t understand your issue (aside from cosmetics).

My assumption was that the dev file once created would stay attached to the device so having a mount point pointing to the 'wrong' dev file would be pointing to the wrong device.

That's exactly why, for persistent mounts, you don't reference device nodes directly. Instead you use stable identifiers like a filesystem's UUID, and have them resolved to their current device nodes before mounting. This way, device nodes can change, but the mounts will always point to the correct nodes.

1 Like

Thanks takimata for that. Gee I wasted a lot of time.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.