{FIX} "Can't write on SD / Insert SD card" after wiping /sdcard

Discussion in 'Xiaomi Mi 2 / Mi 2S' started by davfiala, Oct 8, 2014.

  1. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    Disclaimer:
    Use on your own caution! I take no responsibility for lost data or coming zombies! Always perform backup!

    Instructions:
    1) Download and run: https://play.google.com/store/apps/details?id=jackpal.androidterm
    2) type in terminal following commands:
    Code:
    su
    Code:
    chown media_rw:media_rw /mnt/media_rw/sdcard0
    Code:
    chmod 755 /mnt/media_rw/sdcard0
    4) reboot
    DONE!
     
  2. OfirTurc

    OfirTurcMembers

    Oct 10, 2013
    2
    0
    21
    Male
    Karmiel, Israel
    Thank you very much. Did as explained and it "free" my sdcard, now I can download and take pictures.
    Maybe just to update, the phone must be rooted before starting this procedure.
     
  3. X4nfire

    X4nfireMembers

    Jun 28, 2014
    204
    76
    52
    Male
    When i run "chown media_rw:media_rw /mnt/media_rw/sdcard0" i'm getting "unknown user/group media_rw:media_rw"
    I've got trouble getting my windows 8.1 laptop recognizing my sdcard in mtp mode, it doesn't show on file explorer.It only works in ptp mode.I've got drivers installed.Is that fix related to my problem or applies only for phone recognizing sdcard?I run pacman-rc3 with khaon kernel but it doesn't seem related cause i had this with different combos.
     
  4. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    It fixes phone which can see SD, but can't write it.
     
  5. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    I'm on CM11 having the same problem that I can't write on the sd-card anymore. Trying your commands on the built-in terminal or via "adb shell" I get that error message:

    Code:
    Unable to chown /mnt/media_rw/sdcard0/: Read-only file system 
    Any idea how to solve that?
     
  6. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    Get Total Commander, allow root for him a and change permissions of
    /mnt/media_rw/sdcard0/ to 755 and mnt/sdcard to 777
     
  7. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    Well I use ES Explorer which should have the same possibilities I hope. It shows me that the permissions are already set as you indicated above ... this is the output from my adb shell

    Code:
    shell@aries:/ $ su
    root@aries:/ # cd /mnt/
    root@aries:/mnt # ll
    drwxr-xr-x root     system            2014-11-26 09:37 asec
    drwxrwxr-x root     system            2014-11-26 09:36 fuse
    drwx------ media_rw media_rw          2014-11-26 09:36 media_rw
    drwxr-xr-x root     system            2014-11-26 09:36 obb
    lrwxrwxrwx root     root              2014-11-26 09:36 sdcard -> /storage/sdcard0
    drwx------ root     root              2014-11-26 09:36 secure
    drwx------ shell    shell             2014-11-26 09:36 shell
    lrwxrwxrwx root     root              2014-11-26 09:36 usbdisk -> /storage/usbdisk
    root@aries:/mnt # ll media_rw/
    drwxrwxr-x media_rw media_rw          2014-11-25 08:18 sdcard0
    drwx------ media_rw media_rw          2014-11-26 09:36 usbdisk
    
    Does that look OK?
     
  8. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    Code:
    root@aries:/ # su
    su
    root@aries:/ # cd /mnt
    cd /mnt
    root@aries:/mnt # ll
    ll
    drwxr-xr-x root    system            2014-11-23 02:00 asec
    drwx------ media_rw media_rw          2014-11-23 02:00 media_rw
    drwxr-xr-x root    system            2014-11-23 02:00 obb
    lrwxrwxrwx root    root              2014-11-23 02:00 sdcard -> /storage/sdcard
    0
    drwx------ root    root              2014-11-23 02:00 secure
    drwx------ shell    shell            2014-11-23 02:00 shell
    lrwxrwxrwx root    root              2014-11-23 02:00 usbdisk -> /storage/usbdi
    sk
    root@aries:/mnt # ll media_rw/
    ll media_rw/
    drwxr-xr-x media_rw media_rw          2014-11-25 21:05 sdcard0
    drwx------ media_rw media_rw          2014-11-23 02:00 usbdisk
    root@aries:/mnt #
     
  9. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    Hmm - I don't see a fuse mount at your side ... could that be the source of the changed permissions? I'm really wondering what chaused that change of permissions ... :confused:o_O
     
  10. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    I have AOSP 5.0, it could be different. Last thing you could try is fixing permissions in CWM.
     
  11. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    Hm? I thought that feature was removed from CWM? Or do I miss the point now?
     
  12. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    Sorry, my mistake. I forgot that it's already gone. Try to look at system/etc/permissions/platform.xml and find WRITE_EXTERNAL_STORAGE
     
  13. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
  14. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    Thanks for all the time you're willing to invest to help me!

    I looked into /system/etc/permissions/platform.xml and I see this
    Code:
        <permission name="android.permission.READ_EXTERNAL_STORAGE" >
            <group gid="sdcard_r" />
        </permission>
    
        <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
            <group gid="sdcard_r" />
            <group gid="sdcard_rw" />
        </permission>
    
        <permission name="android.permission.ACCESS_ALL_EXTERNAL_STORAGE" >
            <group gid="sdcard_r" />
            <group gid="sdcard_rw" />
            <group gid="sdcard_all" />
        </permission>
    
        <permission name="android.permission.WRITE_MEDIA_STORAGE" >
            <group gid="media_rw" />
        </permission>
    
    As you've seen above /mnt/media_rw/sdcard0 is already owned by media_rw:media_rw ... perhaps I should change that to sdcard_rw? And /storage/sdcard0 shows root:sdcard_rw as owner with 775 permissions

    Executing the chown and chmod commands via adb is not possible since the filesystem is read-only :-/
     
  15. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
    I'm out of ideas, sorry.
     
  16. swimmer

    swimmerMembers

    Jul 24, 2013
    66
    18
    18
    Male
    Don't be sorry - you helped me a tremendous lot already! Thanks for that :cool:
     
  17. aqueousverm

    Aug 21, 2013
    21
    0
    11
    Male
    can i do it from twrp recovery? since my mi2s has no rom installed
     
  18. davfiala

    davfialaMembers

    Aug 20, 2013
    550
    199
    80
    Male
    Land Rover addict
    Czech Republic
  19. aqueousverm

    Aug 21, 2013
    21
    0
    11
    Male
    #19aqueousverm,Aug 20, 2015
    Last edited: Aug 21, 2015
    thank you for your response
     
  20. aqueousverm

    Aug 21, 2013
    21
    0
    11
    Male
    i used aries core unified single partition resize from @M1cha and it works. the problem is, i can't take a picture due to something wrong about internal storage. it can't save pictures taken, can't download files, but it can install apps from playstore.
    it can also copy files from MTP mode.

    did i miss something?
     
  21. blackcatw81

    Jun 30, 2014
    49
    26
    38
    Female
    Italy
    #21blackcatw81,Sep 6, 2015
    Last edited: Sep 6, 2015
    Hi! Got some problems on my mi2s (32gb) running mokee44.
    I made some mistakes, such as freezing some system apps, but when I tried to disable tdb and wipe data/format system and sd, re-flashing everything, the sd has not been formatted, my syst2 is stuck on bootloop and couldn't find the gapps installed (and can't re-downloaded or else). I restored a previously made backup and all works as it should, but still my syst2 and sd should not be there or as it should be.

    Later today with my boyfriend I'll try running Android Terminal Emulator and check the sd for damaged sectors.. But what could I do to fix those problems? :(
     
  22. did you recreate all filesystems? also, which ROM are you using?
     
    MSephiroth likes this.
  23. well using TDB isn't a good idea these days because many ROM's just don't support it at all.
    You should install TWRP, recreate all filesystems, and install your favorite ROM again.(backup and restore data if that's important, but if your installation is broken that could lead to bootloops again).
     
    blackcatw81 and MSephiroth like this.
  24. blackcatw81

    Jun 30, 2014
    49
    26
    38
    Female
    Italy
    #24blackcatw81,Sep 6, 2015
    Last edited: Sep 6, 2015
    Yep, I disabled tdb for this reason but I don't like LolliPop so much. I'll search for upgraded news on mokee50-51. I don't think my installation is broken, I think there are problems on the internal memory. But flashing a new recovery is in the to-do list.

    EllyG81 Using Tapatalk on Xiaomi Mi2S
     
  25. blackcatw81

    Jun 30, 2014
    49
    26
    38
    Female
    Italy
    Is it normal that after disabling tdb I could access syst2?

    EllyG81 Using Tapatalk on Xiaomi Mi2S
     

Share Our Site