LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-06-2015, 01:47 PM   #1
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Rep: Reputation: Disabled
Write permissions to external drive


I have an external disk but I can only write to it using sudo, not as my normal user.

The commands I've issued are:
Code:
sudo mkdir /media/USBSSD
sudo mount -t auto /dev/sda1 /media/USBSSD
sudo chmod 777 /media/USBSSD
sudo mkdir /media/USBSSD/share
How can I set it up so that other users can write to it?

Last edited by nix.noob; 02-07-2015 at 06:14 AM.
 
Old 02-06-2015, 01:57 PM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
You should add a line t oyour /etc/fstab like this

/dev/sda1 auto /media/USBSSD users 0 2

Last edited by Keruskerfuerst; 02-06-2015 at 02:03 PM.
 
Old 02-06-2015, 02:26 PM   #3
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you for your suggestion.
It already said

Code:
/dev/sda1       /media/USBSSD   auto    noatime           0       0
So I changed it to
Code:
/dev/sda1       /media/USBSSD   auto    users           0       2
but it didnt seem to make any difference.

Last edited by nix.noob; 02-06-2015 at 02:27 PM.
 
Old 02-06-2015, 02:48 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,503

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
To give users rw to another partition, an example below which works for me on an ext4 filesystem. Is this an ntfs filesystem and you forgot to mention that?? Makes a difference. So what happened when you ran the mkdir command, you didn't post the output.

Quote:
/dev/sda1 /media/USBSSD ext4 auto,user,rw 1 2
 
Old 02-06-2015, 04:29 PM   #5
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Original Poster
Rep: Reputation: Disabled
Hi,
Its vfat.

Code:
$ mkdir /media/USBSSD/share
mkdir: cannot create directory `/media/USBSSD/share': Permission denied

$ sudo mkdir /media/USBSSD/share
no output from this, it worked
$ sudo chmod 777 /media/USBSSD
$ echo foo > /media/USBSSD/share/foo.txt
-bash: /media/USBSSD/share/foo.txt: Permission denied
$ ls -l /media/USBSSD/
total 16
drwxr-xr-x 2 root root 16384 Feb  6 22:19 share

sudo cfdisk:

Code:
Name    Flags   Part Type   FS Type  [Label]  Size (MB)
--------------------------------------------------------------
sda1   Boot    Primary     vfat                    30016.66    *
I tried
Code:
/dev/sda1 /media/USBSSD auto auto,user,rw 1 2
and
Code:
/dev/sda1 /media/USBSSD vfat auto,user,rw 1 2
but I still get
Code:
$ echo foo > /media/USBSSD/share/foo.txt
-bash: /media/USBSSD/share/foo.txt: Permission denied
(where foo.txt doesn't exist yet)

Last edited by nix.noob; 02-06-2015 at 04:36 PM.
 
Old 02-06-2015, 04:33 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
https://help.ubuntu.com/community/Au...ountPartitions
 
Old 02-06-2015, 04:49 PM   #7
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Original Poster
Rep: Reputation: Disabled
That page (thanks for the link) suggests that for FAT partitions which are to be accessible by everyone, use the string user,auto,fmask=0111,dmask=0000 in fstab, so I changed mine to say
Code:
/dev/sda1       /media/USBSSD   vfat    user,auto,fmask=0111,dmask=0000      0       2
and tried writing the file again but still permission denied.
So then I tried adding the rw flag too but that didnt make a difference
Code:
/dev/sda1       /media/USBSSD   vfat    user,auto,fmask=0111,dmask=0000,rw      0       2

Last edited by nix.noob; 02-06-2015 at 04:50 PM.
 
Old 02-06-2015, 06:45 PM   #8
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,503

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Which Ubuntu are you using? The more recent version have flash and external devices under /media/username
Post the permissions: ls -ld /media/USBSSD
What kind of data is on it?
 
Old 02-07-2015, 05:15 AM   #9
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Original Poster
Rep: Reputation: Disabled
I'm not running Ubuntu, I'm using the most up-to-date version of raspbian.
I'm trying to connect a new empty disk to a raspberry pi to act as a cheap nas.

Code:
$ ls -ld /media/USBSSD/
drwxr-xr-x 3 root root 16384 Jan  1  1970 /media/USBSSD/
There is no data on it as it's a new disk.
 
Old 02-07-2015, 06:49 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Usually, that is done by giving the separate users a separate directory on the disk. That way they control who can read what within their directory.

You could also make the base directory sticky... (as in chmod ugo+rwxt the/media/USBSSD) which is the same as the access mode of /tmp. This allows any user to create a directory there, and then put stuff on it.
 
Old 02-07-2015, 07:07 AM   #11
nix.noob
Member
 
Registered: Aug 2013
Posts: 31

Original Poster
Rep: Reputation: Disabled
I tried
Code:
$ sudo chmod ugo+rwxt /media/USBSSD/
chmod: changing permissions of `/media/USBSSD/': Operation not permitted
In this case it's not a problem if users can edit each others files, so I'm not sure it needs to be sticky.
So I also tried without the sticky bit
Code:
$ sudo chmod ugo+rwx /media/USBSSD/
but I don't think it is altering the ability to write. I still can't create new files except with sudo
Code:
$ ls -ld /media/USBSSD/
drwxr-xr-x 3 root root 16384 Jan  1  1970 /media/USBSSD/
$ echo foo > /media/USBSSD/share/foo.txt
-bash: /media/USBSSD/share/foo.txt: Permission denied
 
Old 02-07-2015, 07:50 AM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Since you are wanting to use the drive for a NAS it would make more sense to reformat (via mkfs) it with ext3 or other linux filesystem. A FAT32 (vfat) filesystem is not compatible with linux permissions.


And mount it as:
Quote:
/dev/sda1 /media/USBSSD ext3 defaults 0 2

Last edited by michaelk; 02-07-2015 at 07:52 AM.
 
Old 02-07-2015, 07:58 AM   #13
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,503

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
My understanding has always been that Linux permissions aren't comatible with windows filesystem types. You indicate you can write to it as sudo and note the owner:group both root:root. Might also try changing one of those.
 
Old 02-07-2015, 08:08 AM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
You likely have to be root to change permissions on /media/USBSSD/

Now if it is automatically mounted at boot then the permissions will likely go away (it depends on the filesystem used for /media, which is usually tmpfs for automatic mounts - that way it is also cleaned up on reboots as /media has to be recreated on each boot).
 
Old 02-07-2015, 08:10 AM   #15
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by yancek View Post
My understanding has always been that Linux permissions aren't comatible with windows filesystem types. You indicate you can write to it as sudo and note the owner:group both root:root. Might also try changing one of those.
That translation is what Samba is used for (as well as protocol compatibility).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to mount an external ntfs drive with full read/write permissions for everyone Da9L Linux - Newbie 10 12-03-2012 05:54 AM
Ubuntu 11.10 HELP NO longer have Read Write Permissions on external NTFS USB Drive rstoesser Ubuntu 1 10-25-2011 03:23 PM
Not able to set write permissions on external hard drive. jpen8560 Linux - Hardware 19 03-22-2006 10:44 AM
Write permissions for external hard drive kg4ysy Linux - Hardware 1 05-19-2005 05:36 AM
write permissions for a storage drive Riichard Linux - General 7 12-31-2003 02:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration