2

FAT and FAT32 file systems support file attributes like "read only". How can I change those under OS X? The standard chmod command does not seem to do the trick. How else can I do this?

  • What exactly have you tried (which specific chmod command)? – nohillside Aug 4 '16 at 19:04
5

Under OS X, the FAT/FAT32 file system Readonly attribute is set when a file is locked. When a file is viewed in the Finder application, a small lock will appear on the file icon. This Readonly attribute can be set or unset by highlighting the file and then selecting "File->Get Info" from the menu bar. The Readonly attribute can then be modified by checking or unchecking the box labeled "Locked".

This also can be done from the command line. First, to view the attributes use the command below.

ls -lO <filename>

To set the Readonly attribute use the following command.

chflags uchg <filename>

To reset the Readonly attribute use the following command.

chflags nochg <filename>

To set the Hidden attribute use the following command.

chflags hidden <filename>

To reset the Hidden attribute use the following command.

chflags nohidden <filename>

To set the Archive attribute use the following command. Note: this command is the opposite of what one would expect to enter."

sudo chflags noarch <filename>

To reset the Archive attribute use the following command. Note: this command is the opposite of what one would expect to enter."

sudo chflags arch <filename>

Note: The System attribute does not seem to have an OS X equivalent. So even if the Windows command attib can alter the System attribute, the OS X command chflags can not.

  • Unfortunately chflags does not work for FAT, at least it does not affect the hidden attribute. – kirelagin May 1 '18 at 16:11
  • a tiny mistake: chflags nochg <filename> must be chflags nouchg <filename> – S.M.Mousavi Mar 28 at 8:42
1

I found a way to do it via the mtools package. I installed it via home-brew (brew install mtools).

Then I took a look which device I wanted to manipulate: diskutil list. In my case this was /dev/disk3s1. So I unmounted the disk: disuktil unmount /dev/disk3s1.

Then I followed the instructions from this blog:

  1. Create a ~/.mtoolsrc with this content: drive s: file="/dev/disk3s1" mtools_skip_check=1
  2. Use mdir and mattrib to navigate around and change file attributes
  3. Unmount the whole disk: disuktil unmountDisk /dev/disk3

I would have to use the tools with sudo, though: sudo mdir s:, sudo mattrib +r s:/some/path.

You must log in to answer this question.

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