You are not logged in.

#1 2015-08-10 18:39:59

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

[SOLVED] How to mount USB as normal user?

Whenever i try to mount my USB stick i have to mount it using sudo prefix which means i mount it as root user. However, the problem is that, if i mount it as root, normal user will not be able to write to USB stick.

I read Arch Linux tutorial how to mount USB as normal user but next line doesn't seem to work for me.

mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick"

When i run it, it mounts USB stick without errors, however, i still can't write as normal user. Can you help me out guys? Also, can somebody explain me what are all these options like gid, fmask and dmask ?

P.S. /mnt folder owner is root (root).

Last edited by filipbekic01 (2015-08-11 19:22:41)

Offline

#2 2015-08-10 18:42:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

What are the permissions for /mnt and /mnt/usbstick?
Post the commands you run and the errors you got.

When posting configs, code or command output, please use [ code ] tags https://bbs.archlinux.org/help.php#bbcode

like this

It makes the code more readable and - in case of longer listings - more convenient to scroll through.

Offline

#3 2015-08-11 00:14:48

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

karol wrote:

What are the permissions for /mnt and /mnt/usbstick?
Post the commands you run and the errors you got.

When posting configs, code or command output, please use [ code ] tags https://bbs.archlinux.org/help.php#bbcode

like this

It makes the code more readable and - in case of longer listings - more convenient to scroll through.

Okay i edited my post, sorry for being slipslop.

Offline

#4 2015-08-11 00:18:31

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

filipbekic01 wrote:

can somebody explain me what are all these options like gid, fmask and dmask ?

Since these are options for the 'mount' command, I suggest reading 'man mount'.

Offline

#5 2015-08-11 10:37:10

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

Alright, but still can't figure it out. I mean, how to mount as normal user?

Offline

#6 2015-08-11 10:55:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

I've asked you a few question and you answered only some of them.

Offline

#7 2015-08-11 11:06:59

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

karol wrote:

What are the permissions for /mnt and /mnt/usbstick?
Post the commands you run and the errors you got.

Okay if you mean on these questions, i edited my post and i wrote up there that permissions are (root) root (drwxr-xr-x). Also i said that i do not have errors when command executes, i just can't write as normal user to my USB stick smile

Last edited by filipbekic01 (2015-08-11 11:07:34)

Offline

#8 2015-08-11 11:15:08

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

Are you writing with the mount command? If not, what command do you use? How do you know it didn't work?
Mounting as a user is one thing, writing as a user is another.

Yes, you did edit your post and answered some of my questions. Are you going to answer the other part of my question about permissions?

Offline

#9 2015-08-11 12:12:11

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,873
Website

Re: [SOLVED] How to mount USB as normal user?

Please stop silently answering questions by editing your previous messages, it breaks the flow of the thread and makes it difficult to follow.

What filesystem does this USB stick have on it? Are you sure that it's sda1?

filipbekic01 wrote:

I read Arch Linux tutorial how to mount USB as normal user but next line doesn't seem to work for me.

mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick"

Is this the "tutorial" you're following? If so, you have misread it. This command should be run as root, not a normal user.

Also, can somebody explain me what are all these options like gid, fmask and dmask ?

See http://www.tuxera.com/community/ntfs-3g-manual/#6

Mod note: moving to NC.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#10 2015-08-11 12:13:48

bleach
Member
Registered: 2013-07-26
Posts: 264

Re: [SOLVED] How to mount USB as normal user?

if its ext4 it preservers ownership including root mounted drive so chown /mnt/usbstick(when mounted). if its not ext4 let us know.

Last edited by bleach (2015-08-11 12:17:50)

Offline

#11 2015-08-11 18:27:42

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

Okay so here is what i get when i do lsblk command (my USB stick is sdb (FAT32)):

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 119.2G  0 disk 
├─sda1   8:1    0   500M  0 part 
├─sda2   8:2    0  98.8G  0 part /mnt
├─sda3   8:3    0    19G  0 part /
└─sda4   8:4    0     1G  0 part [SWAP]
sdb      8:16   1   7.5G  0 disk 
└─sdb1   8:17   1   7.5G  0 part 
sr0     11:0    1  1024M  0 rom 

And yes WorMzy, that's the tutorial. This is how i did it:

[filip@dell ~]$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sdb1 /mnt
[filip@dell ~]$ cd /mnt
[filip@dell mnt]$ touch testfile
touch: cannot touch ‘testfile’: Permission denied

So you see, it still says Permission denied.

Offline

#12 2015-08-11 18:30:55

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

I suggest you create a subdirectory in /mnt, give it proper permissions and try again.

Offline

#13 2015-08-11 18:41:52

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

Okay i made /mnt/usb directory and executed

chmod 777 /mnt/usb

But i still get this error

[filip@dell usb]$ ls
System Volume Information
[filip@dell usb]$ touch test.txt
touch: cannot touch ‘test.txt’: Permission denied

Offline

#14 2015-08-11 18:42:59

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

What's the output of

ls -l /mnt

Offline

#15 2015-08-11 18:43:52

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

drwxrwxr-x 3 root users 4096 Aug 11 20:40 usb

Offline

#16 2015-08-11 18:44:16

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

Why is it owned by root?

Offline

#17 2015-08-11 18:46:04

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

Sorry i am newbie. How to change it?

Offline

#18 2015-08-11 18:46:10

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,873
Website

Re: [SOLVED] How to mount USB as normal user?

Are you a member of the users group?


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#19 2015-08-11 18:48:00

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

$ sudo mount /dev/sdb1 /mnt/usb
$ ls -l /mnt
total 5
drwxr-xr-x 2 root  root  4096 Oct 19  2014 cd
drwxr-xr-x 3 karol users 1024 Aug 11 12:49 usb
$ touch /mnt/usb/foo
$ ls -l /mnt/usb/foo
-rw-r--r-- 1 karol users 0 Aug 11 20:45 /mnt/usb/foo

Offline

#20 2015-08-11 18:48:52

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

No, i am member of wheel and filip groups. But if i do:

usermod -G users filip

I will overwrite wheel group. How can i append multiple groups?

Last edited by filipbekic01 (2015-08-11 18:49:35)

Offline

#21 2015-08-11 18:50:15

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How to mount USB as normal user?

karol wrote:

Why is it owned by root?

filipbekic01 wrote:

Sorry i am newbie. How to change it?

As bleach said https://bbs.archlinux.org/viewtopic.php … 2#p1552342 , using 'chown'.

WorMzy wrote:

Are you a member of the users group?

filipbekic01 wrote:

No, i am member of wheel and filip groups. But if i do:

usermod -G users filip

I will overwrite wheel group. How can i append multiple groups?

Read the 'usermod' man page.

Last edited by karol (2015-08-11 18:51:49)

Offline

#22 2015-08-11 18:57:30

filipbekic01
Member
Registered: 2015-08-10
Posts: 41

Re: [SOLVED] How to mount USB as normal user?

WorMzy wrote:

Are you a member of the users group?

Solved! The problem was that i said gid=users and my account filip was not in that group. Now it works, thank you guys, i've been playing with Linux for a few days only, trying to figure it out, i really like organisation of system.

Offline

#23 2015-08-11 19:08:09

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,873
Website

Re: [SOLVED] How to mount USB as normal user?

Great stuff. Please remember to mark your thread as solved by editing your first post and prepending "[solved]" to the title.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB