5

I have a 32GB flash drive, formatted as ext4 (I am using it to store files larger than fat32 formatting allows), which I set up using my computer, on which I am the administrator and only user. On this computer I own the flash drive and can use it.

On another Ubuntu computer (I have administrative rights but am not the main user) it mounts under the main user and I can't access it.

I have tried changing the ownership of the flash drive on the other computer to my user, but then back on my computer it is owned by 1001 - user #1001.

Can anyone tell me why this is, and is there any way to get around this?

Any help will be appreciated.

Thank you.

hat
  • 233
  • Did you tried this? https://askubuntu.com/questions/738726/permissions-changing-ownership?s=1|0.5015 – Redbob Sep 11 '17 at 16:45
  • I have tried this, the issue is that I need complete access to the flash drive from both computers. Changing the ownership and group on one computer takes away my ownership on the other. I have not tried it on a third computer to see what happens though. – hat Sep 11 '17 at 16:52
  • Have you tried maybe formatting your drive as exFAT? You would have to install the exfat-utils into your Ubuntu installations so they will see the drive, but it does allow for files larger than 4GB. – Terrance Sep 11 '17 at 17:00
  • I would rather use a format supported on Ubuntu by default, as I (not very often) need to use it with other Ubuntu computers as well. I will give it a try, however, if I can't find a better solution. Thanks for the quick responses. – hat Sep 11 '17 at 17:50

1 Answers1

3

I have solved this issue! (After a lot of research). See the (rather lengthy) answer below.

Note: I believe this solution will also work for ntfs file systems, which have the same 'quirk'.

Problem:

This issue has all to do with user id's and group id's.

An ext4 file system is owned by one user, but its ownership is recognised by that user's user id or uid rather than the user name. It is usually also owned by that user's group, which has the same id (group id or gid, i.e. if uid=1002 gid=1002) In other words, if user 'A' owns the file system on one computer and has the uid 1001, user 'E' on another computer who also has the uid of 1001 automatically owns the file system.

Ubuntu user id's start at 1000, meaning that as I am the only user on my computer, my uid is 1000. On the other computer, however, my uid is 1001. This is why it mounts under the main user on that computer. It is mounting under the same uid.

Solution:

As said above, a file system owned by a user is usually owned by their group. User groups can contain more than one user, so you can add yourself to the group which owns the file system.

You can use:

sudo adduser [user] [group] or sudo usermod -a -G [group name] [user name]

(For more info on these commands, see this question.)

to add a user to an existing user's group, giving them access to files owned by that user.

Add your user to the group, make sure that the owner's group has full access to the file system, and problem solved!

hat
  • 233