16

I have mounted a external drive at:

# mkdir /mnt/external

and subsequently:

mkdir -p /mnt/external
mount /dev/sdb1 /mnt/external

Now only the root-user has access to write to these folders.

linux-wyee:/home/martin # dir /mnt
drwxr-xr-x 2 root root 4096 13. Dez 22:01 external

How to change this - how to change that all can write to the external drive. I need to change the permissions within the terminal.

chmod 777 /dev/sdb1 /mnt/external or something alike -
halfer
  • 19,824
  • 17
  • 99
  • 186
zero
  • 1,003
  • 3
  • 20
  • 42
  • 2
    It has nothing to do with mounting. Just change the permissions of the directory /mnt/external once it is mounted. – Ingo Dec 14 '13 at 13:45
  • 1
    Modern systems (including suse) take care of mounting external drives easily. You just plugin, and the device gets mounted as the current user, if he's in the right group. The default setup is not good enough for you? Why not? – janos Dec 14 '13 at 13:45
  • I've moved your 'solved' addendum (thanks for that) to an answer; we welcome self-answers here, even if you have accepted another one. I've also fixed the case of your writing - if you could try to write in sentence case, it means less edit work for other people here. Thank you. – halfer Jun 12 '14 at 19:16

6 Answers6

20

Try this first,

umount /dev/sdb1

chmod -R 0777 /mnt/external   

then mount with

mount /dev/sdb1 /mnt/external

or try

chmod -R 0777 /mnt/external
d-_-b
  • 21,536
  • 40
  • 150
  • 256
Balaji Perumal
  • 830
  • 1
  • 6
  • 20
4
chmod -R 777 /mnt/external

No need to specify the device. You chmod the directory recursively.

However, usually external drives are formatted with FAT32 or some sort of Windows-compatible file system, which does not have POSIX / UNIX permissions. So this step may be redundant.

How is your drive formatted?

Have you tried writing to it as a non-root user?

Brandon
  • 9,822
  • 3
  • 27
  • 37
1

A solution posted on behalf of the OP.

Update:

linux-wyee:/mnt # chown martin:users /mnt/external

See the results: - it is obvious that it works ;-)

martin@linux-wyee:/> cd mnt
martin@linux-wyee:/mnt> ls -l
insgesamt 4
drwxr-xr-x 3 root root 4096 13. Dez 19:43 external
martin@linux-wyee:/mnt> su
Passwort:
linux-wyee:/mnt # ^C
linux-wyee:/mnt #

linux-wyee:/mnt # chown martin:users /mnt/external

linux-wyee:/mnt # cd mnt
bash: cd: mnt: Datei oder Verzeichnis nicht gefunden
linux-wyee:/mnt # ls -l
insgesamt 4
drwxr-xr-x 2 martin users 4096 13. Dez 22:01 external
linux-wyee:/mnt #

It works as you see now the user martin has got permissions.

halfer
  • 19,824
  • 17
  • 99
  • 186
1

chmod -R 0777 /mnt/external

This seems to be excessive for me. Everyone on this machine can execute whatever he wants from external disk. A wide opened door for hackers. They can e.g. save a picture using a web form, change execute bit and run it as a script on your system.

Perhaps, rw access for owner and group and r for others would be a better option.

0

I had a similar problem, but the solution for me was to use the uid and gid options of the CIFS filing system. (I had to use CIFS because apparently NFS doesn't allow access via username and password, which I needed.)

IpsRich
  • 797
  • 10
  • 23
0

You can control the permissions with which you will mount your external drive using the umask option:

sudo mount /dev/sdb1 /mnt/external -o umask=000

A mask of 000 is equivalent to permissions 0777.

stackprotector
  • 10,498
  • 4
  • 35
  • 64