Access my USB stick

Message
Author
User avatar
andreas
Posts: 15
Joined: Tue May 08, 2018 3:21 pm

Access my USB stick

#1 Post by andreas »

Hi
my problem relates to the access rights to my USB stick.
The command stat shows: 0755 / drwxr-xr-x Uid: 1000/andreas Gid: 1000/andreas
How can I change my access rights so that I will be able to copy files to / from that USB stick, or delete them ?

Thanks for your advice
andreas

User avatar
mxer
Posts: 211
Joined: Fri Sep 21, 2018 9:09 am

Re: Access my USB stick

#2 Post by mxer »

For me, I don't bother, I just use sudo, &/at the command line - but you can change the permissions of the mount point, as well as the files on it, if it has a decent file system on it, like ext2/3/4.
(FOSS, Linux, & BSD since 1999)

User avatar
dolphin_oracle
Developer
Posts: 20001
Joined: Sun Dec 16, 2007 1:17 pm

Re: Access my USB stick

#3 Post by dolphin_oracle »

I'm going to guess thats the info for the mount point folder? and that your usb is formated ext4?

you have two options.

1. add a folder (sudo mkdir path_of_new_folder) and give your user full permissions to that folder (sudo chown path_to_folder USER:USER) and then store all your stuff in that folder.

I suppose you could do that to the root folder of the stick,but I've not had luck with actually getting that to work.

or

2. format the stick such that your user owns the root filesystem of the stick

https://mxlinux.org/wiki/system/format- ... ular-user/
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
andreas
Posts: 15
Joined: Tue May 08, 2018 3:21 pm

Re: Access my USB stick

#4 Post by andreas »

Hi,
many thanks for your feedback.
I forgot to mention that when I run the command sudo lsblk -f, it shows for that USB stick: /dev/sdb1 vfat and mount-point is: /media/andreas/"Title"
I guess that the filesystem vfat does not support Linux permissions, because FAT (e.g. FAT32, VFAT) is a Microsoft-owned proprietary filesystem ? Is my assumption correct ?

andreas

User avatar
mxer
Posts: 211
Joined: Fri Sep 21, 2018 9:09 am

Re: Access my USB stick

#5 Post by mxer »

Yes, you are correct.

That's one of the reasons I got used to just using sudo to write to them. :happy:
(FOSS, Linux, & BSD since 1999)

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Access my USB stick

#6 Post by fehlix »

andreas wrote: Sun May 26, 2019 12:48 pm I guess that the filesystem vfat does not support Linux permissions, because FAT (e.g. FAT32, VFAT) is a Microsoft-owned proprietary filesystem ? Is my assumption correct ?
yes and no. Permission and ownership announced for those mounted filesystem like . vfat,ntfs or exfat,
are determined through the mount options during the mount operation.
So if you e.g. set UID and GID mount option to root you would not have write permissions on a vfat FS.
If the mount-options are set to uid/gid of the user, e.g. like when clicked in Thunar to mount, you get ownership permissions,
as shown in your first post, which are read/write enable for the user.
In addition to permission/ownership o the filesystem you can mount the partition readonly, which would deny any write operation on that mount.
So all depends how those USBsticks have been mounted.
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
andreas
Posts: 15
Joined: Tue May 08, 2018 3:21 pm

Re: Access my USB stick

#7 Post by andreas »

Hi fehlix
thanks a lot for your reply. As you advised, I have tried to mount my USB stick to have write permissions, using the following command:
sudo mount -o uid=1000,gid=1000 /dev/sdb1 /mountpoint
However, I get the message "/dev/sdb1 is write-protected, mounting read-only". So I am still not able to copy data on my USB stick.
Is there any other command I should use ? Or do I have to newly format the entire USB stick, and if yes, how can I do this ?

andreas

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Access my USB stick

#8 Post by fehlix »

andreas wrote: Thu May 30, 2019 7:51 am Is there any other command I should use ? Or do I have to newly format the entire USB stick, and if yes, how can I do this ?
Suggest to wipe the stick and reformat. In most cases it might be enough to just open Gparted to reformat.
But in this case I would do one additional step:
Plugin the USb stick into an USB port of the pc, not at an extension USb port.
Open Terminal and on the command line.
Clear partition table on the stick with live-usb-maker this way:

Code: Select all

sudo live-usb-maker partition-clear
It will scan the usb port and show the sticks available to select,
and look like this:

Code: Select all

===========================================================
Starting live-usb-maker
===========================================================
Only one target usb device was found sdg
Will use target device sdg (14.7G JetFlash Transcend 16GB)
Will use source  null

-----------------------------------------------------------
Ready to perform partition-clear action on sdg
-----------------------------------------------------------

Shall we begin?
  = yes
  > no
  > pretend mode
Press <Enter> to select the highlighted entry
Use 'h' for help, 'r' to redraw, 'q' to quit
>> partition-clear
>> done
lum-partition-clear.png
When finished, open Gparted (in the Menu), select the USB-stick (upper right corner)
Create new partition Table: Device -> Partition Table ( type: msdos)
Create new partition: Partition -> New ( add label and select format ext4, fat32 or ntfs).
:puppy:
You do not have the required permissions to view the files attached to this post.
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
JmaCWQ
Posts: 228
Joined: Fri Sep 09, 2016 4:42 am

Re: Access my USB stick

#9 Post by JmaCWQ »

Creating ext4 with Gparted it's always created with root as the owner, I find the easiest way to get full write permissions for a user is to simply 'chown' it after creation.

Which I believe is

Code: Select all

sudo chown <your username>:<your usergroup> -R <mount point>
Hit Enter, enter password then hit Enter again.

As an example with a username & usergroup called 'home' for a drive named Storage, mounted in /media/home

Code: Select all

sudo chown home:home -R /media/home/Storage

User avatar
figueroa
Posts: 1053
Joined: Fri Dec 21, 2018 12:20 am

Re: Access my USB stick

#10 Post by figueroa »

Format stick ext2/3/4. Example (and be careful):

Code: Select all

mkfs.ext4 /dev/partition
Where partition = sdb1 (Make sure that is your USB stick and not your second hard drive.)

Then:

Code: Select all

chown user:group /path/to/stick/.
Yes, that's a dot at the end. From that point on you will own the stick and be able to read/write at will.
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

Post Reply

Return to “General”