Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

mounted partitions are owned by root

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
ryland
Posts: 16
Joined: 2006-02-22 11:48
Location: London UK

mounted partitions are owned by root

#1 Post by ryland »

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.

User avatar
Lysander
Posts: 643
Joined: 2017-02-23 10:07
Location: London
Been thanked: 1 time

Re: mounted partitions are owned by root

#2 Post by Lysander »

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.

bigrigdriver
Posts: 145
Joined: 2014-09-01 17:04
Location: East Central Illinois, USA

Re: mounted partitions are owned by root

#3 Post by bigrigdriver »

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 ask google before you ask on these boards.

It it isn't broken, Tweak It !!!

ryland
Posts: 16
Joined: 2006-02-22 11:48
Location: London UK

Re: mounted partitions are owned by root

#4 Post by ryland »

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

teeitup
Posts: 25
Joined: 2009-03-09 19:22

Re: mounted partitions are owned by root

#5 Post by teeitup »

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,

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: mounted partitions are owned by root

#6 Post by phenest »

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.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

Post Reply