How to make filesystem name persistent - Filesystem name changes after re-plug/reboot

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

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?


have you checked this out? I would recommend add another line to the /etc/fstab:
/dev/sdi1 /<path_to>/<mount_folder> ext4 defaults,nofail 0 2

EDIT: Please follow @horada’s post. And might come in handy.

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:

  1. configure it from Luci web interface (System -> Mount Points, section Mount Points)
  2. configure it in /etc/config/fstab similarly to this:
config mount
	option uuid 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
	option target '/mnt/data1'
	option enabled '1'
	option fstype 'ext4'

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.

1 Like

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/ .

I have my drives setup like this:

config mount
        option target '/mnt/hdd1'
        option device '/dev/sdc1'
        option uuid '1bc37c49-0682-4491-9548-bea1f89c2e1c'
        option enabled_fsck '1'
        option enabled '1'

config mount
        option target '/mnt/hdd2'
        option device '/dev/sdd'
        option uuid '512dac84-6a1a-4314-a762-31d4a5e4befa'
        option enabled_fsck '1'
        option enabled '1'

Maybe this question is too trivial to ask and clear to the simplest of simplest linux user… :sweat:

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:
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.

1 Like

I don’t know what this refers to exactly, yet, but I think this

may be more the solution I need. I just found it by skimming over the article you refer to. @Koleon thanks for pointing it out.

Alright, now I understand, what you want to achieve :slight_smile:
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.

config mount
	option by-id '3600605b000db099011b1713421c457ad-part2'
	option target '/mnt/data1'
	option enabled '1'
	option fstype 'ext4'

Even though I’m little bit sceptical because of the option by-id is not listed in the table at give it a try. Hopefully it will work. :slight_smile:

1 Like

Ok, I dabbled with udev, but it does not seem to implement any options I am throwing at it through its config files.

Any more help would be much appreciated.