mounted partitions are owned by root

New to Debian (Or Linux in general)? Ask your questions here!

mounted partitions are owned by root

Postby ryland » 2017-05-05 13:37

I have searched through these forums but can't find a post relating to this problem.

I am running a fresh install of Debian KDE 8.7.1. In Settings - removable devices, I have ticked "enable auto mounting on login" but nothing happens.
Just using GUI - with gparted the mount menu item is greyed out even though gparted is opened with root password. With Gnome-Disk-Utility (Disks) the partitions will mount ( with root password) but are then "owned" by root so to work on them is a pain. With Disks I can edit the mount options to mount on startup but this results in root ownership again. I know I could edit fstab file but I think I am missing something simple here. USB memory sticks auto mount on insertion with no problems.
ryland
 
Posts: 16
Joined: 2006-02-22 11:48
Location: London UK

Re: mounted partitions are owned by root

Postby Lysander » 2017-05-05 14:05

I've never been able to automount my secondary and tertiary hard drives, but on reflection it's much better that way. They're mostly backup data and it's more secure. Yes, USB sticks mount with no problem, as they should.
User avatar
Lysander
 
Posts: 313
Joined: 2017-02-23 10:07
Location: London

Re: mounted partitions are owned by root

Postby bigrigdriver » 2017-05-05 17:06

IF the external drive is normally connected, you can enter it in /etc/fstab and have it automount on boot. However, on boot, if the drive is disconnected, you will get some sort of error message (non-critical).

IF the drive is frequently disconnected and reconnected, you will need a udev rule which tells the system what to do when the drive is reconnected.

Now, with the drive connected and mounted, if you open a console and run the command fdisk -l (as root), you should see the drive listed.

For example, on my system, my external drive is /dev/sdb, which has only one partition, /dev/sdb1.

If I run ls -l ( long listing of ls), I see my backups drive (the external) as /mnt/backups. It looks like this:
Code: Select all
$ -l /mnt/backups

drwxr-xr-x  2 root root 4.0K May 19  2016 backup

which shows owner:group as root user and root group.

In your case, you want your user to be able to access the drive and read,write,execute on that drive. In this case, execute means cd into that drive in order to read/write.

So, things to do:

1. create a new group. Call it whatever you like. Use the addgroup command to create the group.

2. add your user name to the group. Use the useradd command. The command will be something like this:
Code: Select all
sudo adduser user group

3. change the group ownership on the external drive mount point. Use the chgrp command.
Code: Select all
chgrp -R <your new group name> <external drive mount point>

For my backups, I would use the command: chgrp -R <group name> /mnt/backups.
The -R means recursive. That changes the group for all files/directories in /mnt/backups.
In the example I used above, I would use
Code: Select all
chgrp -R <new group> /mnt/backups.

4. Finally, change the permissions for the group so that you can read/write/execute. Use the chmod command.
Code: Select all
chmod g+rwx /mnt/backups

for my example mount point.
Registered GNU/Linux user #170078

Go as google before you ask on these boards.

It it isn't broken, Tweak It !!!
bigrigdriver
 
Posts: 124
Joined: 2014-09-01 17:04
Location: East Central Illinois, USA

Re: mounted partitions are owned by root

Postby ryland » 2017-05-06 13:09

Thanks for your input guys. These partitions I am dealing with are on a seperate SSD to the one the booting system is on.
The thing is, I was looking for a simple way to achieve this. Editing fstab is an option, the partitions don't change often, but I would need to read up the man page every time as I don't have a good memory for this type of thing ( plus my spelling is soooo bad serious mistakes can be maid(sic)).

I am dual booting with MINT KDE while I try to migrate all my needs back to Debian as I was looking for a more "vanilla" experience. In Mint these partitions auto mount with my ownership by just ticking the boxes in System Settings/Removable Devices but in Debian these are not activating anything. Because the "mount" menu item in gparted is greyed out I am thinking there may be an issue with the mount command or a "groups" issue with the user!

##extracted line from mtab in the Mint installation.
/dev/sdb5 /media/ry/FILES fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
ryland
 
Posts: 16
Joined: 2006-02-22 11:48
Location: London UK

Re: mounted partitions are owned by root

Postby teeitup » 2017-05-07 06:49

Think of the disks as system resources and not user resources.

As root cd into the mounted disk.
Then create a directory named after your username. (think /home as a guide)
Then change the ownership to your username.
Your user will have unfettered access to that directory. You can fill the entire drive using this directory.

# mkdir ryland
# chown ryland:ryland ryland
# exit
$ cd ryland
$ touch testfile

then in your home directory create a symlink to the newly created directory for easy access.

I mount 3 extra drives on my system, data1, data2, data3,
I the create a directory for my user in each one.
A symlink in my home directory to these directories makes them easily accessable.

Good Luck,
teeitup
 
Posts: 25
Joined: 2009-03-09 19:22

Re: mounted partitions are owned by root

Postby phenest » 2017-05-07 09:37

ryland wrote:Thanks for your input guys.

I wish I could say the same. Your information comes in dribs and drabs. You should mention everything in your first post.
ryland wrote:These partitions I am dealing with are on a seperate SSD to the one the booting system is on.

New information received.

How is this SSD connected? USB or SATA? If it's SATA, then it's on a permanent connection, yes? Then edit fstab and add this:
Code: Select all
/dev/sdb1 /home/ssd-sdb1 ext4 defaults 0 2

Then create a folder at /home/ssd-sdb1. Obviously, your SSD may not be sdb1, so amend as necessary, and change the folder to whatever name you want, but be sure to change in fstab as well.
ryland wrote:Editing fstab is an option, the partitions don't change often

If the partitions are going to constantly change, then you would have to mount manually, as I know of no automatic way to cope with that.
ryland wrote:but I would need to read up the man page every time as I don't have a good memory for this type of thing ( plus my spelling is soooo bad serious mistakes can be maid(sic)).

If you're referring to fstab then, if you make a mistake, it simply won't mount it. Make a back up of fstab before you start. If your referring to the mount command, making a mistake should simply mean that nothing is mounted and no harm done.
ryland wrote:##extracted line from mtab in the Mint installation.
/dev/sdb5 /media/ry/FILES fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0

Now you're just making it complicated. Don't worry about this, and just edit fstab.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable