2

I've been looking to get my drives to automount on boot up and for some reason they're not, I've got my Linux machine running "Ubuntu 20.04.3 LTS" I'm using the GUI version since I'm still really just learning it all, I've set the drives in the interface to mount on boot.

However when I go into my file manager or command line they're not there, what I have to do to get them working is to go into my File Manager and then "Other Locations" and my drives are found in there, after clicking on of them they load and mount, is there any other way to get these to boot up before I login and or when I do login?

It's just a hassle to do it every boot.

Thanks in advance. ~Blood

Bloodshot_pico
  • 83
  • 1
  • 2
  • 6
  • What kind of drives (the hardware)? What kind of file systems? Are the drives that you want to automount always connected (at boot), or only sometimes? - Please edit your original question (to answer my questions). – sudodus Jan 05 '22 at 16:24
  • They're always connected on boot, and they're just 1TB HDD's the machine used to be a windows Machine but it's spare so I've been messing with Linux on it every so often. And sorry I don't know what you mean about File Systems? – Bloodshot_pico Jan 05 '22 at 16:26
  • Please run the command `lsblk -o name,size,fstype` where the last column 'fstype' lists the file system. – sudodus Jan 05 '22 at 16:29
  • My main drive being the SSD is both vfat and ext4 and the HDDs are all running ext4. – Bloodshot_pico Jan 05 '22 at 16:30
  • When the drives are always connected on boot, it is a good option to add a line for each partition that you want mounted into the configuration file `/etc/fstab`. See for example [this link](https://askubuntu.com/questions/1384904/make-symlink-to-folder-on-usb-stick-to-be-owned-by-www-data-group?noredirect=1#comment2390456_1384904) where I helped another user with a similar problem. – sudodus Jan 05 '22 at 16:35
  • You can also find some good tutorials via the internet, for example [this link](https://linuxconfig.org/how-fstab-works-introduction-to-the-etc-fstab-file-on-linux) and [that link](https://help.ubuntu.com/community/Fstab) – sudodus Jan 05 '22 at 16:39
  • Yeah seems a little over my head but I'll have to give it a read and see if I can sort it, thanks for pointing me in the right direction, I was just getting the normal GUI stuff of checking my Disk settings. – Bloodshot_pico Jan 05 '22 at 16:42
  • I think you will find the tutorials useful, please read both of them at least twice. And then, if necessary, please come back here. If I am no longer at the keyboard, other people can chip in and help you. – sudodus Jan 05 '22 at 16:44
  • Yeah, no problem thanks again for the help. :) – Bloodshot_pico Jan 05 '22 at 16:45

1 Answers1

2

Following explains step by step how to configure a drive in the standard Ubuntu desktop so it automounts. Note that you must have administrator rights on the computer to be able to complete this.

Automounting the drive

  1. Decide where you want that drive to be mounted. As an example, I will assume you want to mount the drive in a directory /media/datadrive.
  2. Create the directory where the drive should be mounted. Because this directory will be within the system directories, you need administration priviledges to create it. Open a terminal and create that directory with the command sudo mkdir /media/datadrive.
  3. Open Disks. Click your drive in the left pane. The map with partitions it contains is on the right pane. A partition contains a file system. enter image description here
  4. Click the partition you want to automount during startup so it is highlighted, then click the cog icon under the map. Select "Edit mount options". enter image description here
  5. In the dialog that appears, uncheck "User Session Defaults". That makes the fields available for editing. Next to "Mount point", enter the directory where your drive will be mounted. Uncheck "Show in user interface" if you do not want an icon for the partition in the file manager. Otherwise, leave that checked.
  6. Hit OK. You will now be asked your user login password. enter image description here After hitting Enter, you are finished. The partition should be automatically available in the directory you specify next time you boot.

Regulating the permissions on the partition

A drive mounted this way is by default only accessible for the root user. You will need to grant permissions to other users on the system. For example, if you want to own the partition as your own user, then open a terminal and issue the command

sudo chown $USER:$USER /media/datadrive

Your user will now own the mount point. You will therefore be able to create, modify and delete files and directories on that partition.

Links: Making the partition available from within your home directory

To make the partition part of your home folder, you can create a symbolic link anywhere in your home directory to the mount point, or to any subdirectory on the partition. For example, you could have directories /media/datadrive/Archive and /media/datadrive/Moviecollection on the partition, and then make then directly available through links called Archive and Moviecollection in your home directory.

One way to create symbolic links is:

  1. Open two file manager windows, e.g. the left window showing the folder on your partition to which you want to create a symlink, and the other showing the folder where you want the links to be, e.g. your home folder.
  2. Hold Shift+Alt and drag the folder "Archive" (or any other folder you want to link to) to the other pane.
  3. Release the mouse: the symlink will be created.
vanadium
  • 82,909
  • 6
  • 116
  • 186