[SOLVED] Easiest way to auto mount drives?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
yamete
Level 1
Level 1
Posts: 9
Joined: Fri Dec 14, 2018 3:44 pm

[SOLVED] Easiest way to auto mount drives?

Post by yamete » Thu Jan 10, 2019 7:49 pm

I've tried for a while now to set up 3 of my internal harddrives to mount on startup/boot but with no real success to what I want. I've managed to make them mount on boot but they're then owned by root and mounted in /mnt, I want them mounted in /media as they get when I manually click on their icons and with full user privileges. 2 of the drives are formatted as NTFS and 1 is formatted as Ext4 if that matters.
Last edited by yamete on Fri Jan 11, 2019 9:08 am, edited 1 time in total.

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: Easiest way to auto mount drives?

Post by philotux » Thu Jan 10, 2019 8:05 pm

Create a mount-point in /media for each one. Example:

Code: Select all

sudo mkdir /media/drive1

(change drive1 to whatever convenient name for you).

Open the app "Disks" (gnome-disk-utilty). Mark the appropriate device, click on the cogwheel and choose: "Edit Mount Options". Toggle off "Automatic Mount Options" and edit the mount point by putting in the path to mountpoint you created above (/media/drive1). You could change "Identify as" as well. My personal preference is the UUID.You might want to give the device a display name also. Click OK. Repeat these steps for each one of your devices. You could have a look at the following links as well:
https://www.techrepublic.com/article/ho ... ing-a-gui/
https://www.linuxuprising.com/2018/12/h ... artup.html

yamete
Level 1
Level 1
Posts: 9
Joined: Fri Dec 14, 2018 3:44 pm

Re: Easiest way to auto mount drives?

Post by yamete » Fri Jan 11, 2019 7:18 am

philotux wrote:
Thu Jan 10, 2019 8:05 pm
Create a mount-point in /media for each one. Example:

Code: Select all

sudo mkdir /media/drive1

(change drive1 to whatever convenient name for you).

Open the app "Disks" (gnome-disk-utilty). Mark the appropriate device, click on the cogwheel and choose: "Edit Mount Options". Toggle off "Automatic Mount Options" and edit the mount point by putting in the path to mountpoint you created above (/media/drive1). You could change "Identify as" as well. My personal preference is the UUID.You might want to give the device a display name also. Click OK. Repeat these steps for each one of your devices. You could have a look at the following links as well:
https://www.techrepublic.com/article/ho ... ing-a-gui/
https://www.linuxuprising.com/2018/12/h ... artup.html
By doing this I still end up with all files on that drive being owned by root and chown doesn't seem to change that.
Skärmbild från 2019-01-11 12-09-56.png
I want all files to be owned by me with all permissions on boot/login which I only seem to achieve by using automatic mount options but I then need to manually mount them.
Skärmbild från 2019-01-11 12-08-16.png

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 7:28 am

By doing this I still end up with all files on that drive being owned by root and chown doesn't seem to change that.
Did you try (for the ext4-formatted device):

Code: Select all

sudo chown -R $USER:$USER /path/to/mountpoint
?
Just taking the example from before (/media/drive1):

Code: Select all

sudo chown -R $USER:$USER /media/drive1
For the NTFS-formatted device, you could try adding umask=007,uid=1000,gid=1000 as shown below:
Screenshot.png
Try copying/pasting a file, changing a file and saving it to see if it works.

If still no go, I am afraid I am out of ideas

User avatar
AndyMH
Level 6
Level 6
Posts: 1062
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Easiest way to auto mount drives?

Post by AndyMH » Fri Jan 11, 2019 8:43 am

Edit your fstab file, this is the entry in mine for a HDD mounted in the ultrabay of my laptop:

Code: Select all

# mount point for HDD in ultrabay, added 3 feb 18, modded 22 oct with 2TB drive
UUID=085d40e6-75d8-4f70-af68-cf382cfe6d52 /media/Ultrabay ext4 defaults,nofail 0 2
You have to edit fstab as root, it lives in /etc (in file manager navigate to / and then right click on the /etc folder and open as root).

