0

On Linux, all connected disks have ambiguous mountpoint names to user.

For example, if I connect a USB then Linux (udev?) mounts it to a directory like this:

/media/username/78128SDGHJ23G

But I want to mount block devices to a directory which is named with their /dev/ names.

For /dev/sdb1 it should be like this:

/media/username/sdb1

So users can access the mounted blocks easily without looking for which random numbers points which devices.

How can I do that, should I need to write an udev rule? If so, is there any example how to do this?

Thanks!

1
  • Sorry, I haven't used automounting with USB devices in awhile; didn't realize it added an entry in /etc/fstab. I'll delete my answer. Commented Jun 25, 2022 at 15:33

1 Answer 1

0

The mounting and the mountpoint naming is done by UDisks and the name is chosen (in order of preference) as one of: filesystem label, filesystem UUID or disk + number as a fallback if both label and UUID are empty/not set. In your case it uses UUID (or in your case I guess NTFS volume serial number which is used instead of UUID for NTFS).

This is not configurable, if you don't like the mountpoint generated based on the UUID, your options are:

  • Use filesystem label. For NTFS you can set label with ntfslabel and then the mountpoint will look like /media/<user>/<label>.
  • Add fstab records for the device. UDisks will use the mountpoint specified in fstab when (auto)mounting.
  • Do the mounting manually.
  • Use a different method for automounting. You can for example create your own udev rules to mount a newly created device and select your own mountpoint that way.

Btw. even if it would be possible to use the device name, I don't think it would be easier to use something that changes based on the number of devices you have connected. If you are not using a GUI filesystem manager that uses different ways to identify the external devices you can also simply check with for example lsblk to see what block device is mounted where.

2
  • Thanks for little information and suggestion but I just want to know how can I change automount options so I can mount it a mountpoint with dev name. Not the answer looking for. Commented Jun 25, 2022 at 7:10
  • Sometimes the answer is "that is not possible", not everything is user configurable and all you can do is a) report bug/rfe with your desired functionality, b) find an alternative approach (that might not entirely meet your needs) or c) find a different tool that meets your needs (and there unfortunately isn't much competition, for example udiskie provides a nice UI for automounting but also uses UDisks and doesn't allow to set custom mountpoint). Commented Jun 25, 2022 at 7:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.