Wednesday, October 12, 2016
Change FAT NTFS file attributes from Linux
Change FAT NTFS file attributes from Linux
The original use case was born for me when one of my friends gave me a memory card that was infected by the hidden file virus (he calls it so). All of the files were applied the +S +H +R attributes which made the file System file, Hidden and Read only respectively. For this reason he could not see them in his cell phone which depended on this attributes (Nokia Symbian OS).
I personally dont like to work with Microsoft born tools, so instead of booting into my Windows 7 installation (I usually never do that), I wanted to find a way that allowed me to change these attributes right from my Linux installation. There it came, the awesome mtools toolset.
To change the file attributes, you first need to switch into that directory (which points to the card). But the mtools have a catch. They do not let you work with them, unless you ignore some errors. And to instruct it to do so, you have to make an RC file that will do just that right before one of tools takes any actions. The location of the RC file will be
Then change into your drive
Credits due:
http://blogs.gnome.org/diegoe/2012/04/21/removing-the-hiddensystem-bit-of-vfatfat32-files-on-gnulinux/
I personally dont like to work with Microsoft born tools, so instead of booting into my Windows 7 installation (I usually never do that), I wanted to find a way that allowed me to change these attributes right from my Linux installation. There it came, the awesome mtools toolset.
To change the file attributes, you first need to switch into that directory (which points to the card). But the mtools have a catch. They do not let you work with them, unless you ignore some errors. And to instruct it to do so, you have to make an RC file that will do just that right before one of tools takes any actions. The location of the RC file will be
or
~/.mtoolsrc
The contents have to be
/home/<user>/.mtoolsrc
The significance of the first line is, it assigns the directory into drive S. it could be anything else, like C, D, E etc. The second line tells mtools to check for some errors, it has to be set to not check because otherwise it refuses to operate on the drive (please dont look at me, I just copied it from somewhere)
drive s: file="/dev/<your-usb-drive>"
mtools_skip_check=1
Then change into your drive
And change the attributes (actually unset them) for all the files
$ mattrib -/ s:
Thats it :)
$ mattrib -/ -h -s -r s:
Credits due:
http://blogs.gnome.org/diegoe/2012/04/21/removing-the-hiddensystem-bit-of-vfatfat32-files-on-gnulinux/
Go to link download