Score:1

How to mount external drive with the same name every time?

sz flag

I'm having this issue under Xubuntu 21.10 (kernel 5.11.0-41-generic) where, when clicking on a USB external drive label in Thunar's sidebar after I've plugged it in (so it shows up but is still unmounted) gets the drive mounted with a different "label" each time. It's getting mounted under the same location, but the folder it's getting mounted at is "/media/$USER/DRIVE_NAME$NUMBER", where $NUMBER is a number that increments each time I mount the drive. This is becoming a pain for obvious reasons. Thanks in advance to anyone helping.

vanadium avatar
cn flag
Unplug the drive, then remove all remaining /medis/$USER/drive_name* directories. Perhaps then reboot. That could solve the issue, where the system can normally recreate the default mount point again, and remove it when the drive is disconnected.
sudodus avatar
jp flag
Your problem does not occur for me in a persistent live Xubuntu 21.10; 1. *Please describe your system with more details, for example how you have modified it;* 2. Also, in order to know details about your computer, please [download and run the `system-info` script](https://github.com/UbuntuForums/system-info/). Let it upload the result to a pastebin and paste the link into a new comment here. It will make it much easier to help you.
Score:1

You can tell the mount point in /etc/fstab. So you would set the name, and your partition would always mount with the same name. The header of the file is reasonably explanatory

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>

see 1:

  1. Run a combination of sudo fdisk -l and sudo blkid to identify the UUID of your partition.
  2. Edit with sudo nano /etc/fstab (or use the editor of your choice).
  3. Add a line like UUID="xxxx-xxxx" /media/<mount point of your choice> ext4 defaults,user,auto 0 1.
  4. Reboot.

The exact flags to use should be fine tuned. You have to create directory /media/<mount point of your choice> for the mount to take place.

nobody avatar
gh flag
please check your answer, the b in blkid is missing and the mountpoint have to be created before.
sancho.s ReinstateMonicaCellio avatar
@nobody - Fixed, thanks!
Score:0
jp flag

Here are the steps that I use to mount automatically an USB drive:

1. Create mount point

$ sudo mkdir /mount/<usb-drive-name>

<usb-drive-name> name it how you like, but please keep in mind that

Mount points should not have spaces in the names.

2. Find out the UUID and TYPE of your drive

$ sudo blkid

will give you a list of mounted drives, find your USB drive:

...
/dev/sda1: LABEL="my-usb-drive" UUID="e6a1db23-be63-4b39-b263-e68101bb179d" TYPE="ext4"
...

3. Edit fstab

(I use vim, but any editor is good)

$ sudo vim /etc/fstab

Usually it looks like this:

# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.  See fstab(5).
#
# <file system> <mount point>  <type>  <options>  <dump> <pass>
/dev/root       /              ext4    defaults        0 1
/swfile         none           swap    sw              0 0

Add this line if TYPE is ext4 (linux partition):

# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/swfile              none                  swap           sw                                           0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ext4 defaults                      0 2

Add this line if TYPE is ntfs (windows partition):

# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/swfile              none                  swap           sw                                           0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ntfs defaults                      0 0

Add this line if TYPE is fat (all OS partition):

# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/swfile              none                  swap           sw                                           0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> fat defaults                       0 0

The PASS (fsck order param) explanation:

In practice, use "1" for your root partition / and 2 for the rest. All partitions marked with a "2" are checked in sequence and you do not need to specify an order.

For the pass param, use "0" to disable checking the file system at boot or for network shares.

Here are the fstab options explained.

4. (optional) Add USB drive to your home directory

If you want that mounted usb drive to appear also automatically in your HOME directory, add this line to fstab:

# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/swfile              none                  swap           sw                                           0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ext4 defaults                      0 2
/media/<usb-drive-name>  /home/<USERNAME>/<usb-drive-name>  none  bind                                 0 0
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.