How to mount /data partition as RW - General Questions and Answers

I am trying to run these simple ADB commands:
adb devices
adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
adb shell "dd if=/dev/zero of=/dev/block/bootdevice/by-name/userdata bs=4096"
after I run
adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
I get the following:
dd: /dev/block/bootdevice/by-name/userdata: Permission denied
I was told that /data partition must be mounted as RW. I am not that advanced and I do not understand what it means exactly. Could someone help me with this please?

Mounting a partition as RW - read / write access - requires Android is rooted.

For those of you reading this now, I struggled with this for a while, what worked for me was loading it from twrp, from there I was able to run adb commands as root user.

Related

[Q] ADB Backup

Hi All,
I've backed up my device (I9000) using ADB with the following commands:
mkdir backup
cd backup
adb shell su -c "dd if=/dev/block/bml1 of=/sdcard/boot.bin bs=4096"
adb shell su -c "dd if=/dev/block/bml2 of=/sdcard/pit.pit bs=4096"
adb shell su -c "dd if=/dev/block/stl3 of=/sdcard/efs.rfs bs=4096"
adb shell su -c "dd if=/dev/block/bml4 of=/sdcard/Sbl.bin bs=4096"
adb shell su -c "dd if=/dev/block/stl6 of=/sdcard/param.lfs bs=4096"
adb shell su -c "dd if=/dev/block/bml7 of=/sdcard/zImage bs=4096"
adb shell su -c "dd if=/dev/block/stl9 of=/sdcard/factoryfs.rfs bs=4096"
adb shell su -c "dd if=/dev/block/stl10 of=/sdcard/dbdata.rfs bs=4096"
adb shell su -c "dd if=/dev/block/stl11 of=/sdcard/cache.rfs bs=4096"
adb shell su -c "dd if=/dev/block/bml12 of=/sdcard/modem.bin bs=4096"
adb shell su -c "tar -czvf /sdcard/data.tar.gz /data"
adb pull /sdcard/param.lfs .
adb pull /sdcard/zImage .
adb pull /sdcard/factoryfs.rfs .
adb pull /sdcard/dbdata.rfs .
adb pull /sdcard/cache.rfs .
adb pull /sdcard/modem.bin .
adb pull /sdcard/efs.rfs .
adb pull /sdcard/boot.bin .
adb pull /sdcard/Sbl.bin .
adb pull /sdcard/pit.pit .
adb pull /sdcard/data.tar.gz .
And I would like to give the backup to some of my friends, but I would like to verify there are no "personal data" on the backup (I did a factory reset before the backup and there was no contacts \ data that was mine), I don't know what type of data should I delete from the files, (like IMEI and serial data..).
Please help me find out what shouldn't be on the backup,
Thanks,
AYahoo.

ADB prompt question

I'm having some trouble with the mount command. More specifically when trying to mount the system without going into shell. It worked fine on 2.1, but on 2.2 I get an error. The command I'm typing is:
./adb shell mount -t rfs -o remount,rw /dev/block/stl9 /system
The error I get is:
mount: Operation not permitted
However, when I go into shell su, and just type the mount command, it works fine. I need to get the mount command to work outside of shell for a bash script that I am writing. If I enter shell in the script, the script does not finish executing, and I cannot enter commands into the adb shell prompt. Any idea?
I have a Samsung Fascinate running EB01 and the phone has been rooted. I'm also doing this on a mac.
Thanks.
Braydon525 said:
I'm having some trouble with the mount command. More specifically when trying to mount the system without going into shell. It worked fine on 2.1, but on 2.2 I get an error. The command I'm typing is:
./adb shell mount -t rfs -o remount,rw /dev/block/stl9 /system
The error I get is:
mount: Operation not permitted
However, when I go into shell su, and just type the mount command, it works fine. I need to get the mount command to work outside of shell for a bash script that I am writing. If I enter shell in the script, the script does not finish executing, and I cannot enter commands into the adb shell prompt. Any idea?
I have a Samsung Fascinate running EB01 and the phone has been rooted. I'm also doing this on a mac.
Thanks.
Click to expand...
Click to collapse
Hi, what does the following output?
adb shell id
Also, what about just
adb remount
- jc
JimmyChingala said:
Hi, what does the following output?
adb shell id
Also, what about just
adb remount
- jc
Click to expand...
Click to collapse
Tried both remount and shell remount..
$ ./adb shell id
uid=0(root) gid=2000(shell) groups=1007(log)
$ ./adb remount
remount failed: No such file or directory
$ ./adb shell remount
remount: not found

What is wrong with my script - going crazy

so I'm new to scripting, and I have a TON of lg optimus S's to root for work. So I figured I'd write a script to make life easy. I know all the shell commands are correct as if I manually type everything in it works. What happens is it gets through gingerbreak exploit and when the prompt returns # - everything seems to go to hell.
Here is my script I am using. I'm using Kubuntu 11.04 writing it in Kate, name of my script is Script2 and I'm executing it in bash via $sh Script2
echo "removing TMP directory";adb shell rm -r /data/local/tmp
echo "creating TMP directory";adb shell mkdir /data/local/tmp
echo "pushing gingerbreak";adb push gingerbreak /data/local/tmp/gingerbreak
echo "CD TMP";adb shell cd /data/local/tmp
echo "CHMOD TMP";adb shell chmod 777 /data/local/tmp/*
echo "running gingerbreak";adb shell /data/local/tmp/gingerbreak &
sleep 32
adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock5 /system
adb shell cat /sdcard/flash_image > /system/bin/flash_image
adb shell chmod 755 /system/bin/flash_image
adb shell mount -o remount,ro -t yaffs2 /dev/block/mtdblock5 /system
adb shell flash_image recovery /sdcard/xionia_cwma_12518.6.img
adb shell reboot recovery
I've tried with out sleep command and also with out "&" at the end of gingerbreak, and when I do that and it returns # it seems like no commands will work, even if I type them in it returns just a blank line with out #.
With that current script after sleep 32, it returns #, few seconds later it tries to mount and I get (including the end of gingerbreak exploit).
[!] dance forever my only one
# mount: Operation not permitted
Script2: 9: cannot create /system/bin/flash_image: Directory nonexistent
Unable to chmod /system/bin/flash_image Read-only file system
mount -o: permission denied
reboot: Operation not permitted
then it returns me to bash$
Thanks!
So something interesting, I've been playing with this for awhile, and I took everything out past the
adb shell /data/local/tmp/gingerbreak
it seems if I run it as
bash$ adb shell /data/local/tmp/gingerbreak
vs
bash$ adb shell
$ cd /data/local/tmp
$ ./gingerbreak
when # is returned, the first option won't take any commands its like it hangs, if I type out the next command it will just return a blank line with out $ or #, I have to forcibly end the process by CTRL+C and it will return me to bash, if I do the second option it works and I can enter the next command in and it takes and returns me to #. Anyone know why this is? I'm pretty sure this is the problem.
I would happily use the second option, but I'm not sure how to get the script to take any android shell commands without a "adb shell" infront. If anyone knows how to get around this, that would be awesome =)

[Completed] [Q] Batch file commands help

So I am trying to make a batch file that automatically flashes a custom bootanimation from my computer and I am having trouble with these commands.
adb wait-for-device shell "su -c 'ls /system/media'"
adb wait-for-device shell "su -c 'mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system'"
adb wait-for-device shell "su -c 'rm /data/media/bootanimation.zip1'"
Bascially I want to have the adb shell enter superuser mode, remount system in read write mode and delete the existing bootanimation.zip
Whenever I try and run this it says permission denied.
Please post your question in Android General so that the right experts may be of help.
Thread Closed. Thank you.

Easiest way to temporarily get root on Android

Hi
I have a new Android device, it's not any of the ones that have their own forum.
More specifically it runs Android 11 on top of a 4.19.193 Rockchip BSP kernel.
I need to read one or two specific files but these files are only readable by root.
I have ADB shell access.
What I do want to acheive:-
Temporarily have an ability to copy a file that's readable only by root, this could be by some GUI app that copies files, as long as the copy is readable by normal user, running commands as root, copy a partition to an image file, export to a desktop machine and read it there. Any one of these would get me that file.
What I don't want to do:-
I don't want to permanently modify the device, unlock the bootloader, put su into /system or anything like that.
Does anyone know of a rooting app that can give me temporary root access but then doesn't actually change the system?
thanks
To get temporary super-user ( AKA root ) rights on an Android's device shell all you have to do is to find a suitable su binary and copy it onto Android's filesystem.
A: To run Android shell commands with super-user right from within the shell on desktop computer ( AKA Command Prompt ) you have to run within desktop computer shell
Code:
adb devices
adb push <LOCATION-OF-SUITABLE-SU-BINARY-ON-PC-HERE> /data/local/tmp/
what will 1. connect the Android device to your desktop computer and 2. upload the su binary in the Android device temporary directory always available for the user.
B: Then, in desktop computer shell type
Code:
adb shell "cd /data/local/tmp & chmod 776 su"
what makes the su binary executable: its ownership by default is set to shell.
C: Then in desktop computer shell type
Code:
adb shell "ls -l"
what will show you content and permissions on recently uploaded files.
D:
To apply a series of Android shell commands what require super-user rights you now would run
Code:
adb shell
export PATH=/data/local/tmp:$PATH"
su -c "<SHELL-CMD-HERE>"
....
su -c "<SHELL-CMD-HERE">
exit
BTW:
When in an Android shell another process like su gets started then this spawned process runs as a child process means it inherits most of the parent process attributes.
adb push allowed me to send the file
Code:
adb push su /data/local/tmp/
su: 1 file pushed. 1.2 MB/s (11640 bytes in 0.009s)
but the adb shell command is failing
Code:
adb shell "cd /data/local/tmp & chmod 776 su"
chmod: su: No such file or directory
if I then log in over adb I don't seem to have permissions to do anything in data
Code:
adb shell
ls -al
drwxrwx--x 47 system system 4096 2022-09-02 16:31 data
cd data
ls -al
ls: .: Permission denied
additionally, I thought that su would need the suid bit set
Does chmod 766 acheive that?
oh this works
Code:
adb shell
cd /data/local/tmp
ls -al
total 18
drwxrwx--x 2 shell shell 3452 2022-09-02 16:32 .
drwxr-x--x 4 root root 3452 2022-07-27 03:04 ..
-rw-rw-rw- 1 shell shell 11640 2022-09-02 16:29 su
Code:
chmod 776 su
ls -al
total 18
drwxrwx--x 2 shell shell 3452 2022-09-02 16:32 .
drwxr-x--x 4 root root 3452 2022-07-27 03:04 ..
-rwxrwxrw- 1 shell shell 11640 2022-09-02 16:29 su
Code:
adb shell
export PATH=$PATH:/data/local/tmp
su
su: setgid failed: Operation not permitted
The device has separate boot_a, boot_b, dtbo_a, dtbo_b partitions.
If I could be reasonably sure that booting a boot partition from a similar device (I have one) would pick up the dtb from this device then I think I could be reasonably confident of not frying anything, I might try and boot it from fastboot.

Categories

Resources