I want to add a mount point owned by user to /media
$ mkdir /media/working
$ ls -la /media | grep working
drwxr-xr-x 2 haines haines 4096 Mar 2 08:05 working
I mount a USB key on that mount point. I plug it in and do:
# dmesg
...
sdc: sdc1
sd 7:0:0:0: [sdc] Attached SCSI removable disk
FAT-fs (sdc1): Volume was not properly unmounted. Some data may
be corrupt. Please run fsck.
The error because I originally pulled the key without first
unmounting it. Assume error irrelevant.
I mount the key:
$ sudo mount /dev/sdc1 /media/working
Now comes the trouble
$ ls -la /media
total 32
drwxr-xr-x 6 haines haines 4096 Mar 2 08:14 .
drwxr-xr-x 28 root root 4096 Feb 16 14:29 ..
drwxr-xr-x 2 haines haines 4096 Jan 8 09:22 cdrom
drwxr-xr-x 2 root root 4096 Dec 22 12:50 Elements
drwxrwxr-x 2 root users 8192 Dec 31 1969 usbhd-sdc1
drwxrwxr-x 2 root users 8192 Dec 31 1969 working
The mount command creates the strange usbhd-sdc1 mount point
and mounts /dev/sdc1 on it as well as on the working mount
point. /dev/sdc1 is mount twice:
$ mount | grep sdc
/dev/sdc1 on /media/usbhd-sdc1 type vfat
(rw,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,
codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/sdc1 on /media/working type vfat
(rw,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,
codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
Also the owner of the working directory by mounting /dev/sdc1 becomes
root:users,
In /etc/group are the lines:
users:x:100:alt
nogroup:x:65:
I replace alt with haines.
I now umount the two directories. Doing causes the ownership of the
/media/working mount point to revert to owner haines:haines:
ownship of working reverts:
$ ls -la /media | grep working
drwxr-xr-x 2 haines haines 4096 Mar 2 08:05 working
I delete usbhd-sdc1 and remount /dev/sdc1 on /media/working
This time /usbhd-sdc1 mount point does not appear, but the
working mount point changes its ownership to root:root rather than to
root:owner.
I cannnot do
$ sudo chown haines:haines working
chown: changing ownership of 'working': Operation not permitted
I suppose this is because it is mounted, but if I unmount, haines
again becomes the owner.
Two questions. In group, should alt be member of users group or
should the member be user haines?
How can the mount command change ownership of a mount point? User owns
its parent directory:
$ ls -la | grep media
drwxr-xr-x 5 haines haines 4096 Mar 2 08:38 media
--
Haines Brown