You can find the UUID of a drive/partition by typing blkid in a terminal. You can mount your drives/partitions wherever you want. google fstab to find out more.

This is a much better way of doing it rather than messing around with disks.

Might be best to undo whatever you have done already - you may find entries in your fstab that disks has put there. Whatever you do, DO NOT delete or amend the entries for / and /home!!
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 9:01 am

AndyMH wrote:
Fri Jan 11, 2019 8:43 am

...

This is a much better way of doing it rather than messing around with disks.
...
Just for the sake of learning and future practice, in what objective, factual way editing the fstab with "Disks" is inferior to editing it manually?

Thanks!
philotux

yamete
Level 1
Level 1
Posts: 9
Joined: Fri Dec 14, 2018 3:44 pm

Re: Easiest way to auto mount drives?

Post by yamete » Fri Jan 11, 2019 9:03 am

philotux wrote:
Fri Jan 11, 2019 7:28 am
By doing this I still end up with all files on that drive being owned by root and chown doesn't seem to change that.
Did you try (for the ext4-formatted device):

Code: Select all

sudo chown -R $USER:$USER /path/to/mountpoint
?
Just taking the example from before (/media/drive1):

Code: Select all

sudo chown -R $USER:$USER /media/drive1
For the NTFS-formatted device, you could try adding umask=007,uid=1000,gid=1000 as shown below:
Screenshot.png
Try copying/pasting a file, changing a file and saving it to see if it works.

If still no go, I am afraid I am out of ideas
This seems to have fixed it, thanks! Still, it seems like there should be an easier way to do this by now as I don't think I was alone with this issue when moving from windows.

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 9:09 am

yamete wrote:
Fri Jan 11, 2019 9:03 am

This seems to have fixed it, thanks! Still, it seems like there should be an easier way to do this by now as I don't think I was alone with this issue when moving from windows.
That's great! Glad to hear that the issue is resolved. You are welcome!
The more technical explanation of why this is the case is a bit beyond me, but you are right, it is desirable if the whole thing was a bit more straight forward.

Lycka till!
philotux
:D

User avatar
AndyMH
Level 6
Level 6
Posts: 1062
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [SOLVED] Easiest way to auto mount drives?

Post by AndyMH » Fri Jan 11, 2019 11:22 am

factual way editing the fstab with "Disks" is inferior to editing it manually
I think it is simpler and the entries in your fstab are clearer, long time since I used disks. A recommendation I picked up on this forum a couple of years ago.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
thx-1138
Level 6
Level 6
Posts: 1379
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: Easiest way to auto mount drives?

Post by thx-1138 » Fri Jan 11, 2019 12:28 pm

philotux wrote:
Fri Jan 11, 2019 9:01 am
...................................
Just for the sake of learning and future practice,
in what objective, factual way editing the fstab with "Disks" is inferior to editing it manually?

Thanks!
philotux
...probably the nicest explanation i've seen around...

User avatar
AndyMH
Level 6
Level 6
Posts: 1062
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [SOLVED] Easiest way to auto mount drives?

Post by AndyMH » Fri Jan 11, 2019 12:41 pm

...probably the nicest explanation i've seen around...
Which makes my point far more coherently that I could have (or had the time to do) :D
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
thx-1138
Level 6
Level 6
Posts: 1379
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: [SOLVED] Easiest way to auto mount drives?

Post by thx-1138 » Fri Jan 11, 2019 12:49 pm

...i especially enjoy this specific comment... :mrgreen:
/mnt/40F76A4E40B0C5CB is used to make the mount point meaningless to the user.

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 1:17 pm

thx-1138 wrote:
Fri Jan 11, 2019 12:28 pm
...probably the nicest explanation i've seen around...
AndyMH wrote:
Fri Jan 11, 2019 12:41 pm
Which makes my point far more coherently that I could have (or had the time to do) :D
thx-1138 wrote:
Fri Jan 11, 2019 12:49 pm
...i especially enjoy this specific comment... :mrgreen:
/mnt/40F76A4E40B0C5CB is used to make the mount point meaningless to the user.

Well, nothing prevents you from not accepting its default settings, meaning you don't have to necessarily end up with an entry like:
/dev/disk/by-uuid/40F76A4E40B0C5CB /mnt/40F76A4E40B0C5CB auto nosuid,nodev,nofail,x-gvfs-show 0 0
(from the link provided in the first quote above) in the fstab.

I choose to mount an NTFS-partition called Storage at /media/Storage through "Disks" and here it is how it looks like in the gui:
disks1.png
and this is the entry it puts for it in the fstab:

Code: Select all

#Entry for /dev/sda13 :
UUID=4C4F14D51F7833C0 /media/Storage ntfs-3g defaults 0 0
I have chosen to identify the partition by its UUID in the fstab, but I could have opted for LABEL, etc if I wanted to:
disks2.png
I have full rw-access to the partition and it shows in the left pane of my file manager.

So, giving a "worst case" or "most complicated" example is not a compelling argument against using the tool, since you are free to define the parameters yourself and simplify things a whole lot as demonstrated above.

cheers,
philotux

User avatar
AndyMH
Level 6
Level 6
Posts: 1062
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [SOLVED] Easiest way to auto mount drives?

Post by AndyMH » Fri Jan 11, 2019 2:29 pm

I'm not saying don't use it, I just think it is better not to. It is not that difficult to understand what fstab does and do it yourself. And with your example, mounting in /media means it will be assumed as removable and will cause the system to hang at boot (think the default timeout is around 90 secs) if it is not present because you just used the default option. If you need to understand all the fstab options, why not do it yourself?

Edit - I think mounting an NTFS partition like that results in either a read only partition or owned by root. Been there, done it.
Last edited by AndyMH on Fri Jan 11, 2019 2:37 pm, edited 3 times in total.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
thx-1138
Level 6
Level 6
Posts: 1379
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: [SOLVED] Easiest way to auto mount drives?

Post by thx-1138 » Fri Jan 11, 2019 2:31 pm

...it wasn't a 'worse' case or 'most complicated' example - it was simply 'default' settings...

If by definition you need to have read / understood man fstab & man mount - eg. as nicely shown in your own example above,
ie. if the app doesn't somehow automagically 'get it' right out of the box & you have to manually tweak quite a few of the settings,
then surely there isn't much difference than using a text editor directly (other maybe than manually changing Disks' weird 'defaults')...
Hence, in a certain sense...what other argument would you need besides this very thread actually?...

Not saying that Disks is 'useless' - i'm neither necessarily bashing it neither praising it.
And no doubt that someone should use whatever he/she finds more convenient - for whatever reason that might be.
But since you asked about it's deficiencies, i thought of answering why...not just for you, but for the OP as well,
and possibly anyone else who possibly stumbles upon this thread and/or Disks' quirkiness...with the tldr being:
"Disks frequently has non-sane defaults when it comes to auto-configuring...so better read the man / help pages first..."

Considering that besides explaining & pointing the OP to the right direction,
you also (wisely) further advised the OP to do some reading as well...then i think most likely you wouldn't disagree with such ;-)

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: [SOLVED] Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 2:50 pm

AndyMH wrote:
Fri Jan 11, 2019 2:29 pm
And with your example, mounting in /media means it will be assumed as removable and will cause the system to hang at boot (think the default timeout is around 90 secs) if it is not present because you just used the default option.
Edit - I think mounting an NTFS partition like that results in either a read only partition or owned by root. Been there, done it.
Well, how come my system boots up normally without any 90 seconds time-out and how come I have full rw-access to the partition? It's a partiton on the same internal drive as my system. I dare you to try it, as the given example in my post, to see for yourself.
Last edited by philotux on Fri Jan 11, 2019 3:12 pm, edited 1 time in total.

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: [SOLVED] Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 3:04 pm

