I was trying to recover files from android phone using adb shell and test disk. But I am getting a read only filesystem error, even though the permissions to write is granted to the user.

adb devices

list the device attached. After I ran the following commands

adb shell

Inside the shell I did the following

user:/ $ su
user:/ # adb shell "stty raw; cat </dev/block/mmcblk0p56" > data.img
sh: can't create data.img: Read-only file system

How to solve this?


Trying the proposed solutions:

 $ sudo adb shell "stty raw; cat /dev/block/mmcblk0p56" > /home/user/android-backup/data.img
stty: tcgetattr standard input: Not a typewriter
cat: /dev/block/mmcblk0p56: Permission denied

Mounting code:

$ sudo mount -o remount,rw /dev/block/mmcblk0p56 /tmp
mount: /tmp: mount point not mounted or bad option.

You can try to remount the file system with read and write permissions (source):

sudo mount -o remount,rw /partition/identifier /mount/point

Or in your case you just can tray to redirect the output to a file located in a directory where you must be able to write:

adb shell "stty raw; cat </dev/block/mmcblk0p56" > /tmp/data.img
  • I would add 'writing to / is always a bad idea (not related if possible or not)'. But your suggestion to use /tmp covers the solution already. – LupusE Mar 26 at 7:53
  • Hi, @LupusE, why it is a bad idea? – pa4080 Mar 26 at 8:00
  • There is something called FSH (en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) to define what data should be stored in which directory. ... It is very important if you've got different partitions for different purposes. For example: Avoid to put /var/log on a flash storage. Much read/write will kill it ... It is the same if you store everything on C: in windows. Maybe good for the moment, but don't show anyone. – LupusE Mar 26 at 8:07
  • @pa4080 Is /partition/identifier in this case /dev/block/mmcblk0p56? Also, what should be the mount point? – supremum Mar 26 at 9:02
  • @supremum, yes I think it should be /dev/block/mmcblk0p56, but can't be sure. You can list the attached drives/devices by the command sudo lsblk. – pa4080 Mar 26 at 10:08

Are you trying to copy the block device to an image file on your local computer? If so, try:

adb shell su -c '"stty raw; cat < /dev/block/mmcblk0p56"' > data.img

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.