Question

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 -
Was it helpful?

Solution

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

OTHER TIPS

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?

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.

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.

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top