thx-1138 wrote:
Fri Jan 11, 2019 2:31 pm
if the app doesn't somehow automagically 'get it' right out of the box & you have to manually tweak quite a few of the settings...
Well, I don't think "Disks" is an exception in that regard. Have a look at Timeshift's default settings for example. How many users haven't end up with a choked / with an un-updatable and/or un-bootable systems. I would call those settings weird as well in great need of tweaking and the app much more prone to bork your system than what "Disks" can do to it.


But since you asked about it's deficiencies, i thought of answering why...not just for you, but for the OP as well, and possibly anyone else who possibly stumbles upon this thread and/or Disks' quirkiness...with the tldr being:
"Disks frequently has non-sane defaults when it comes to auto-configuring...so better read the man / help pages first..."
I simply asked because of this:
AndyMH wrote:
Fri Jan 11, 2019 8:43 am
...
This is a much better way of doing it rather than messing around with disks.
...
curious to know about the argument and not because I didn't know what "Disk" does or doesn't do well. Is there any piece of software that gets everything right without tweaking a bit? They must be very rare, if you ask me. And besides, a knife and a hammer could potentially be very harmful tools if you don't know how to use them. You won't surely put the blame on them if you get hurt or will you?

altair4
Level 19
Level 19
Posts: 9392
Joined: Tue Feb 03, 2009 10:27 am

Re: [SOLVED] Easiest way to auto mount drives?

Post by altair4 » Fri Jan 11, 2019 3:47 pm

What I've never understood is why someone never used the installer logic to build a post-install fstab GUI.

When you go to install Ubuntu you eventually get to a part labeled "Installation Type" and one of the options presented is "Something Else". If you click on something else you are given a visual display of all your available partitions. If you double click on one you are are asked 3 questions:

[1] What filesystem? ... like ntfs,ext4,...
[2] Do you want to reformat it?
[3] Where do you want me to mount it?

The installer uses a template together with the answers to those questions. For ntfs it's:
UUID=bunch-of-numbers /mountpoint ntfs defaults,umask=007,gid=46 0 0

It's old school to be sure. An ntfs partition by default ( not to be confused with the defaults option ) automatically mounts with root as owner but permissions of 777 so it's r/w to everyone and your Aunt Tilly. So they added the umask option to render 770 permissions and made it r/w to everyone in the plugdev ( uid=46 option ) group which at first is the first user you created.

Now we can all debate if that is complete enough. Should it have nofail? Probably. Should it have the windows_names option? I would argue yes since you never know where that partition will end up and definitely if you dual boot with Windows. But either way it gets the job done without a lot of drama.

For a Linux filesystem the template is even simpler:
UUID=even-longer-bunch-of-numbers /mountpoint ext4 defaults 0 2
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
AndyMH
Level 6
Level 6
Posts: 1062
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [SOLVED] Easiest way to auto mount drives?

Post by AndyMH » Fri Jan 11, 2019 7:12 pm

Well, how come my system boots up normally without any 90 seconds time-out and how come I have full rw-access to the partition? It's a partiton on the same internal drive as my system.
Because it is still there! As I said earlier /media is normally where you put removable drives and if you take out a removable drive unless you have 'nofail' in the fstab options it will hang for 90secs or thereabouts on boot. NTFS read only - my bad, with defaults it is r/w but owned by root.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, Thinkpad T430 i7-3632 Cinnamon 19.0, Thinkpad T420 Cinnamon 18.3, Thinkpad T410 Cinnamon 17.3, Thinkpad T60 19.0 Mate

User avatar
philotux
Level 4
Level 4
Posts: 426
Joined: Sat Jul 21, 2018 11:14 am

Re: [SOLVED] Easiest way to auto mount drives?

Post by philotux » Fri Jan 11, 2019 7:31 pm

Honestly, in practice, I see no difference between mounting a device at /media or at /mnt. As long as you have nofail for an external device which might not be there sometimes, things should be fine.

Post Reply

Return to “Newbie Questions”