Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a file on /sdcard?

Tags:

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?

like image 948
Barry Fruitman Avatar asked Oct 01 '13 00:10

Barry Fruitman


3 Answers

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.

like image 60
Yuichi Araki Avatar answered Nov 16 '22 10:11

Yuichi Araki


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.

like image 42
jww Avatar answered Nov 16 '22 12:11

jww


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.

  1. adb shell to your device,
  2. go to /sdcard (mouting point may vary on each device)
  3. 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
  4. Format <yout-new>.img, in my case I used ext2. eg. mke2fs -F ubuntunew.img
  5. 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

like image 24
nanangarsyad Avatar answered Nov 16 '22 12:11

nanangarsyad