[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to change ownership of subdirectories under /media



On Sat, 3 May 2025 at 11:09, Haines Brown <haines@histomat.net> wrote:

The private message that I have quoted here ...

> On Sat, May 03, 2025 at 10:51:17AM +0000, David wrote:
> > On Sat, 3 May 2025 at 10:23, Haines Brown <haines@histomat.net> wrote:

> > > I want to enable a user to copy files to a USB key mounted on a directory
> > > under /media.
> >
> > Hi, what type of filesystem is on the USB key? extt4? vfat?
>
> Sorry, Should have mentioned that the key is vfat.
>
> > Did you read the 'Non-superuser mounts' section of 'man mount'?
>
> Yes, but couldn't make much sense of it. It seemed focused on
> options in fstab.

First, please don't ask a question on the list and then treat replies as an
invitation to begin a personalized support experience. As explained in
the FAQ for this mailing list:

* Please post answers back to the list so others can benefit: private
  conversations don't benefit people who may only be following
  along on the list or reading the archives later.

Now to assist you, here's an actual example cut and pasted from the machine
I'm using right now.

I have a USB key with vfat filesystem with label "SDS814XHD" as shown here:

$ lsblk -f | grep SDS814XHD
sdc                           vfat        FAT16    SDS814XHD  843A-B464

Here's 'grep' showing the relevant line in /etc/fstab that allows that
particular key to be mounted by any user:

$ grep SDS814XHD /etc/fstab
LABEL=SDS814XHD        /mp/sds814xhd            vfat
noauto,gid=share,dmask=7007,fmask=7117,shortname=winnt,quiet,user

Note in that line the use of the 'user' option as described in 'man mount'.

Here's what happens when a plain user 'david' mounts the USB key:

$ whoami
david

$ mount -v LABEL=SDS814XHD
mount: /dev/sdc mounted on /mp/sds814xhd.

User david owns the files:

$ ls -l /mp/sds814xhd
total 32
drwxrwx--- 3 david share 16384 1980-01-01 11:00 SDS814XHD
drwxrwx--- 2 david share 16384 2024-11-15 19:25 SIGLENT

$ umount -v LABEL=SDS814XHD
umount: /mp/sds814xhd (/dev/sdc) unmounted

I hope that example helps you to do what you need.
If you reply, please make sure that your reply goes to the
list, not to me. Thanks.


Reply to: