How to execute a file on /sdcard? - android

I'm trying to run sqlite3 on my rooted Nexus 4. I've gotten as far as pushing the executable to /sdcard but I cannot execute it. I'm running stock Android 4.3, rooted with SuperSU 1.45.
The file looks like this:
-rw-rw-r-- root sdcard_rw 36860 2013-09-30 17:29 sqlite3
So far:
chmod 777 sqlite3 does nothing
File.setExecutable() returns false (but File.exists() returns true).
Is there a better way to do this?

SD cards are usually formatted as FAT32 and mounted with all files unexecutable. SD card directory on Nexus 4 is a simulated one, but still the system prevents any file in it to be marked as executable. You need to move your file outside of your SD card to mark it as executable.

I know this is an old question.
But I want to suggest another work around for this problem by creating disk .img file in sdcard then mount it on /data/
Well, I know it was quite redundant, but at the very least it could be used as workaround if your internal disk was low on space.
Here, some instructions in case needed.
adb shell to your device,
go to /sdcard (mouting point may vary on each device)
dd if=/dev/zero of=<your-new>.img bs=1M count=0 seek=2048. This creates a new image file called <your-new>.img change the seek value to the size you want (e.g 2048 = 2GB). If dd not available, try to install busybox first, then from dd change into busybox dd
Format <yout-new>.img, in my case I used ext2. eg. mke2fs -F ubuntunew.img
Mount <your-new>.img to /data. eg. mount -o loop /sdcard/<your-new>.img /data/<your-mount-point>. If mount command not available use busybox.
Ok. That's all
References:
https://forum.xda-developers.com/showthread.php?t=2743108
https://linuxonandroid.uservoice.com/knowledgebase/articles/74683-how-to-i-give-linux-more-space

chmod 777 sqlite3 does nothing...
chmod +x doesn't work... I get "bad mode".
The "Bad Mode" is from a+x, +x, etc. Remember, its octal. Try:
chmod 0777 sqlite3
And Yuichi is probably correct - /mnt/sdcard is likely mounted with noexec.

Related

Copy folder from Android app to local Windows directory

I'm trying to use the Android Adb Command Prompt to copy a folder inside the app container to a local Windows folder. The device is running Android 5.1.1 and is not rooted.
adb pull or cp aren't working. How can I copy a folder?
The following approaches aren't working:
Approach 1
adb shell
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
error: device not found
Inside the shell you can't see to do adb pull. See here.
Approach 2
DDMS can't access the data folder.
Approach 3
adb shell
run-as DroidSample.DroidSample
cp /files/MetroLog/MetroLogs/ C:/temp/test
cp: /files/MetroLog/MetroLogs/: No such file or directory
Approach 4
adb shell
run-as DroidSample.DroidSample
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs/ C:/temp/test
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs is a directory (not copied).
This is also not working.
Approach 5
adb shell
run-as DroidSample.DroidSample
chmod 777 /files/MetroLog/MetroLogs
exit
exit
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
adb shell run-as DroidSample.DroidSample
chmod 700 /files/MetroLog/Metrologs
remote object '/data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs' does not exist
So also this isn't working.
Approach 6
adb shell
mkdir /sdcard/tmp
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs /sdcard/tmp
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs: Permission denied
This is also not working.
Approach 7
The only thing which half work is this
adb exec-out run-as DroidSample.DroidSample cat "files/MetroLog/MetroLogs/Log - 20160509.log" > C:/temp/test/test.log
But here I don't get the original file and I also have to know the exact file name. Additionally, that I loose line breaks and I have to do this for each file. Not that what I want.
So I'm running out of ideas. How can I access the internal stored files and copy them over?
You have almost solved the problem. As the storage of this kind is secured, you need to do one additional step. You need to copy the file from secured location to sdcard of the device. And then you can copy it anywhere via usb or android pull. Here are the command sequence I executed successfully.
adb shell
run-as DroidSample.DroidSample
cd shared_prefs
cp DroidSample.DroidSample_preferences.xml /sdcard/DroidSample.DroidSample_preferences.xml
exit
exit
adb pull /sdcard/DroidSample.DroidSample_preferences.xml C:/test/
That's it.
And I really appreciate the way you posted your question. Best of luck.
You're trying to gain read access to /data partition on actual android device. Such thing is not possible without root access, even if the app folder is yours. For the reason that permissions to read /data partition are not granted and cannot be granted, unless you're using an emulator. On emulator, which by default is with admin privileges for developer, you can access the data partition to read and write. On actual device you cannot. Not with adb, not with DDMS.
So basically speaking, anything that requires access to those files under /data is not going to work. Whether you sue cp command or pull command. The moment your kernel reads the beginning of your path which starts with /data/... it says: Oops, no can do.
You are trying to access /data folder of android device which is not accessible in unrooted device.

Mount boot partition on Galaxy S4 (i9500) (CyanogenMod 12.1)

I'm interesting in make some changes in init.rc file.
As I have read, I must get copy of boot.img, unpack it, add my changes to init.rc file, pack and push back new boot.img to phone, and after reboot my changes will be considered. (I can't just change init.rc file, that is at / directory, due to it will be rewritten at next reboot.)
So I try:
adb shell
su
fdisk -l /dev/block/mmcblk0
fdisk outputs list of all partition (mounted and unmounted) which are on phone.
I'm intersting in boot:
9 147456 163839 8192K 0700 BOOT
where 9 - is partition number, so my partition (device to mount) is /dev/block/mmcblk0p9.
Then I remount rootfs to read/write permissions:
mount -o rw,remount rootfs /
Create directory (mount point) /boot:
mkdir /boot
And then try to mount boot partition to /boot:
mount -t auto /dev/block/mmcblk0p9 /boot
but retrive "mount: No such device".
Are anybody faced with this ?
Thanks in advance for you help.
PS:
List of partitions can be also obtained by:
ls -l /dev/block/platform/dw_mmc.0/by-name
Edited:
I have sources, but I don't want to rebuild their, due to a large amount of time compilation. (I must make many changes in init.rc file and recompile all CyanogenMod it's very expensive).
I have tried to build only module tied, as I think, with init.rc (system/core/rootdir), just type mmp:
ila:~/cm_s4/cm_12_1/system/core/rootdir$ mmp
and obtained next line:
Install: /home/ila/cm_s4/cm_12_1/out/target/product/i9500/root/init.rc
but, no line such as (for example, when I type mmp in external/hello_world):
Pushing: /system/bin/hello_world

How to mount an external drive's ext4 partition on android and make it rw-available to all the apps

I have written the following shell script:
alias mount='/system/xbin/busybox mount'
set -e
set -x
MNT=sda1
function mkdir_ext() {
if [ ! -d $1 ]; then
mkdir -p $1
fi
chown $2 $1
chmod $3 $1
}
mkdir_ext /storage/emulated/$MNT root:media_rw 777
mount -t ext4 /dev/block/$MNT /storage/emulated/$MNT
mkdir_ext /data/media/$MNT root:media_rw 777
sdcard -u 1023 -g 1023 /storage/emulated/$MNT /data/media/$MNT
After executing the commands above, mount reports:
root#NEO-X8:/sdcard # mount|grep sda
/dev/block/sda1 /storage/emulated/sda1 ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/fuse /data/media/sda1 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
I am working via ssh, remotely, using rooted ssh/sftp daemon, and while logged in as root, I can list the files in /storage/emulated/sda1.
From what I understand, android is case-insensitive in regards to filesystems by design, so the filesystem has to be fused.
The problem is, I see just an empty directory in /data/media/sda1. Even stranger is that, if I navigate to /storage/emulated/sda1 from the device as root with bash shell X, I also see an empty directory.
I have tried different other apps and I've tried to also use sdcard_rw instead of media_rw (with the uid / gid 1015 instead of 1023), nothing works.
How to get ext4 to work for all apps on a rooted Minix NEO X8-H? Using anything but ext4 is not an option, the 4TB drive already contains important data. As a side note, sda1 is just a small 1GB partition.
I will assume that your device is rooted from what you have done so far so will not go into that. Though I cannot be certain this is your issue I shall explain how I solved a similar problem.
Resent versions of android with the intent on improving device security are now using the (somewhat half arsed) feature of making mounts performed by most processes not visible to other processes. Working around this is frustratingly device specific, however it appears the Minix NEO X8-H is using a "vanilla" style source build of android. Therefore you have a good chance of using StickMount in order to mount the USB stick, it should enable the global mounting of USB devices running any file-system supported by your ROM (which should include ext4 given you have already mounted it before).
I have not tested this personally on your device so cannot guarantee it will work but have had success with a number of other android devices so this is certainly worth a shot.
I use mkfs -t ext4 /dev/sdf2 format SDcard and insert into samsung s4 anrdoid phone.
adb shell
su
mount /dev/block/mmcblk1p2 /root
I cant't mount this SDcard, I have googled it but no solution.
The last, I found this can succeed :)))
mk2fs -t ext4 /dev/sdf2
and ...

Android ADB shell commands: Mount host PC folder?

Hope this isn't too much of an amateur/moron question: I'm trying to replace most ringtones and alarms (Dell Streak 5 (2.2.2 rooted)) with a few of my own pet sounds.
For reasons I won't bother you with, I can't use an SD card, so my .ogg replacements need be transferred straight from my PC to their respective default folders under /system/media/audio/ .
ADB push and pull commands don't seem to accept widlcards (which is a pain) but anyway, despite setting the system folder to rw, I get 'permission denied' when I tediously attempt to pull or push files one by one.
But I should be able to rm and cp interactively from ADB's shell # prompt, with simple Unix commands to transfer groups of files between the /system/media/audio folders and my Windows PC. But to do this I presumably need to mount my PC source folder, and I have no idea how to do this.
I'd be grateful for any info or ideas...
You need to have root access on the phone. My advice as a programmer would be to
1) Write a program to do this...
or just do it the easy way haha. Try this (your device must be rooted):
adb shell into your device using $> adb shell
move to the local folder using $> cd /data/local
Now create a directory for your tones with $> mkdir my_tones - this shouldn't require su
Next you must push your .ogg files from your computer to the /data/local/my_tones folder
Now you can become su user with $> su
Now you should be able to copy the files from the /data/local/my_tones directory to where ever it is you would like them.
Hope this helps.

Change file permission:/system/etc/bluetooth/audio.config

I use a Samsung Dart - SGH-T499 with Android v2.2.2 on it.
Now I need to edit the /system/etc/bluetooth/audio.config file. For that I rooted my phone using the SuperOneClickv2.3.3-ShortFuse. And browsed the file-system using Root Explorer. But I am unable to edit the permission of the audio.config. Could you please help me?
You also need to ensure that the /system directory, as it's a filesystem, is mounted read-write. In the adb shell use -o rw,remount as parameters to the mount command to do this. First you need to determine what ( hardware / physical / logical ) device that particular filesystem is stored on - use the mount command on its own to see the list and select the one which has /system as its mount point.
Can you not issue a
chmod 777 /system/etc/bluetooth/audio.config
...from the adb shell?

Categories

Resources