USB mounting automatically : users option?

Chris Jones jonesc at hep.phy.cam.ac.uk
Tue Mar 3 13:52:41 UTC 2009


Hi,

> Is it possible to ensure that the files on the device will be readable 
> and writable by the user who mounted the USB drive? 
> 
> I have done the following, and it may be working:
> 
>   1. mkdir /media/BLUE
>   2. labelled the USB drive "BLUE"
>   3. chmod 777 /media/BLUE
>   4. in fstab:
>         ####USB BLUE
>         LABEL=BLUE /media/BLUE ext2 defaults,users,rw,auto 0 0
> 
> So far so good.  I am not sure this is doing what I want, however, as I 
> still see the owner of some files as "1000". 

1000 was presumably the UID of your user account on the machine where 
you created the file ? The fact that you are seeing 1000 as the user on 
the second system means that you don't have a user on that system using 
UID=1000 (and thus your account on this machine has a different UID ?)

In a similar situation I found the best approach was to arrange to make 
sure I have the same UID for all the accounts I use on different 
systems. When accounts are created the UID is normally automatically 
assigned, but it is possible to choose it by hand. Of course, if some 
other account is already using the UID you want, you are out of luck. 
IIf you can do this though then you will naturally have the same 
permissions on all machines where you mount the drive, and thus it is 
the most elegant solution I think.

If this is not possible, then you could make the files on the drive rw 
for all users. e.g.

 > cd /path/to/external/drive
 > chmod -R a+wr *

This is not as elegant, but might be your best alternative.

cheers Chris





More information about the ubuntu-users mailing list