Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Okay I am a complete n00b here and have spent the past week trying to google a solution which I just can't seem to find so maybe if someone here ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    8

    Non-Root User Writing to USB


    Okay I am a complete n00b here and have spent the past week trying to google a solution which I just can't seem to find so maybe if someone here can help me then that'll be great.

    Basically I have a USB flash drive currently formatted under vfat. I can log in as root and the system automatically picks it up and automounts the drive successfully.

    What needs to happen is that a non-root user needs to be able write to this device while root has mounted this device. Due to other program constraints, I can not mount the device using another user so I have to do it with root.

    Any suggestions/help would be much appreciated

    Thanks in advance

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Is this being mounted via automount or via fstab?

    If you're mounting via fstab, you basically just need to add some permissions options (because the drive is FAT, it's a bit more complicated to mount). Adding a "umask=0000" option will set the device to be world-readable and world-writable.

    I don't know much about automount, but it's probably a similar option.

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    8
    Automount automatically mounts the drive. I do not know how to configure the fstab file. I tried playing with it but afterwards it doesn't even mount anymore so I replaced it with a copy before I played around with it

    So should i be editing the fstab file? I can format the drive to ext2 or ext3. Would it help with the required permissions?

  4. #4
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    41
    Logging in as root is not really recommended. If you need to run system commands that require root access you should use sudo <command>.

    Anyways you would change the permissions on the folder mounted for your usb stick (e.g /mnt/usb)

    Code:
    chown -R user:group /mnt/usb
    The -R option is recursive in case you have sub-folders under /mnt/usb

    Although it may not work on a vfat file system.

    Cheers

    JC

  5. #5
    Just Joined!
    Join Date
    Sep 2010
    Posts
    8
    Quote Originally Posted by jr0sco View Post
    Logging in as root is not really recommended. If you need to run system commands that require root access you should use sudo <command>.

    Anyways you would change the permissions on the folder mounted for you usb stick (e.g /mnt/usb)

    Code:
    chown -R user:group /mnt/usb
    The -R option is recursive in case you have sub-folders under /mnt/usb

    Although it may not work on a vfat file system.

    Cheers

    JC
    Already tried that. It returns with "Operation not permitted". This was done with root login.

    I could be completely wrong but I believe this is because the file structure is under vfat system and has no permissions to change to begin with.

  6. #6
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    41
    Quote Originally Posted by MB12345 View Post
    I can format the drive to ext2 or ext3. Would it help with the required permissions?
    ext2 and ext3 do not work under windows, if you use the usb stick under windows that is.

    Quote Originally Posted by MB12345 View Post
    I could be completely wrong but I believe this is because the file structure is under vfat system and has no permissions to change to begin with.
    Yeah that would make sense.

    JC

  7. #7
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    41
    Found this in man mount

    Code:
    mode=value
                       Set the mode of all files to value & 0777 disregarding the original permissions.  Add search permission  to  directories
                  that have read permission.  The value is given in octal.
    Maybe you could config automount to use this option

  8. #8
    Just Joined!
    Join Date
    Sep 2010
    Posts
    8
    Quote Originally Posted by jr0sco View Post
    Found this in man mount

    Code:
    mode=value
                       Set the mode of all files to value & 0777 disregarding the original permissions.  Add search permission  to  directories
                  that have read permission.  The value is given in octal.
    Maybe you could config automount to use this option
    I am a complete n00b with this. So I don't know how :S

    But having a quick read the way I understand it (I could be wrong as I don't have the knowledge of you guys), is that it sets all the permissions of the files on the USB to 777. My problem is writing to the USB...not necessarily trying to read from it.

    But if you could maybe tell me what I need to type then I could try it in the terminal console and give it a go.

  9. #9
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    41
    777 is full permissions with read, write and execute for user, user group and others

    Have a read of is it will help you understand permissions in Linux

    Linux permissions

    Moving on

    Post your /etc/auto.misc, /etc/auto.master and any other /etc/auto.* files here

    JC

  10. #10
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    877
    One way is editing fstab, you could post relevant line here and we'll help.
    Another way is add your user(s) to usb and plugdev groups. Normally, when a USB device is automounted it will have owner root:plugdev, may vary depending on distro.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •