Partition mount point keeps changing

The system changes my partition mount name with a numeric suffix dynamically (Example: Name becomes Name1, Name2, and so on).

I appreciate all your suggestions to fix this problem in my Ubuntu 16.04 LTS.

Thanks


This seems to happen when three conditions are met:

  1. You mount the partition using the GUI (Nautilus or otherwise)
    • In the backend, this seems to use udisksctl mount
  2. There is no entry for the partition in the filesystem table (/etc/fstab)
    • If there were an entry, it would specify the mount point
  3. There is already a directory at the default mount point
    • The default mount point is /media/$username/$partition_label, so in this case, probably /media/dinesh/Name
    • I'm not sure why this happens. Maybe if the machine is not properly shut down?
    • It could also be a file not a dir, but practically, that doesn't happen

So, there are three solutions:

1. Delete the existing dir(s)

This is quick and dirty - more of a workaround than a solution.

With the drive unmounted, run this command:

sudo rmdir /media/$USER/Name*

Note that rmdir will only delete empty dirs, so if you accidentally run this while the drive is mounted, it shouldn't do any harm.

2. Create an entry for the partition in /etc/fstab

From nathwill's answer on a related question:

For a long-term fix, you could add the drive to /etc/fstab with a designated mountpoint. I recommend using the UUID to identify the drive.

Bonus tip: If you want the icon to be displayed when the drive is mounted, set the mountpoint somewhere within /media/. If you don't, set the mountpoint somewhere else, such as /mnt/.

If you prefer GUI, you can use Disks (gnome-disks) to set up an fstab entry:

  1. From the Dash, type "Disks" then open it
    • Or from a terminal, run gnome-disks
  2. Select the disk
  3. Select the partition
  4. Click the gear icon (for more actions)
  5. Click Edit Mount Options
  6. Disable Automatic Mount Options
  7. Set Identify as to UUID=(uuid)
  8. Set the Mount point

3. Mount the partition using CLI

This uses sudo mount, which IMO is way more hassle than the other two options, so I won't even bother explaining it.


More details

When using udisksctl mount, if the default mount point already exists, it will append 1. If the mount point with 1 already exists, it will iterate the number (2, 3, etc). It seems like earlier versions of Ubuntu used udisks --mount in the backend, which would mount to /media/$partition_label, and append an underscore if the mount point already existed. For example, see Why does the mount point keeps changing, and how can I prevent it?