Chmod error changing permission read only file system

I have three main partitions on my disc /dev/sda:

/dev/sda1            2048   117186559    58592256   83  Linux
/dev/sda2       117186560   128905215     5859328   82  Linux swap / Solaris
/dev/sda3   *   128905216   324216831    97655808    7  HPFS/NTFS/exFAT
/dev/sda4       324216832  1250263039   463023104    b  W95 FAT32

/dev/sda3 is a Windows 7 partition and /dev/sda4 is a FAT32 partition where I keep my data. My problem is that yesterday I can't write on /dev/sda4 and when I tried to change the file permissions I get an error:

$ sudo chmod 777 /media/fourat/74A7-A44E/
chmod: changing permissions of ‘74A7-A44E/’: Read-only file system

mount output:

/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=fourat)
/dev/sda4 on /media/fourat/74A7-A44E type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)

Solved: Remounted the partition as instructed in mikewhatever's comment with

sudo mount -o remount,rw /dev/sda4

Solution 1:

I've faced a similar problem with an SD Card previously used on an Android device and locked in READ ONLY mode.

I could not even write nor change permissions :
touch my-test-file.txt and sudo chmod -R a+rwX Pictures/ or chown commands where failing with a message like

chmod: changing permissions of 'Pictures/Screenshots': Read-only file system

In addition, the folder named Android/ was corrupted :

gilles@inspiron-15:/media/gilles/E0A4-1EEB$ ll
ls: cannot access 'Android': Input/output error
total 452
drwxr-xr-x  16 gilles gilles 32768 janv.  1  1970 ./
drwxr-x---+  3 root   root    4096 juin  20 17:36 ../
drwxr-xr-x   2 gilles gilles 32768 janv. 11  2019 100ANDRO/
drwxr-xr-x   2 gilles gilles 32768 juil. 19  2020 Alarms/
d??????????  ? ?      ?          ?              ? Android/
drwxr-xr-x   3 gilles gilles 32768 août  12  2020 DCIM/
drwxr-xr-x  14 gilles gilles 32768 août   4  2019 Download/
drwxr-xr-x   2 gilles gilles 32768 janv. 10  2019 LOST.DIR/
drwxr-xr-x   3 gilles gilles 32768 janv. 10  2019 Movies/
drwxr-xr-x  29 gilles gilles 32768 juil. 10  2020 Music/
drwxr-xr-x   2 gilles gilles 32768 juil. 19  2020 Notifications/
drwxr-xr-x   4 gilles gilles 32768 janv. 10  2019 Pictures/
drwxr-xr-x   2 gilles gilles 32768 juil. 19  2020 Playlists/
drwxr-xr-x   2 gilles gilles 32768 juil. 19  2020 Podcasts/
drwxr-xr-x   2 gilles gilles 32768 juil. 19  2020 Ringtones/
drwxr-xr-x   2 gilles gilles 32768 janv. 10  2019 voicecall/
gilles@inspiron-15:/media/gilles/E0A4-1EEB$ 

IMPORTANT

my SD CARD was formatted in vfat / FAT32.
it means that it does not support unix rwx rwx rwx (ugo) permissions !
With ls -l the file permissions always look like drwxr-xr-x or -rwxr-xr-x and depend only my mount options !


First, I ran the command sudo df to get the device name :

Filesystem     1K-blocks     Used Available Use% Mounted on
udev             3978532        0   3978532   0% /dev
tmpfs             801580     3248    798332   1% /run
/dev/sda4      527509864 30275276 470368876   7% /
tmpfs            4007896      152   4007744   1% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
tmpfs            4007896        0   4007896   0% /sys/fs/cgroup
/dev/sda2         664280     8048    656232   2% /boot/efi
/dev/sda6      415169488 54509064 339548004  14% /DATA
tmpfs             801576       16    801560   1% /run/user/1000
/dev/mmcblk0p1  15553280  4783744  10769536  31% /media/gilles/E0A4-1EEB

I also ran fdisk -l to get the filesystem type (not mandatory) :

...
Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       2048 31116287 31114240 14,9G  b W95 FAT32

I mounted again the device /dev/mmcblk0p1 on RW mode using my uid and gid :

sudo mount -o remount,rw,uid=1000,gid=1000 /dev/mmcblk0p1

and with the fsck command, I removed the "DIRTY BIT" which prevented my card's filesystem to be writable :

gilles@inspiron-15:~$ sudo fsck -f /dev/mmcblk0p1 
fsck from util-linux 2.34
fsck.fat 4.1 (2017-01-24)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1
/Android
  Contains a free cluster (149071). Assuming EOF.
Perform changes ? (y/n) y
/dev/mmcblk0p1: 1823 files, 149492/486040 clusters
gilles@inspiron-15:~$

Hopefully, after that, I could write on the SD card again !


PS 1 :
in addition to fsck the command dosfsck can be usefull too.

PS 2 :
I could not recover my Android/ directory, but I could clear it and get a clean file system :

gilles@inspiron-15:/media/gilles/E0A4-1EEB$ sudo dosfsck /dev/mmcblk0p1 
fsck.fat 4.1 (2017-01-24)
/Android
 Start does point to root directory. Deleting dir. 
Perform changes ? (y/n) y
/dev/mmcblk0p1: 1823 files, 149492/486040 clusters
gilles@inspiron-15:/media/gilles/E0A4-1EEB$