10

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
5
  • There's nothing in your question that shows us the location of '74A7-A44E'. Please update your question with the output of mount and where the directory you cannot change permissions of actually is. Jan 11, 2015 at 19:05
  • Are you trying to apply chmod command on a file that exists on USB?
    – Wolverine
    Jan 11, 2015 at 19:15
  • 3
    If a filesystem is read only, you need to re-mount it as rw - sudo mount -o remount,rw /dev/sda4, and not hammer it with chmod. The cause of such errors is usually filesystem corruption, so you'll need to check it for errors in Windows. Jan 11, 2015 at 19:17
  • 1
    If I'm not mistaken, FAT partitions don't have 'permissions'. Instead of chmod, you could just give your user permission to access the files with mount/fstab.
    – earthmeLon
    Jan 12, 2015 at 18:37
  • 7
    Possible duplicate of How to make read-only file system writable?
    – Zanna
    Mar 7, 2017 at 7:14

2 Answers 2

2

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$
-2

I guess you can use the below command to remount:

adb remount 

this solution should work for the above issue

1
  • 2
    adb is the Android Debug Bridge tool, how could it solve the OP issue? Sep 20, 2020 at 6:56

You must log in to answer this question.

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