Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Attempting to mount external hard drive clobbers permissions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Armand Karlsen
n00b
n00b


Joined: 18 Aug 2005
Posts: 59
Location: London, UK

PostPosted: Wed Oct 09, 2024 9:01 pm    Post subject: Attempting to mount external hard drive clobbers permissions Reply with quote

I have an external hard drive formatted to XFS that I intend to use as an occasionally-connected offline backup and I want the normal user on my machine to be able to mount and write to it, for convenience.

I created the directory inside /mnt, then used chown and chmod to give ownership and full permissions to the user, and ls -l shows as such:
Code:
drwxrwxrwx 2 armand armand 6 Oct  9 21:27 extbak

The mountpoint is listed in /etc/fstab for read-write, allow non-root to mount:
Code:
PARTUUID=5916f543-8185-4d1a-8d6d-6e62246cc0a1   /mnt/extbak             xfs     noauto,rw,user                                                                  0       0

However, when I actually mount the drive, ownership and permissions get clobbered back to root, and it's turned read-only for everyone else:
Code:
drwxr-xr-x 2 root   root   6 Oct  9 20:42 extbak


Am I missing something really basic here, or how do I give the regular user read-write access to the drive?
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1961

PostPosted: Wed Oct 09, 2024 10:37 pm    Post subject: Reply with quote

Armand Karlsen wrote:
Am I missing something really basic here, or how do I give the regular user read-write access to the drive?

Change the permissions once mounted as it shows owners from the external drive's root after the mount.
Back to top
View user's profile Send private message
Armand Karlsen
n00b
n00b


Joined: 18 Aug 2005
Posts: 59
Location: London, UK

PostPosted: Thu Oct 10, 2024 11:10 am    Post subject: Reply with quote

grknight wrote:
Armand Karlsen wrote:
Am I missing something really basic here, or how do I give the regular user read-write access to the drive?

Change the permissions once mounted as it shows owners from the external drive's root after the mount.


Thanks, I'll give that a go :). Is there a way to make that stick so I don't have to do that every time?
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1799
Location: Germany

PostPosted: Thu Oct 10, 2024 11:34 am    Post subject: Reply with quote

It will stay unless changed again.
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
sabayonino
Veteran
Veteran


Joined: 03 Jan 2012
Posts: 1041

PostPosted: Thu Oct 10, 2024 12:11 pm    Post subject: Reply with quote

Hi .
try to change from
Code:
noauto,rw,user


to

Code:
noauto,rw,users


mount options

look at
Code:
man mount


Quote:
user
Allow an ordinary user to mount the filesystem. The name of the mounting user is written to the mtab file (or to the private libmount file in /run/mount on
systems without a regular mtab) so that this same user can unmount the filesystem again. This option implies the options noexec, nosuid, and nodev (unless
overridden by subsequent options, as in the option line user,exec,dev,suid).

users
Allow any user to mount and to unmount the filesystem, even when some other ordinary user mounted it. This option implies the options noexec, nosuid, and
nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).


change the permissions/owner to the root of the device filesystem (e.g.: /mnt/usb)
_________________
LRS 64/32
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22867

PostPosted: Thu Oct 10, 2024 5:38 pm    Post subject: Reply with quote

Armand Karlsen wrote:
Am I missing something really basic here, or how do I give the regular user read-write access to the drive?
Yes, you are missing the basic rules for how mounts work. You changed the permissions on the directory named mnt/extbak on the filesystem / (to a very insecure setting, incidentally). You then mounted a new filesystem over that directory, hiding it and all its contents. The permissions of the root of the new filesystem are the secure standard of root:root 755. The permissions on the directory mnt/extbak on / were not clobbered. They are merely hidden until you unmount.

Even with the solution given to you here, that will not allow your unprivileged user armand to create files owned as users other than armand, so some types of backup will not be possible.
sabayonino wrote:
try to change from
Code:
noauto,rw,user
to
Code:
noauto,rw,users
This is not relevant here. Your proposal only matters if OP wants multiple non-root users to be able to manage the mount status of the drive.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum