I have a Samsung S3 which I have installed Cyanogenmod on with a view to carry out some procedures with root permissions.

At the minute I am trying to create a .img file of the userdata memory block using the DD command in the adb shell. I have a 32GB SD card which initially was formatted as FAT32 and therefore failed once the .img file reached 4GB. I expected as much but I wanted to check things were going ok before I reformatted the card.

I then formatted the SDCard as ext4 using gparted. I noticed on my ubuntu machine that the card had root ownership so I changed that to user and I can read and write files in nautilus fine.

Switching back to the adb shell, I carried out the same command as below (which is what I previously used when it was formatted as FAT32) and I get a permission error. Its driving me insane, I've tried chown'ing and chmod'ing till the cows come home and still nothing working.

Commands I'm using

$ ./adb shell
shell@mo:/ $ cd dev/block/platform/dw_mmc/by-name
shell@mo:/ $ su
root@m0:/ # dd if=/dev/block/mmcblk0p12 of=/storage/sdcard1/userdata.img

#error message is
/storage/sdcard1/userdata.img: cannot open for write: Permission denied

I've tried

chmod 777 /storage/sdcard1

and various other chowning, but still get the same issue. Am I doing something stupid (probably!) but any tips appreciated.


Relevant output of mount:

/dev/block/vold/179:17 /mnt/media_rw/sdcard1 ext4 rw,dirsync,context=u:object_r:sdcard_external:s0,nosuid,nodev,noexec,noatime,user_xattr,barrier=1 0 0
/dev/fuse /storage/sdcard1 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

Output of ls -l in storage/

dr-xr-xr-x root     root              2014-10-01 08:15 emulated
lrwxrwxrwx root     root              2014-10-01 08:15 sdcard0 -> /storage/emulated/legacy
drwxrwxr-x root     sdcard_rw          2014-10-01 08:13 sdcard1
drwxrwxr-x system   system            2014-10-01 08:15 usbdisk0


Output of echo'ing foo to a text file

root@m0:/ # echo foo > /storage/sdcard1/foobar.txt
sh: can't create /storage/sdcard1/foobar.txt: Permission denied
  • Have you checked the SD card's mount options? Could be flagged as read-only, but you may be able to remount it to fix it. I think external cards get mounted read-only by default on newer versions of Android (not sure about that, though, my device has no SD card slot). – eldarerathis Sep 30 '14 at 19:23
  • 1
    @eldarerathis I would wonder if they get mounted r/o even with that stupid KK change, as that would render even the systems camera app void – plus the ability of apps to write to their own directories there, which still exists with KK. // m0atz: please check the output of mount, and do a ls -l on the directory where the card is mounted to, plus on the card's root directory. Any notable things that "jump into your face" there? – Izzy Sep 30 '14 at 22:00
  • 1
    @m0atz I've truncated that a little to leave only the relevant stuff in (easier to read/follow). But that looks fine: card is mounted r/w, and the sdcard_rw group (plus root) are granted full access to it. Btw: Your original post doesn't indicate whether your su succeeded (what prompt belongs before the dd call: is it a $ or a #?) – could you please fill that gap? Also: Does a simple echo foo > /storage/sdcard1/foobar.txt, run as root, succeed? Is your system's camera app able to store pictures on the SDCard? – Izzy Oct 1 '14 at 9:52
  • 2
    @m0atz can you try to echo foo /mnt/media_rw/sdcard1/foobar.txt as root? I think sdcard is mounted two times, second time with fuse that makes permissions harder to understand. – Crayon Oct 1 '14 at 16:47
  • 1
    Glad that worked, coming from linux sometimes I find android a bit confusing about permissions. – Crayon Oct 2 '14 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.