Auto full permission for subfolder when plug in the usb

mc flag

i have a player that auto download the files if i plug in usb, for some pc its working smoothly but i got problem for some pc with same OS ( ubuntu ) but different type and i test to give full permission access ( 777 ) to the files manually with chmod and its working

try to edit fstab but the usb uuid not shown :

UUID=C0C2-706F                            /boot/efi      vfat    umask=0077 0 2
UUID=d2187334-fc44-48c1-9226-f23f6289d985 /              ext4    defaults   0 1

result for the mount :

/dev/sda2 on /media/amg/TO1 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1001,fmask=0022,dmask=0022,codepage=437,ioc            harset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

result for lsb_release - a;uname -a :

amg@amg:~$ lsb_release -a;uname -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal
Linux amg 5.11.0-27-generic #29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

result for lsblk ( usb at sda2 ):

amg@amg:~$ lsblk
sda            8:0    1  7,3G  0 disk
├─sda1         8:1    1  200M  0 part
└─sda2         8:2    1  7,1G  0 part /media/amg/TO1
mmcblk0      179:0    0 29,1G  0 disk
├─mmcblk0p1  179:1    0  300M  0 part /boot/efi
└─mmcblk0p2  179:2    0 28,8G  0 part /
mmcblk0boot0 179:8    0    4M  1 disk
mmcblk0boot1 179:16   0    4M  1 disk

result for lsblk -e7 -o model,name,size,fstype,uuid :

amg@amg:~$ lsblk -e7 -o model,name,size,fstype,uuid
Cruzer_Blade sda           7,3G
             ├─sda1        200M vfat   67E3-17ED
             └─sda2        7,1G vfat   D078-0D63
             mmcblk0      29,1G
             ├─mmcblk0p1   300M vfat   C0C2-706F
             └─mmcblk0p2  28,8G ext4   d2187334-fc44-48c1-9226-f23f6289d985
             mmcblk0boot0    4M
             mmcblk0boot1    4M

my question is how to make the subfolder file get auto full permission when i plug in the usb ?


Marco avatar
br flag
Does the option `nofail` help ?
Talaat Etman avatar
gt flag
`chown -R username ./yourfolder`
adrian avatar
mc flag
nope, the OS still stuck @Marco
adrian avatar
mc flag
its working if i grant it manually chown/chmod, but i want it auto grant when i plug in the usb @TalaatEtman
waltinator avatar
it flag
Unless you [edit] your Question and show us the actual `/etc/fstab` line, the results of the `mount` command, and the results of `lsb_release -a;uname -a`, we don't know enough to help.
Marco avatar
br flag
according to the manuals, exfat can only be used with fuse. Means exfat can not be used in `/etc/fstab`
Talaat Etman avatar
gt flag
see this answer
adrian avatar
mc flag
already edited, but now my usb ( vfat/exvat) not shown the uuid @waltinator
sudodus avatar
jp flag
vfat/exvat is not detailed enough. Is it FAT32 or exFAT or something else? Anyway, a Microsoft filesystem must be treated in one way and a Linux filesystem for example `ext4` in another way. You can run the command line `lsblk -e7 -o model,name,size,fstype,uuid` in order to find out, if you are not sure.
adrian avatar
mc flag
im try to used FAT32 & exFAT but the uuid not shown in fstab, already edited, the result for lsblk -e7 -o model,name,size,fstype,uuid @sudodus
jp flag

It should work to mount the partition in the USB drive after editing the following line into /etc/fstab (assuming access for the first user (with uid=1000). Open the file in a text editor

sudo nano /etc/fstab

add one of the following lines and finally save the edited file with ctrl + x (and y for yes).

  • alternative 1, drive always to be plugged in (and automatically mounted at boot),

    UUID=D078-0D63  /mnt/usbdata  vfat  rw,user,uid=1000,dmask=007,fmask=117  0  0
  • alternative 2, drive to be plugged in when computer is running,

    UUID=D078-0D63  /mnt/usbdata  vfat  noauto,rw,user,uid=1000,dmask=007,fmask=117  0  0

    Here you must also mount the file system by

    sudo mount /mnt/usbdata
  • creating a mountpoint

    sudo mkdir /mnt/usbdata
  • and rebooting.

  • If you format the drive, the UUID will change and you can use

    lsblk -e7 -o model,name,size,fstype,uuid

    to find the new UUID.

  • If you want to modify the permissions, see this link.

  • If still no luck mounting the file system in the USB drive, the best tip I can think of is that Windows has left the drive 'dirty', and you can try to repair it with Windows tools.

    This can be avoided if you turn off fast startup in Windows, and always use safe removal of the drive (flush the buffers so that the write operations reach the memory cells before you unplug the drive). In Ubuntu you can do that with the command


    or 'eject' in the graphical interface. A safe way to sync and prevent further writes is to unmount,

    sudo umount /mnt/usbdata
adrian avatar
mc flag
i got error when try run the first line command : amg@amg:/media/amg/TO1$ lsblk -e7 -o model,name,size,fstype,uuid MODEL NAME SIZE FSTYPE UUID Cruzer_Blade sda 7,3G └─sda1 7,3G vfat 7C10-C25D amg@amg:/media/amg/TO1$ UUID=7C10-C25D /mnt/media/amg/TO1/ vfat rw,user,uid=1000,dmask=007,fmask=117 0 0 -bash: /mnt/media/amg/TO1/: No such file or directory
sudodus avatar
jp flag
It is very difficult to read the output of the lsblk command in a comment, because it is 'unformatted'. Please edit your original question to enter the command and its output and render it as `code` by indenting each line four spaces (or use the relevant button at the top of the editing window).
sudodus avatar
jp flag
The first code line is not a command, I meant that you should open the file `/etc/fstab` in a text editor and add that line: `sudo nano /etc/fstab`; add that line and finally save the edited file.
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.