2

I have a got a USB key with some directories on it. All files belong to root.

whoami 
root 

id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023


lsblk -f 
[...]
  ├─cs-root xfs               8cd99025-279f-4bc5-82c2-914200ae4e1a   /
  ├─cs-swap swap              af0674c2-a5e9-4646-be91-93c6f876eb88   [SWAP]
  └─cs-home xfs               39212c8d-0a88-4e55-91c9-a5751233a5ca   /home
sdb                                                                  
└─sdb1      vfat              36C7-16EE    #-> the faulty usb device, vfat formated.

ls -ld /mnt
drwxr-xr-x. 10 root root 32768 Dec 31  1969 /mnt

I try to change all files' ownership to a regular user (achille) but the command fails due to an unexpected error message

chown achille: -R /mnt

...
chown: changing ownership of '/mnt/2.order/virtualbox/install.VirtualBox.Centos': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/install.virtualbox.local.repos': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/warning/install.AdditionsGuest': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/warning/install.virtualbox.local.repos': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/warning/readme.txt': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/warning': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/Centos8.ova': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/vbox.forum.infos.txt': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox/vbox.post': Operation not permitted
chown: changing ownership of '/mnt/2.order/virtualbox': Operation not permitted
chown: changing ownership of '/mnt/2.order/openssl.en-de_cryption': Operation not permitted
chown: changing ownership of '/mnt/2.order': Operation not permitted
chown: changing ownership of '/mnt/vim.config.files.paths': Operation not permitted
chown: changing ownership of '/mnt': Operation not permitted

I try:

chown achille: /mnt
chown: changing ownership of '/mnt': Operation not permitted

I check the sysctl configuration but cannot see anything that could be related to this issue:

fs.protected_fifos = 0
fs.protected_hardlinks = 1
fs.protected_regular = 0
fs.protected_symlinks = 1

there is no mechanical locker on the usb, but the usb is full:

df -h /mnt
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       7.4G  7.4G  384K 100% /mnt

Question: what could be the reason of such an error? Could it be because of the vfat fs?

thanx folks!!

2 Answers 2

7

in vfat you can't have owner and group as it is available in other filesystems. So the good way (if you want to provide permissions to ordinary user(s) is to unmount USB drive, change permission and ownership of /mnt and then mount with specific options:

mount -o uid=achille,other_options /dev/sdb1 /mnt

(not sure if uid option will work well with vfat)

1
  • 1
    @@Romeo:it does, gid too.
    – achille
    Feb 20 at 14:51
3

vfat filesystem doesn't support Unix ownership and this is what Operation not permitted error message is telling you.

1
  • This is a rather wrong error code/message. The right one would be EOPNOTSUPP and this would likely fix many programs that error-out on being unable to do what was asked for permissions reasons, but happily accept "unsupported" as a non-fatal error. Unfortunately Linux stability policy probably precludes fixing this. Maybe it could be a mount option tho. Feb 21 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .