The following happens each time I re-plug my external USB HDDs:
The drives that I frequently unplug and re-plug, the filesystem names (is that even the correct term for it?) keep changing around. This time hdd6 is sdi1, next time it’s sdd1. I want these names to be fixed.
I searched the web and found out that there is udevadm on the turris OS. I get this, however, when trying to us it:
root@turris:~# udevadm info --path=/dev/sdi1 --query=all
device path not found
root@turris:~#
I assume I am not using it right.
Any help and pointers are much appreciated.
Or maybe there is even a different approach to solving this problem and making the names persistent?
For this kind of task is /etc/fstab the right place on common linux machine, but on Turris OS (or any OpenWRT) is the right place in /etc/config/fstab (the /etc/fstab is auto generated from this config file).
You have two options:
configure it from Luci web interface (System -> Mount Points, section Mount Points)
configure it in /etc/config/fstab similarly to this:
The uuid is from blkid command output, you can similarly use label.
It is not good idea to use just device name (like /dev/sda1) because this might change after reboot.
I think you misunderstood me and the problem I want to solve: Like you say here, I want to prevent the system from changing the filesystem name in the /dev/ directory since I need them to be fixed after I unplug and replug the device or reboot the router. I want to setup routine tasks that depend on the name of the drive in /dev/ .
Ah, ok I probably misunderstood it.
I thought that you need to heave always the same disk mounted to the particular /mnt/... directory. (If it is the case) then I would try to remove the lines option device '/dev/... from your configuration (to ensure that the disk will be “addressed” by the UUID and not by the “always changing” path in /dev/.
But if you really need to have the same device name (like /dev/sdc) for the particular physical device, then I’m not sure about the right solution for Turris OS/OpenWRT (AFAIK for normal desktop/server Linux distribution you will have to create your own custom udev rule for that, but I’m not sure if this apply also for TurrisOS/OpenWRT).
Yes, I added the /dev/ line just now to test weather or not the system would assign the path after remounting. It did not work.
Well, I need it for my convenience when addressing the drive from within the console, I don’t want to look up the /dev/ path each time, and for fixed tasks like smartmontool for those drives that get un- and replugged or after a reboot.
I was thinking custom udev rules as well, but I was not able to extract the device information bits for writing specific rules for each drive since the turris OS does not have the typical linux commands for doing it.
Yep I understood.
I found following doc: https://wiki.openwrt.org/doc/techref/hotplug
But I’m not 100% sure how this work on TurrisOS, so I’m not sure if the article is applicable for you. Maybe somebody else will have better information.
Alright, now I understand, what you want to achieve
Look at this and that article and focus on /dev/disk/by-id. Unfortunately I cannot experiment with that right now. Nevertheless I think you gonna need add a line (in fstab format) similar to the: /dev/disk/by-id/scsi-3600605b000db099011b1713421c457ad-part2 /mnt/data1 ext4 acl,user_xattr 0 1
At first plug the HDD in and check by-id: $ ls -l /dev/disk/by-id It suppose to be possible check by-* whatever (by-id, by-label, by-uuid, by-path)
And then let’s try to rewrite it into the uci syntax as horada already pointed out.