You are not logged in.

#1 2014-02-04 21:34:04

Hurricane
Member
Registered: 2012-10-18
Posts: 77

[SOLVED]Cannot move files from mounted usb drive

When I try to move a file off of my usb drive I get the following error:

mv: cannot remove ‘homework-1.txt’: Permission denied

The usb drive is mounted to a folder that I created as a normal user in my home directory. However, when I call ls -l on my home directory it says that the directory I'm using as a mount point is owned by root:

$ ls -l | grep mnt/
drwxr-xr-x 10 root root 4096 Dec 31  1969 mnt

When I unmount the flash drive, the ownership of the mount point changes back to me:

$ ls -l | grep mnt/
drwxr-xr-x  2 hugo hugo 4096 Feb  4 16:12 mnt

When I move the file I want as a super user it works but I don't get to retain ownership of the file anymore.
How can I make it so that when I mount the usb drive I have access to it as a normal user?

Last edited by Hurricane (2014-02-05 20:19:37)


Computers are extra dumb, which is why it takes extra smart people to make them work.

Offline

#2 2014-02-04 21:42:45

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: [SOLVED]Cannot move files from mounted usb drive

That is normal.  For example, look at who owns /home, and the permissions for it.
What is the output of mount  ? Is the device mounted read only?  Is it an NTFS volume?  Did you install NTFS-3g?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2014-02-04 21:51:30

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

Re: [SOLVED]Cannot move files from mounted usb drive

How are you mounting it? If not ntfs, what filesystem is it using?


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.

Online

#4 2014-02-04 22:50:35

Hurricane
Member
Registered: 2012-10-18
Posts: 77

Re: [SOLVED]Cannot move files from mounted usb drive

ewaller wrote:

That is normal.  For example, look at who owns /home, and the permissions for it.
What is the output of mount  ? Is the device mounted read only?  Is it an NTFS volume?  Did you install NTFS-3g?

Mount gave me the following output:

$ mount

... (a bunch of other filesystem info) ...

/dev/sdb1 on /home/hugo/mnt type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

I have ntfs-3g installed. The filesystem is vfat (I know it's a bit redundant because it's in the output above but just answering your question lmao).

WorMzy wrote:

How are you mounting it? If not ntfs, what filesystem is it using?

$ sudo mount /dev/sdb1 mnt/

Computers are extra dumb, which is why it takes extra smart people to make them work.

Offline

#5 2014-02-04 22:54:23

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [SOLVED]Cannot move files from mounted usb drive

if you are using sudo, your user might not have write permissions on /mnt. You normally don't. So use sudo to mv files or mount the stick where your user has write permissions.

If you want your user to have write access, then why not use udevil -- which can also auto-mount usb sticks under /media and provide your user write access.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#6 2014-02-04 23:02:55

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

Re: [SOLVED]Cannot move files from mounted usb drive

Look into uid and/or umask mount options ('man mount'), or use a user mount tool like Inxsible suggested.

Last edited by WorMzy (2014-02-04 23:03:16)


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.

Online

#7 2014-02-05 07:48:20

fivedigits
Member
Registered: 2012-12-12
Posts: 13

Re: [SOLVED]Cannot move files from mounted usb drive

Seems to me that udev is giving ownership of the device to root and no write permission to world. Try adding something like:

SUBSYSTEM=="block" ID_BUS=="usb" GROUP="users" MODE=0660

to /etc/udev/rules.d/10-locale.rules

Read up on http://www.reactivated.net/writing_udev_rules.html

Offline

#8 2014-02-05 12:13:33

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED]Cannot move files from mounted usb drive

fivedigits wrote:

Seems to me that udev is giving ownership of the device to root and no write permission to world. Try adding something like:

SUBSYSTEM=="block" ID_BUS=="usb" GROUP="users" MODE=0660

to /etc/udev/rules.d/10-locale.rules

Read up on http://www.reactivated.net/writing_udev_rules.html

no, just no.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#9 2014-02-05 19:09:55

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED]Cannot move files from mounted usb drive

Mr.Elendig wrote:
fivedigits wrote:

Seems to me that udev is giving ownership of the device to root and no write permission to world. Try adding something like:

SUBSYSTEM=="block" ID_BUS=="usb" GROUP="users" MODE=0660

to /etc/udev/rules.d/10-locale.rules

Read up on http://www.reactivated.net/writing_udev_rules.html

no, just no.

To expand on this... the rule changes permissions on all USB block devices (and will change permissions on some sysfs nodes as well), which is dangerous and doesn't accomplish what the OP wants -- to change permissions on the filesystem. You've also given the rule an irrelevant name (locale? wat?), and then point to an incredibly outdated resource (last updated nearly 6 years ago!!!) about udev rules. udev(7) is far more relevant and up to date. It doesn't mention outdated commands which no longer exist (udev$foo were all merged into udevadm).

Offline

#10 2014-02-05 20:19:20

Hurricane
Member
Registered: 2012-10-18
Posts: 77

Re: [SOLVED]Cannot move files from mounted usb drive

Inxsible wrote:

if you are using sudo, your user might not have write permissions on /mnt. You normally don't. So use sudo to mv files or mount the stick where your user has write permissions.

The mount point's full name is ~/mnt. I have full permissions on it when the stick isn't mounted. It's only when I mount it.

As for using something to facilitate it, I'm perfectly fine with using sudo to move the files around but I will give udevil a try. I'm marking it as solved since I'm guessing if there's tools to implement the behavior I'm asking for it's because there's no way to really do it with mount itself.


Computers are extra dumb, which is why it takes extra smart people to make them work.

Offline

#11 2014-02-05 20:29:29

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

Re: [SOLVED]Cannot move files from mounted usb drive

Hurricane wrote:

there's no way to really do it with mount itself.

Mount options for fat
       (Note: fat is not a separate filesystem, but a common part of the msdos, umsdos and vfat filesystems.)
...
       uid=value and gid=value
              Set the owner and group of all files.  (Default: the uid and gid of the current process.)

       umask=value
              Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process.  The value
              is given in octal.

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.

Online

Board footer

Powered by FluxBB