Shell commands - Desire General

Here you will find a list of some shell commands you can use on your android phone, either with a terminal emulator or over adb shell from your PC. I would recommend using connectbot as your terminal emulator.
The commands listed are in no way limited to what is described below, I am just scraping the surface here. For more information on these commands type ' --help' after your command, e.g. 'mount --help' or use google, most of these commands are exactly the same as what you would find on any Linux system, so you will find EXTENSIVE information on the web if you want to know more.
These commands work on my HTC Desire running Cyanogenmod 6 (Android 2.2), most, if not all of them should work on other devices and/or roms.
If you have any suggestions post them below or pm me and I will edit this post to include them.
Notes
Most of these commands require root privileges, type su first.
Everything after a # is a not and not a part of the command.
busybox
What it does
Provides a selection of commands not built into android by default.
Example(s)
busybox cp a b
Notes
busybox is included in most custom roms and has aliases set up so you do not need to type busybox before the commands eg, 'cp' is the same as 'busybox cp' in most custom roms.
cat
What it does
Prints the contents of a (text)file onscreen.
Example(s)
cat file
cd
What it does
Changes the current directory. You may find it easier to change to the directory you will be working in before issuing other commands so you dont need to include the full path in your commands.
Example(s)
cd .. # Go up 1 directory level, eg go from '/sdcard/download/ to '/sdcard'.
cd /sd-ext # Change to '/sd-ext'.
chmod
What it does
Makes a file executable
Example(s)
chmod 755 /data/bin/yourbin
cp
What it does
Copies files/directories
Example(s)
cp filea fileb
cp -rf directorya directoryb # Copy entire directory recursively and forces copy.
df
What it does
Displays information on all mounted filesystems (free space).
Example(s)
df -hm # Show disk usage in human readable format in Megabytes.
du
What it does
Diplays the size of files/directories.
Example(s)
du -md 1 # Prints the size of all directories in Megebytes.
du -sh file # Prints the size of file in human readable format.
du -sh directory # Prints the size of directory in human readable format.
export
What it does
Sets environment variables.
Example(s)
export PATH=$PATH;/sd-ext/bin;
free
What it does
Display the amount of free and used system memory
losetup
What it does
Associates loop disk images with loop devices.
Example(s)
losetup /sdcard/disk.img /dev/block/loop7
Notes
Android 2.2's implementation of apps2sd uses one loop device for each app saved to SD. There are 8 loop devives by default (loop0-loop7) so if you have 8 or more apps saved to SD you will not be able to use this command. There is no issue when using 'oldschool a2sd'
ls
What it does
List Directory contents.
Example(s)
ls -a # List directory contents including hidden contents.
mount
What it does
Mounts a filesystem.
Example(s)
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 # Remounts /system as writable.
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 # Remounts /system as read only.
mount -t ext2 /dev/block/loop6 /sdcard/disk # Mount loop6 on /sdcard/disk.
mount /sd-ext /sdcard/sd-ext # Mount /sd-ext on /sdcard/sd-ext.
Notes
On other devices it may be possible to mount disk images without going through losetup and using the option -loop in mount instead.
If you are having trouble with mount try using busybox mount instead, the busybox version seems more capable than the one shipped with Android.
mv
What it does
Move/rename files/directories
Example(s)
mv download/file stuff/file
mv picture4.jpg mydog.jpg
ping
What it does
Pings a server to check for conectivity.
Example(s)
ping -c 5 http://www.google.com # Ping google 5 times
Notes
if you do not include the -c option ping will work indefinatly.
pwd
What it does
Prints the current directory.
rm
What it does
Remove file/directory.
Example(s)
rm file
rm -rf directory # Delete a directory and its contents.
rmdir
What it does
Removes a directory
Example(s)
rmdir emptydir
Notes
If a directory has contents us 'rm -rf' instad.
su
What it does
Gives you root privelages.
touch
What it does
Makes an empty file
Example(s)
touch file.txt
wget
What it does
Download things from http or ftp.
Example(s)
wget http://www.google.com

Excellent, thank you.
Just what the doctor ordered for n00bs like me

Related

MoDaCo custom rom - weird display of "ls"

I've installed modaco's custom rom (2.6) for a few times; when i use 'adb shell' and try to do a "ls" it gives me the following:
Code:
C:\>adb shell
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# cd /system
cd /system
# ls
ls
app customize framework medi
a xbin
bin etc lib sd[
0m
build.prop fonts lost+found usr[
0m
# ls
ls
app customize framework medi
a xbin
bin etc lib sd[
0m
build.prop fonts lost+found usr[
0m
but when I boot into recovery mode it works fine:
Code:
ls
app customize framework media xbin
bin etc lib sd
build.prop fonts lost+found usr
/system # cd
anyone got similar problems?
kazuni said:
I've installed modaco's custom rom (2.6) for a few times; when i use 'adb shell' and try to do a "ls" it gives me the following:
Code:
C:\>adb shell
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# cd /system
cd /system
# ls
ls
app customize framework medi
a xbin
bin etc lib sd[
0m
build.prop fonts lost+found usr[
0m
# ls
ls
app customize framework medi
a xbin
bin etc lib sd[
0m
build.prop fonts lost+found usr[
0m
but when I boot into recovery mode it works fine:
Code:
ls
app customize framework media xbin
bin etc lib sd
build.prop fonts lost+found usr
/system # cd
anyone got similar problems?
Click to expand...
Click to collapse
Those are ANSI color codes and they appear because ls thinks you have a terminal that supports it. Paul will probably fix this in an upcoming version.
If you want to get ls to behave normally you can run the following command.
alias ls="ls --color=no"
After that ls should produce normal output.
packetlss said:
Those are ANSI color codes and they appear because ls thinks you have a terminal that supports it. Paul will probably fix this in an upcoming version.
If you want to get ls to behave normally you can run the following command.
alias ls="ls --color=no"
After that ls should produce normal output.
Click to expand...
Click to collapse
Ahh, thanks for the heads up. got it
same for me here, but under ftp (ftpserver) and usb file connection

[ROOT ICS] The hard way && Digging for roots

For anyone that doesn't want to root the hard way crossix has come up with a double click root for Windows forum.xda-developers.com/showpost.php?p=23052186&postcount=105
Update 2/26/12
/system can now be mounted writable see the bottom of this post.
So the old Honeycomb exploit has now been patched in ICS. But there was an exploit found in the newer ICS kernels. Written by saurik,: called mempodroid
There is an offset needed as an argument to the binary, for the a100 we'll use what has worked for the a200 as noted in sauriks github linked above.
The issue with this is mounting /system as writable. I'm not sure if it's something in ICS, but it appears to be write protected. As noted here and here we will loop mount the system partition.
The tools needed are:
1. mempodroid under Usage Instructions, download pre-compiled
2. busybox 1.20 snapshot 3-10-12
3. su the latest from androidsu.com, extract from system/bin
4. mount.txt script
After downloading and extracting place them all in a folder called tools.
This must be done with adb. Issue the following from cmd or a terminal:
Code:
$ adb shell mkdir /data/local/tools
$ adb push tools /data/local/tools ; adb shell
$ cd /data/local ; chmod 755 tools/*
$ cd tools ; ./mempodroid 0xd9f0 0xaf47 sh
If all went well you should be at a hash # prompt. This is temp root.
mount /system rw the new way:
Code:
# PATH=$PWD:$PATH
# sh mount.txt -o remount,rw /system
Copy su and busybox to /system
Code:
# ./busybox cp busybox /system/xbin; ./busybox cp su /system/xbin/
# chmod 6755 /system/xbin/su
Install busybox
Code:
# cd /system/xbin
# for i in $(busybox --list); do ln -s busybox $i; done; sync
Copy the mount script
If busybox is updated this step must be run again
Code:
# cp /data/local/tools/mount.txt /system/bin/mount
# cp /data/local/tools/mount.txt /system/xbin/mount
Done your a100 should be rooted
the old way:
Now lets loop mount /system
Code:
[b]This is no longer needed[/b]
# ./busybox losetup -o $((512 * 51200)) /dev/block/loop7 /dev/block/mmcblk0
Code:
# ./busybox losetup /dev/block/loop7 /dev/block/mmcblk0p3
# mkdir loop ; mount -t ext4 /dev/block/loop7 loop
Copy su and busybox to the new mount point.
Code:
# ./busybox cp su loop/xbin/ ; ./busybox cp busybox loop/xbin/
# chmod 6755 loop/xbin/su ; sync
If it worked your a100 is fully rooted. Make sure to install SuperUser from the Market.
Either get busybox installer from the market, and install it to /data/local/tools/loop/xbin
Or:
Code:
# cd loop/xbin
# for i in $(busybox --list); do ln -s busybox $i; done; sync
The mount point won't survive a reboot so in order to write to /system again run:
Code:
# busybox losetup /dev/block/loop7 /dev/block/mmcblk0p3
# mount -t ext4 /dev/block/loop7 /data/local/tools/loop
[update 2/26/12]
To mount /system as writable do the following from adb. We'll just make a directory called /data/loop for easy access.
Code:
$ adb shell
$ su
# stop
[b]your screen will go black[/b]
# mkdir /data/loop
[b]skip this if the loop is already set up
# busybox losetup /dev/block/loop7 /dev/block/mmcblk0p3[/b]
# mount -t ext4 /dev/block/loop7 /data/loop
# mount -o bind /data/loop /system
# start
You can write to /system with any app but /system can't be remounted ro then back to rw.
This can be added to /etc/install-recovery.sh to make it permanent
Code:
busybox losetup /dev/block/loop7 /dev/block/mmcblk0p3
mount /dev/block/loop7 /data/loop
mount -o bind /data/loop /system
Thanks to crossix as the first to get temp root, and Icewyng for pointing out the exploit and helping with the magic number.
Ill be testing this when I get home, if it works Ill attempt to write a 1 command script to do it.
Sent from my MB860 using XDA App
OK...
Testing this out and found there were a couple of bugs.
You didn't have a "loop" folder created so I made one in the "tools" folder.
and, when mounting, you need to specify -t ext4.
Here are the revised commands for # mount /dev/block/loop7 loop
mkdir loop;mount -t ext4 /dev/block/loop7 /data/local/tools/loop
I noticed that the files /data/local/tools/loop/xbin/su and /data/local/tools/loop/xbin/busybox don't exist on /system/xbin until after a restart.
Finally, the busybox we are using to install doesn't seem to make all of the links to all of the nice commands we are used to, so things like grep, cp, etc... they won't work. I'm trying to figure out how to re-run the GUI busybox installer and point it to the loop folder, but haven't had much success.
danifunker said:
OK...
Testing this out and found there were a couple of bugs.
You didn't have a "loop" folder created so I made one in the "tools" folder.
and, when mounting, you need to specify -t ext4.
Here are the revised commands for # mount /dev/block/loop7 loop
mkdir loop;mount -t ext4 /dev/block/loop7 /data/local/tools/loop
I noticed that the files /data/local/tools/loop/xbin/su and /data/local/tools/loop/xbin/busybox don't exist on /system/xbin until after a restart.
Finally, the busybox we are using to install doesn't seem to make all of the links to all of the nice commands we are used to, so things like grep, cp, etc... they won't work. I'm trying to figure out how to re-run the GUI busybox installer and point it to the loop folder, but haven't had much success.
Click to expand...
Click to collapse
You beat me to the punch... was about to point it out.
Not sure what version of busybox this is but I will try with 1.19.2 and see how it goes.
Edit: Got root! It works great... for Busybox, use Busybox Installer to be able to get the latest version (1.19.4) I confirm that system is R/O for now.
danifunker said:
OK...
Testing this out and found there were a couple of bugs.
You didn't have a "loop" folder created so I made one in the "tools" folder.
and, when mounting, you need to specify -t ext4.
Here are the revised commands for # mount /dev/block/loop7 loop
mkdir loop;mount -t ext4 /dev/block/loop7 /data/local/tools/loop
I noticed that the files /data/local/tools/loop/xbin/su and /data/local/tools/loop/xbin/busybox don't exist on /system/xbin until after a restart.
Finally, the busybox we are using to install doesn't seem to make all of the links to all of the nice commands we are used to, so things like grep, cp, etc... they won't work. I'm trying to figure out how to re-run the GUI busybox installer and point it to the loop folder, but haven't had much success.
Click to expand...
Click to collapse
I did have some typos, think it's right now. That is an old busybox, it was just a quick find and it includes losetup but it's not one to use full time. Maybe sync is needed at the end so files are written properly. I didn't have to use -t ext4 with HC, but Ill add it to the OP
[edit] you have to use "busybox cp or busybox grep" I didn't include a way to add all the symlinks. Wow I have typos everywhere it's the end of the day for me, working nights.
Ok ... Got root!
Titanium works, Busybox Installer works, Superuser works, Root Explorer works...
Only thing is that System is R/O but we will work on it.
Waiting for a R/W system...and then, no one will stop my update
I can't get it to root :-(
It say not found
Sent from my A100 using xda premium
jondi23 said:
I can't get it to root :-(
It say not found
Sent from my A100 using xda premium
Click to expand...
Click to collapse
At what point, need some more details.
The tools folder gets pushed (the 3 files are copied) but then it says there is no such folder.
edit: never mind - i created the folder manually and pushed the files into the folder
edit2: rooted - thakns guys
Brilliat work, will try this later (need to get the sdk all set up again, I've been distro swapping). Got a pool match tonight too, so will try as soon as I can, will give whatever feedback I can later.
myprecious27 said:
The tools folder gets pushed (the 3 files are copied) but then it says there is no such folder.
edit: never mind - i created the folder manually and pushed the files into the folder
Click to expand...
Click to collapse
I forgot adb can't push a whole directory, it instead only copies the files within the directory.
wait how is it rooted if it's r/o I thought point of root was to make the file system r/w... er is root just allowing you to view all directories? Sorry for a noobish question, but you gotta start somewhere right?
rando152 said:
wait how is it rooted if it's r/o I thought point of root was to make the file system r/w... er is root just allowing you to view all directories? Sorry for a noobish question, but you gotta start somewhere right?
Click to expand...
Click to collapse
Well I think if we have su working we will be able to mount /system rw in some way if not directly. I cant imagine not being able to.
In any case though being able to write to /data as root is very useful. Example: Hulu flash fix.
You can't view /data if you're not root. That's one thig. Also, other functions may require root, like advanced networking things, etc.
I agree, not being able to write to /system is a major inconvenience, but most of the root programs will still work, as long as you're not writing to /system.
Since this is a temp root, does it mean that I will have to reroot every time I reboot? Will apps like Adfree work on this?
better yet is there a way we can do this solely on the tab? im away for work for another 4 weeks and only have my cell and a100 with me :-(
Sent from my SGH-I897 using xda premium
I get
Code:
255|[email protected]:/data/local/tools # mount -t ext4 /dev/block/loop7 /data/local
/tools/loop
lock/loop7 /data/local/tools/loop <
mount: Invalid argument
simoneser said:
I get
Code:
255|[email protected]:/data/local/tools # mount -t ext4 /dev/block/loop7 /data/local
/tools/loop
lock/loop7 /data/local/tools/loop <
mount: Invalid argument
Click to expand...
Click to collapse
I noticed the same thing happen after you root it and restart... not sure what to do next. Are you at temp loop?
simoneser said:
I get
Code:
255|[email protected]:/data/local/tools # mount -t ext4 /dev/block/loop7 /data/local
/tools/loop
lock/loop7 /data/local/tools/loop <
mount: Invalid argument
Click to expand...
Click to collapse
danifunker said:
I noticed the same thing happen after you root it and restart... not sure what to do next. Are you at temp loop?
Click to expand...
Click to collapse
try:
Code:
# busybox losetup -d /dev/block/loop7
# busybox losetup -o $((512 * 51200)) /dev/block/loop7 /dev/block/mmcblk0
# mount -t ext4 /dev/block/loop7 /data/local/tools/loop
The first line may produce
losetup: /dev/block/loop7: No such device or address
If it's not looped
After you are rooted the above can be run without adb from a terminal as su.
The mount point can be anywhere ex. /sdcard/loop instead of /data/local/tools/loop

[Q] Run script on FireTV boot

I have a very simple script to mount my NAS to a specific path that I want executed every time my FireTV boots.
I have read about pointing to it in the install-recovery-2.sh, however that is not available on my FireTV. I have also read about placing the script in system/etc/init.d/ however that path doesn't exist on the fireTV either.
Would prefer to do this at the system level and not rely on a manager (Tasker, Script Manager, etc).
Anyone have any experience?
Update w/ solution:
I was able to get this working by placing a script called install-recovery.sh in /system/etc/ . Make sure that permissions are set appropriately (at least 755). If creating the script on a Windows machine, make sure there aren't any hidden whitespace characters (I personally verified the script using SManager on my Fire TV).
Code:
[B]sleep 15[/B]
mkdir /mnt/obb/nas
chmod 777 /mnt/obb/nas
[B]sleep 20[/B]
mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
The sleep command is necessary as the script may run before the network is initialized.
Thanks rbox and ECEXCURSION!
patrickorr said:
I have a very simple script to mount my NAS to a specific path that I want executed every time my FireTV boots.
I have read about pointing to it in the install-recovery-2.sh, however that is not available on my FireTV. I have also read about placing the script in system/etc/init.d/ however that path doesn't exist on the fireTV either.
Would prefer to do this at the system level and not rely on a manager (Tasker, Script Manager, etc).
Anyone have any experience?
Click to expand...
Click to collapse
/system/etc/install-recovery.sh
rbox said:
/system/etc/install-recovery.sh
Click to expand...
Click to collapse
That file does not exist in /system/etc/ on my FireTV
patrickorr said:
That file does not exist in /system/etc/ on my FireTV
Click to expand...
Click to collapse
Yes... you have to create it...
rbox said:
Yes... you have to create it...
Click to expand...
Click to collapse
Ahh, sorry a little dense
Will give that a shot and report back on the results
Ok, I have placed install-recovery.sh (which houses my mounting script) in /system/etc/
I reboot and it doesn't appear that the script has run. Is there anything else I would need to do in order to get it to run on boot?
If it matters here are the details on my FireTV
Custom Recovery 6.0.5.1.4a
Pre-rooted 51.1.4.1_514013920
patrickorr said:
Ok, I have placed install-recovery.sh (which houses my mounting script) in /system/etc/
I reboot and it doesn't appear that the script has run. Is there anything else I would need to do in order to get it to run on boot?
If it matters here are the details on my FireTV
Custom Recovery 6.0.5.1.4a
Pre-rooted 51.1.4.1_514013920
Click to expand...
Click to collapse
And you're sure the script works?
rbox said:
And you're sure the script works?
Click to expand...
Click to collapse
That is a very good question How can I test that my script is functioning?
From adb shell or Terminal emulator I type the following commands to mount my NAS:
Code:
su
cd /mnt/obb/
mkdir nas
chmod 777 nas
mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
To turn this into a script I just dumped it into notepad and added #!/system/bin/sh to the top and saved it as install-recovery.sh.
patrickorr said:
That is a very good question How can I test that my script is functioning?
From adb shell or Terminal emulator I type the following commands to mount my NAS:
Code:
su
cd /mnt/obb/
mkdir nas
chmod 777 nas
mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
To turn this into a script I just dumped it into notepad and added #!/system/bin/sh to the top and saved it as install-recovery.sh.
Click to expand...
Click to collapse
Run it from adb, but right off the bat, I can tell you you need to chmod 755 it atleast before that will work.
rbox said:
Run it from adb, but right off the bat, I can tell you you need to chmod 755 it atleast before that will work.
Click to expand...
Click to collapse
Ok, was able to run the script, but got the following error(s):
Code:
127|[email protected]:/system/etc # sh ./install-recovery.sh
sh ./install-recovery.sh
: not foundecovery.sh[2]:
: not foundecovery.sh[3]: su
: No such file or directoryd: /mnt/obb/
, Read-only file system
: No such file or directory
mount: No such file or directory
patrickorr said:
Ok, was able to run the script, but got the following error(s):
Code:
127|[email protected]:/system/etc # sh ./install-recovery.sh
sh ./install-recovery.sh
: not foundecovery.sh[2]:
: not foundecovery.sh[3]: su
: No such file or directoryd: /mnt/obb/
, Read-only file system
: No such file or directory
mount: No such file or directory
Click to expand...
Click to collapse
Well first of all, don't run it with sh... it needs to have #!/system/bin/sh at the top, and you need to run it directly. Second, don't put su in it because it's already running in the root context.
rbox said:
Well first of all, don't run it with sh... it needs to have #!/system/bin/sh at the top, and you need to run it directly. Second, don't put su in it because it's already running in the root context.
Click to expand...
Click to collapse
How would I run it directly?
Here is my current script (with su removed):
Code:
#!/system/bin/sh
cd /mnt/obb/
mkdir nas
chmod 777 nas
mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
patrickorr said:
How would I run it directly?
Here is my current script (with su removed):
Code:
#!/system/bin/sh
cd /mnt/obb/
mkdir nas
chmod 777 nas
mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
Click to expand...
Click to collapse
Just type:
/system/etc/install-recovery.sh
rbox said:
Just type:
/system/etc/install-recovery.sh
Click to expand...
Click to collapse
I am attempting to run that in adb shell, but am getting the following errors:
Code:
[email protected]:/ $ cd /system/etc/
cd /system/etc/
[email protected]:/system/etc $ stat -c "%a %n" install-recovery.sh
stat -c "%a %n" install-recovery.sh
777 install-recovery.sh
[email protected]:/system/etc $ /system/etc/install-recovery.sh
/system/etc/install-recovery.sh
/system/bin/sh: /system/etc/install-recovery.sh: No such file or directory
1|[email protected]:/system/etc $ ./system/etc/install-recovery.sh
./system/etc/install-recovery.sh
/system/bin/sh: ./system/etc/install-recovery.sh: not found
127|[email protected]:/system/etc $
It seems like the permissions are correct on the file, and I also tried adding ./ before the path to see if that made any differences.
I made a slight "upgrade" to my script to see if it would help (but as you can probably already see, I am not exactly sure what I am doing!):
Code:
#!/system/bin/sh
mkdir /mnt/obb/nas
chmod 777 /mnt/obb/nas
busybox mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
patrickorr said:
I am attempting to run that in adb shell, but am getting the following errors:
Code:
[email protected]:/ $ cd /system/etc/
cd /system/etc/
[email protected]:/system/etc $ stat -c "%a %n" install-recovery.sh
stat -c "%a %n" install-recovery.sh
777 install-recovery.sh
[email protected]:/system/etc $ /system/etc/install-recovery.sh
/system/etc/install-recovery.sh
/system/bin/sh: /system/etc/install-recovery.sh: No such file or directory
1|[email protected]:/system/etc $ ./system/etc/install-recovery.sh
./system/etc/install-recovery.sh
/system/bin/sh: ./system/etc/install-recovery.sh: not found
127|[email protected]:/system/etc $
It seems like the permissions are correct on the file, and I also tried adding ./ before the path to see if that made any differences.
I made a slight "upgrade" to my script to see if it would help (but as you can probably already see, I am not exactly sure what I am doing!):
Code:
#!/system/bin/sh
mkdir /mnt/obb/nas
chmod 777 /mnt/obb/nas
busybox mount -o noperm,unc=\\\\192.168.1.147\\Public,username=xxxxxx,password=xxxxxx -t cifs none /mnt/obb/nas
Click to expand...
Click to collapse
That sounds strange... but you'll need to run su before running it, because it needs root. It could be that its not in UNIX file format. If you edited it on Windows you need to use an advanced editor that has the ability to save as UNIX format.
rbox said:
That sounds strange... but you'll need to run su before running it, because it needs root. It could be that its not in UNIX file format. If you edited it on Windows you need to use an advanced editor that has the ability to save as UNIX format.
Click to expand...
Click to collapse
Unix file format appears to have been the issue. When I opened it with SManager I saw some nasty whitespace characters. Removed those and the script works as expected:
Code:
[email protected]:/data/media/0 # ./install-recovery.sh
./install-recovery.sh
[email protected]:/data/media/0 # cd /mnt/obb/nas
cd /mnt/obb/nas
[email protected]:/mnt/obb/nas # ls
ls
Games
Photos
Shared Music
Shared Videos
eBooks
key.txt
[email protected]:/mnt/obb/nas #
After confirming the script worked as expected, I moved it to /system/etc/ and verified permissions were acceptable (777). Upon reboot I see that the /mnt/obb/nas is created, however the NAS is not mapped.
Can you comment, when is the install-recovery.sh called in the boot up process? Is it possible that the CIFS module isn't fully loaded when this is called? Alternatively, is there a log that I could reference to see if any error occurred while running the script at startup?
patrickorr said:
Unix file format appears to have been the issue. When I opened it with SManager I saw some nasty whitespace characters. Removed those and the script works as expected:
Code:
[email protected]:/data/media/0 # ./install-recovery.sh
./install-recovery.sh
[email protected]:/data/media/0 # cd /mnt/obb/nas
cd /mnt/obb/nas
[email protected]:/mnt/obb/nas # ls
ls
Games
Photos
Shared Music
Shared Videos
eBooks
key.txt
[email protected]:/mnt/obb/nas #
After confirming the script worked as expected, I moved it to /system/etc/ and verified permissions were acceptable (777). Upon reboot I see that the /mnt/obb/nas is created, however the NAS is not mapped.
Can you comment, when is the install-recovery.sh called in the boot up process? Is it possible that the CIFS module isn't fully loaded when this is called? Alternatively, is there a log that I could reference to see if any error occurred while running the script at startup?
Click to expand...
Click to collapse
It's probably running before the network comes up. There might be maybe some kind of regular android apk that will run a script when the network comes up. There might be a way to just stick a loop in your current script waiting for something, not sure.
You could probably just add "sleep 30" to the beginning of the script.
rbox said:
It's probably running before the network comes up. There might be maybe some kind of regular android apk that will run a script when the network comes up. There might be a way to just stick a loop in your current script waiting for something, not sure.
Click to expand...
Click to collapse
ECEXCURSION said:
You could probably just add "sleep 30" to the beginning of the script.
Click to expand...
Click to collapse
Thanks, will give that a try when I get back home.
Edit: It worked! Thanks to the both you for your input.
Just wondering since I'm a newbie when it comes to this one. Does mounted folder have to be in /mnt/obb or can I choose any directory I want?

[GUIDE] Run Sickbeard/Transmission/sabnzbd/SSH/Samba/More on Shield

I've seen lots of people saying its not possible to make the shield an all in one solution for downloading, but after hours of tinkerering I've got a semi easy way of running the above services (and tons more) from the shield. This does requrie a bit of command line-fu , but I think I've got most of the hard work done. When its all said and done, we'll have a working entware-ng installation ( https://github.com/Entware-ng/Entware-ng)
--This guide is a work in progress, there are a few other items I'll add that will improve user experience, but as it stands now it should work as intended. I also haven't gotten a samba config to work yet, so if anyone can figure it out, let me know and I'll update a section on it
I've addapted this guide from a few github projects , but that likely means some commands/steps are actually useless on the shield:
https://github.com/erichlf/AndroidSeedBox
(will add other sources later)
AS ALWAYS MAKE A BACKUP OF DATA -- I AM NOT RESPONSIBLE IF YOUR DEVICE LOSES DATA (to my knowledge, there is no risk of bricking your device doing this, at worst a factory reset/reflash)
Pre-reqs:
Shield has to have ROOT
ADB set up on PC
Busybox : http://www.apkmirror.com/apk/jrummy-apps-inc/busybox-for-android/
Rom Toolbox Lite : Not on apk mirror, so side load from your favorite place
For this process, I recommend having your shield next to your computer, and share inputs with your monitor. You can do 90% of it from an ADB shell, but a few parts you will need to use a terminal on the shield itself, and keyboard is way easier than controller
Install Busybox on the shield, but use the oldest version available (I think the wget for 1.26 messes with the process)
run "ADB Shell" and run these commands on the shield (You can copy/paste multiple lines into the cmd window):
Code:
su
mount -o rw,remount /
ls /data/entware-ng >/dev/null 2>&1 || mkdir /data/entware-ng
cd .; ln -s /data/entware-ng /opt
ls /data/entware-ng/rootbin >/dev/null 2>&1 || mkdir /data/entware-ng/rootbin
cd .; ln -s /data/entware-ng/rootbin /bin
ls /data/entware-ng/rootlib >/dev/null 2>&1 || mkdir /data/entware-ng/rootlib
cd .; ln -s /data/entware-ng/rootlib /lib
ls /data/entware-ng/tmp >/dev/null 2>&1 || mkdir /data/entware-ng/tmp
cd .; ln -s /data/entware-ng/tmp /tmp
ls /data/entware-ng/home >/dev/null 2>&1 || mkdir /data/entware-ng/home
ls /data/entware-ng/home/root >/dev/null 2>&1 || mkdir /data/entware-ng/home/root
ls /data/entware-ng/home/user >/dev/null 2>&1 || mkdir /data/entware-ng/home/user
chmod 0755 /data/entware-ng/home/root
chown root.root /data/entware-ng/home/root
chmod 0755 /data/entware-ng/home/user
We've set up our staging area, and created a new home directory.
Now lets install Entware
Code:
ls /data/entware-ng/bin >/dev/null 2>&1 || mkdir /data/entware-ng/bin
ls /data/entware-ng/lib >/dev/null 2>&1 || mkdir /data/entware-ng/lib
ln -s /system/bin/sh /bin/sh
wget http://pkg.entware.net/binaries/armv7/installer/entware_install.sh -O /data/entware-ng/entware_install.sh
sh /data/entware-ng/entware_install.sh
Now lets install a new Busybox and Wget
Code:
/opt/bin/opkg install busybox
/opt/bin/opkg install wget
cd /bin; ln -s /data/entware-ng/bin/busybox sh
cd /bin; ln -s /data/entware-ng/bin/busybox echo
cd /bin; ln -s /data/entware-ng/bin/busybox rm
cd /bin; ln -s /data/entware-ng/bin/busybox rmdir
cd /bin; ln -s /data/entware-ng/bin/busybox sed
cd /bin; ln -s /data/entware-ng/bin/busybox mkdir
cd /bin; ln -s /data/entware-ng/bin/busybox head
cd /bin; ln -s /data/entware-ng/bin/busybox sort
cd /bin; ln -s /data/entware-ng/bin/busybox dirname
cd /bin; ln -s /data/entware-ng/bin/busybox ln
cd /bin; ln -s /data/entware-ng/bin/busybox mv
cd /bin; ln -s /data/entware-ng/bin/busybox cat
cd /bin; ln -s /data/entware-ng/bin/busybox chown
cd /bin; ln -s /data/entware-ng/bin/busybox chmod
cd /bin; ln -s /data/entware-ng/bin/busybox pgrep
This next step may be optional. Sets up resolv.conf (which may already exist, I'm not sure) and mtab (I don't know what this is)
Code:
echo nameserver 8.8.8.8 >/data/entware-ng/etc/resolv.conf
ls /etc >/dev/null 2>&1 || mkdir /etc
mount -o rw,remount /system
ls /etc/resolv.conf >/dev/null 2>&1 && rm /etc/resolv.conf
cd .; ln -s /data/entware-ng/etc/resolv.conf /etc/resolv.conf
cd .; ln -s /proc/mounts /etc/mtab
Create Passwd file
Code:
echo root:x:0:0:root:/opt/home/root:/bin/sh >/data/entware-ng/etc/passwd
echo shell:x:2000:2000:shell:/opt/home/user:/bin/sh >>/data/entware-ng/etc/passwd
cd .; ln -s /data/entware-ng/etc/passwd /etc/passwd
echo root:x:0:root >/data/entware-ng/etc/group
echo shell:x:2000:shell >>/data/entware-ng/etc/group
cd .; ln -s /data/entware-ng/etc/group /etc/group
echo /bin/sh > /etc/shells
echo PATH=/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin > /etc/profile
echo export PATH >> /etc/profile
OPTIONAL: If you want to use Open SSH with password instead of certs you can do the following step. I have done this, and haven't noticed any issues, but it may lessen the security of Root
Code:
/data/entware-ng/bin/busybox passwd root
Now let's create a script that will initialize Entware-ng after reboot
Code:
echo \#\!/system/bin/sh > /data/entware-ng/entware-init.sh
echo mount -o rw,remount rootfs / >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng /opt >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/rootlinb /lib >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/rootbin /bin >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/tmp /tmp >> /data/entware-ng/entware-init.sh
echo ln -s /system/bin/sh /bin/sh >> /data/entware-ng/entware-init.sh
echo mount -o ro,remount rootfs >> /data/entware-ng/entware-init.sh
chmod 755 /data/entware-ng/entware-init.sh
Now lets create a start script that calls the initialize script we just made, but also returns a shell in the new environment
Code:
echo \#\!/system/bin/sh > /data/entware-ng/start.sh
echo ls '/opt >/dev/null 2>&1 ||' su -c /data/entware-ng/entware-init.sh >> /data/entware-ng/start.sh
echo export PATH=/opt/sbin:/opt/bin:/opt/rootbin:/opt/local/bin:/system/bin >> /data/entware-ng/start.sh
echo if busybox test $(busybox id -u) = 0; then HOME=/opt/home/root; else HOME=/opt/home/user; fi >> /data/entware-ng/start.sh
echo export HOME >> /data/entware-ng/start.sh
echo '/opt/etc/init.d/rc.unslung start' >> /data/entware-ng/start.sh
echo /bin/sh >> /data/entware-ng/start.sh
chmod 755 /data/entware-ng/start.sh
Now, lets install different services. These are optional, and there are tons more, but this will get transmission/sickbeard/ssh going
Code:
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install vim
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install samba36-server
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install transmission-web transmission-daemon-openssl
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install python
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install python-setuptools
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install python-pip
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install python-cheetah
PATH=/data/entware-ng/bin:/bin /data/entware-ng/bin/opkg install openssh-server
Copy the start.sh and sysinit to the home environment
Code:
cp /data/entware-ng/start.sh /data/entware-ng/home/root/start.sh
cp /data/entware-ng/start.sh /data/entware-ng/home/root/sysinit
chown root.root /data/entware-ng/home/root/start.sh
chmod 755 /data/entware-ng/home/root/start.sh
chown root.root /data/entware-ng/home/root/sysinit
chmod 755 /data/entware-ng/home/root/sysinit
mount -o ro,remount /
mount -o ro,remount /system
Start the new environment
Code:
sh /data/entware-ng/home/root/sysinit
SICKBEARD CONIG
Install a few pre-reqs for sickbeard
Code:
pip install transmissionrpc
pip install cherrypy
Create a file in init.d to allow sickbeard to start on reboot. Please note, you will need to change the path to where your sickbeard directory is.
I'm not going to cover setting up sickbeard, there are other guides for that. I did find that it couldn't be bound to 0.0.0.0 , or local host, it needed to be hard coded for the shields IP, so I recommend setting it up as a static IP in your router.
Code:
echo PATH=/opt/bin:/opt/sbin:$PATH > /opt/etc/init.d/S96sickbeard
echo /opt/bin/python <YOUR PATH TO>/SickBeard.py -d --port 8081 >> /opt/etc/init.d/S96sickbeard
chmod 755 /opt/etc/init.d/S96sickbeard
chmod +x /opt/etc/init.d/S96sickbeard
OPENSSH CONFIG
OPTIONAL - If you want to use SSH we need to generate keys
Code:
ssh-keygen -f /opt/etc/ssh/ssh_host_rsa_key -N '' -t rsa
ssh-keygen -f /opt/etc/ssh/ssh_host_dsa_key -N '' -t dsa
ssh-keygen -f /opt/etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa -b 521
Now you'll have to get on the shield and use a terminal emulator to edit your sshd_config file. Here's a copy of mine, but I do not promise how secure it is.
Code:
# $OpenBSD: sshd_config,v 1.99 2016/07/11 03:19:44 tedu Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# The default requires explicit activation of protocol 1
Protocol 2
# HostKey for protocol version 1
#HostKey /opt/etc/ssh/ssh_host_key
#HostKeys for protocol version 2
HostKey /opt/etc/ssh/ssh_host_rsa_key
HostKey /opt/etc/ssh/ssh_host_dsa_key
HostKey /opt/etc/ssh/ssh_host_ecdsa_key
#HostKey /opt/etc/ssh/ssh_host_ed25519_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
StrictModes no
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /opt/etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitEmptyPasswords yes
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /opt/var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# enable DSCP QoS values (per RFC-4594)
#IPQoS AF21 AF11
# override default of no subsystems
Subsystem sftp /opt/lib/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
To edit this, on the shield (Rom Toolbox Lite has a terminal emulator) run
Code:
su
cd /opt
sh ./start.sh
cd /opt/etc/ssh
vi ./sshd_config
TRANSMISSION
You'll have to configure your transmission settings, but they're located
/opt/etc/transmission/settings.json
Persist after reboot / Start Transmission/SSH/Sickbeard on boot
On the shield, open Rom Toolbox lite, and go down to "Scripter"
Import the sysinit script located /opt/home/root/sysinit and set the script to run at boot as root
Reboot and you should be able to connect via SSH, and have
Why do we need the passwd and group file ? Won't we use android's UID/GID ?
Can this method somehow be used to create custom group where we could put android's UID ?
I don't know why that step is needed, I got it from the guide I listed, and it worked without any apparent issues, so I left it in. My guess is openssh wants it to be there, but I'm not sure
So after you run all that is there a Interface for Sickbeard etc?
ahoslc said:
So after you run all that is there a Interface for Sickbeard etc?
Click to expand...
Click to collapse
It would be running on <shield IP>:8081 which you could access from the shield, or any other device on your network. Transmission would be :9091
Thanks for this. I'm trying to get python3-pip, acd_cli, and encfs installed on my Shield TV so I can mount my Amazon Cloud Drive and decrypt files for use with Plex. I have this set up on my NAS but it is too weak to do transcoding. I did set up the NAS as a middleman and mounted shares from it on the Shield TV, and while it does work, the extra step is really slow.
edit: I managed to get acd_cli working but I cannot mount my Amazon Cloud Drive share, I get I/O errors when I try to cd into it. Wonder if there's a kernel issue.
psycho_asylum said:
Thanks for this. I'm trying to get python3-pip, acd_cli, and encfs installed on my Shield TV so I can mount my Amazon Cloud Drive and decrypt files for use with Plex. I have this set up on my NAS but it is too weak to do transcoding. I did set up the NAS as a middleman and mounted shares from it on the Shield TV, and while it does work, the extra step is really slow.
edit: I managed to get acd_cli working but I cannot mount my Amazon Cloud Drive share, I get I/O errors when I try to cd into it. Wonder if there's a kernel issue.
Click to expand...
Click to collapse
So I was able to get this working https://github.com/dsoprea/GDriveFS and could cd into my google drive (But couldn't get Plex to see any files in the directory)
Soooo, even if you do get it working, its possible Plex won't be able to see it
Edit-- Did you install fuse-utils ?
chasx003 said:
Edit-- Did you install fuse-utils ?
Click to expand...
Click to collapse
Not specifically. I would think it would have been listed as a dependency and automatically installed, libfuse was though. I ended up factory restoring my Shield after I botched something, so now I'm just at 5.1 stock using the built-in Samba for now.
which version of busybox works? I am having trouble with wget and I tried v1.21.0
chasx003 said:
I've seen lots of people saying its not possible to make the shield an all in one solution for downloading, but after hours of tinkerering I've got a semi easy way of running the above services (and tons more) from the shield. This does requrie a bit of command line-fu , but I think I've got most of the hard work done. When its all said and done, we'll have a working entware-ng installation ( https://github.com/Entware-ng/Entware-ng)
[..]
FIRST
Now let's create a script that will initialize Entware-ng after reboot
Code:
echo \#\!/system/bin/sh > /data/entware-ng/entware-init.sh
echo mount -o rw,remount rootfs / >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng /opt >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/rootlinb /lib >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/rootbin /bin >> /data/entware-ng/entware-init.sh
echo ln -s /data/entware-ng/tmp /tmp >> /data/entware-ng/entware-init.sh
echo ln -s /system/bin/sh /bin/sh >> /data/entware-ng/entware-init.sh
echo mount -o ro,remount rootfs >> /data/entware-ng/entware-init.sh
chmod 755 /data/entware-ng/entware-init.sh
[..]
SECOND
Now lets create a start script that calls the initialize script we just made, but also returns a shell in the new environment
Code:
echo \#\!/system/bin/sh > /data/entware-ng/start.sh
echo ls '/opt >/dev/null 2>&1 ||' su -c /data/entware-ng/entware-init.sh >> /data/entware-ng/start.sh
echo export PATH=/opt/sbin:/opt/bin:/opt/rootbin:/opt/local/bin:/system/bin >> /data/entware-ng/start.sh
echo if busybox test $(busybox id -u) = 0; then HOME=/opt/home/root; else HOME=/opt/home/user; fi >> /data/entware-ng/start.sh
echo export HOME >> /data/entware-ng/start.sh
echo 'for file in /data/opt/etc/init.d/*' >> /data/entware-ng/start.sh
echo do >> /data/entware-ng/start.sh
echo ' $file start' >> /data/entware-ng/start.sh
echo done >> /data/entware-ng/start.sh
echo /bin/sh >> /data/entware-ng/start.sh
chmod 755 /data/entware-ng/start.sh
[..]
THIRD
Copy the start.sh and sysinit to the home environment
Code:
chown root.root /data/entware-ng/home/root/start.sh
chmod 755 /data/entware-ng/home/root/start.sh
chown root.root /data/entware-ng/home/root/sysinit
chmod 755 /data/entware-ng/home/root/sysinit
mount -o ro,remount /
mount -o ro,remount /system
[..]
FOURTH
Start the new environment
Code:
sh /data/opt/home/root/sysinit
Reboot and you should be able to connect via SSH, and have
Click to expand...
Click to collapse
In my quote there has to be something missing between the "first" and "second" steps and the "third" one.. are the two files we've just made the missing files in the home/root directory? Or where they supposed to come from somewhere else?
Also the "fourth" step, there are no /data/opt directory in my installation.
MartiniGM said:
In my quote there has to be something missing between the "first" and "second" steps and the "third" one.. are the two files we've just made the missing files in the home/root directory? Or where they supposed to come from somewhere else?
Also the "fourth" step, there are no /data/opt directory in my installation.
Click to expand...
Click to collapse
Ah! Sorry for not replying until now, life has been busy.
You are correct, there are some typos / things out of order! I'm going to go through this and fix it and will update the OP
I've taken this guide and installed rTorrent (due to superior web client and RSS capability). If anyone needs help on that, I can chime in.
Great tuto !
Working fine one Nvidia Shield TV 2017 with latest update (whithout reboot)
But after reboot I lost /opt and /bin on root :-O
mkdir /opt working fine after mount -o rw,remount /
but if i reboot it disappear
any idea ?
android.stackexchange.com said:
(root) directory is not a persistent filesystem on Android. It's a initramfs, which is packed into the boot image on your device. Although you can remount it with write permissions, changes will always be lost the next time you boot because the original ramdisk will be re-extracted from the boot image on the next boot.
Click to expand...
Click to collapse
So we need to :
$ mkboot boot.img /output-folder
$ cd /output-folder
$ gunzip -c ramdisk | cpio -i
... make some changes in the ramdisk and possibly /output-folder/img_info ...
$ find . | cpio -o -H newc | gzip > newramdisk.cpio.gz
$ cd ..
$ mkboot /output-folder newboot.img
If you're rooted, a better solution is to simply install in a chroot, either using debootstrap or other; you can obtain a nearly complete Linux system this way (init in a chroot is weird, stuff like openssh will still have to be started separately after boot, either manually or by an app/script).
If you're not rooted, you can use proot for simple path redirection; this is how termux installs arch on unrooted devices.
Using either option (chroot, proot) requires having binary files that aren't in a noexec partition; generally this means private app storage, not sdcard that's accessible to other apps. If you're building a chroot, you should be able to include the external/public storage folder in it, however a chroot also requires the partition not be mounted with nodev option.
***Note that I don't actually have a shield TV*** (I'm just interested in getting one) so I can't say if the shield's storage is mounted noexec, but the android data partition generally is. I can, however, verify that the process in general works on Android, however, as I've got two tablets running Lineage/Nougat with chroots, and a stock Moto G6 with archlinux arm in proot. To check for partitions mounted as nodev or noexec, run `mount|TERM=xterm grep --color -E 'nodev|noexec'`. You might check to see if you can use /data/local instead of app's private storage.
For installing BusyBox, *should* be a `busybox --install -s [DIR]` option that copies the binary to the destination, then symlinks applets. This should be simpler than symlinking a bunch of applets manually.
If you want a system-wide BusyBox I recommend stericson busybox: https://play.google.com/store/apps/details?id=stericson.busybox
For a terminal emulator on Android, I highly recommend termux, which is available on Google play and F-Droid. It has support for 256 color, styles, a package manager, Android integration (ie notifications from Linux scripts), boot scripts, widgets, etc: https://play.google.com/store/apps/details?id=com.termux
Another alternative: you can set up user-mode Linux for something closer to virtualization, but I have yet to see any UML binaries for use with Android; this would also make it difficult to run networking and to access files from outside the guest, but will provide a full working system with init support, and would not require root to set up and run--however, I think UML networking requires root and/or kernel support, though, and UML generally requires a disk image much like other virtualization tools. Qemu might be workable instead of UML with fewer issues.
Note that all of these solutions are still running under an Android app, and as such are subject to the android task killer. Not sure if there's any way around this without having something run directly by Android's own init system.
Efreak2004 said:
If you're rooted, a better solution is to simply install in a chroot, either using debootstrap or other; you can obtain a nearly complete Linux system this way (init in a chroot is weird, stuff like openssh will still have to be started separately after boot, either manually or by an app/script).
If you're not rooted, you can use proot for simple path redirection; this is how termux installs arch on unrooted devices.
Using either option (chroot, proot) requires having binary files that aren't in a noexec partition; generally this means private app storage, not sdcard that's accessible to other apps. If you're building a chroot, you should be able to include the external/public storage folder in it, however a chroot also requires the partition not be mounted with nodev option.
***Note that I don't actually have a shield TV*** (I'm just interested in getting one) so I can't say if the shield's storage is mounted noexec, but the android data partition generally is. I can, however, verify that the process in general works on Android, however, as I've got two tablets running Lineage/Nougat with chroots, and a stock Moto G6 with archlinux arm in proot. To check for partitions mounted as nodev or noexec, run `mount|TERM=xterm grep --color -E 'nodev|noexec'`. You might check to see if you can use /data/local instead of app's private storage.
For installing BusyBox, *should* be a `busybox --install -s [DIR]` option that copies the binary to the destination, then symlinks applets. This should be simpler than symlinking a bunch of applets manually.
If you want a system-wide BusyBox I recommend stericson busybox: https://play.google.com/store/apps/details?id=stericson.busybox
For a terminal emulator on Android, I highly recommend termux, which is available on Google play and F-Droid. It has support for 256 color, styles, a package manager, Android integration (ie notifications from Linux scripts), boot scripts, widgets, etc: https://play.google.com/store/apps/details?id=com.termux
Another alternative: you can set up user-mode Linux for something closer to virtualization, but I have yet to see any UML binaries for use with Android; this would also make it difficult to run networking and to access files from outside the guest, but will provide a full working system with init support, and would not require root to set up and run--however, I think UML networking requires root and/or kernel support, though, and UML generally requires a disk image much like other virtualization tools. Qemu might be workable instead of UML with fewer issues.
Note that all of these solutions are still running under an Android app, and as such are subject to the android task killer. Not sure if there's any way around this without having something run directly by Android's own init system.
Click to expand...
Click to collapse
Using chroot isn`t good solution. Emulators not effective too.
Stericon`s busybox is paid, meefik`s busybox is free and has more utils.
Termux is heavy, I use Teeminal Emulator: https://f-droid.org/app/jackpal.androidterm
You be able to install a lot of lightweight linux utils by installing entware-ng. For example, git pkg has 300 Mb size in termux and 15 Mb in entware.
Entware has a lot of conmon with optware and openwrt
this is a wonderful guide I'm surprised more people don't use it great job!

Startup Scripts

Stock ROM, oreo.
How do you execute scripts on startup? Either by init.d or some other means, doesn't matter as long as it works. The /system/etc/init.d folder isn't there. Remounting /system for me doesn't work:
mount -o remount,rw -t ext4 /dev/block/platform/hi_mci.0/by-name/system /system
I get: '/system': Device or resource busy
I reboot into TWRP, I get the same error as above. Any help please?
TouchOdeath said:
Stock ROM, oreo.
How do you execute scripts on startup? Either by init.d or some other means, doesn't matter as long as it works. The /system/etc/init.d folder isn't there. Remounting /system for me doesn't work:
mount -o remount,rw -t ext4 /dev/block/platform/hi_mci.0/by-name/system /system
I get: '/system': Device or resource busy
I reboot into TWRP, I get the same error as above. Any help please?
Click to expand...
Click to collapse
For mounting you use these command.
In local terminal
HWBND-H:/ $ su
HWBND-H:/ # mount -o rw,remount /system
In adb terminal
adb shell su -c mount -o rw,remount /system
And to see how is mounted
HWBND-H:/ # mount | grep system
It should return like this.
/dev/block/mmcblk0p51 on /system type ext4 (rw,seclabel,relatime,data=ordered)
And to go back to ro do this or reboot:
HWBND-H:/ # mount -o ro,remount /system
HWBND-H:/ # mount | grep system
/dev/block/mmcblk0p51 on /system type ext4 (ro,seclabel,relatime,data=ordered)
mrmazak said:
For mounting you use these command.
In local terminal
HWBND-H:/ $ su
HWBND-H:/ # mount -o rw,remount /system
In adb terminal
adb shell su -c mount -o rw,remount /system
And to see how is mounted
HWBND-H:/ # mount | grep system
It should return like this.
/dev/block/mmcblk0p51 on /system type ext4 (rw,seclabel,relatime,data=ordered)
And to go back to ro do this or reboot:
HWBND-H:/ # mount -o ro,remount /system
HWBND-H:/ # mount | grep system
/dev/block/mmcblk0p51 on /system type ext4 (ro,seclabel,relatime,data=ordered)
Click to expand...
Click to collapse
Thank you for your response I appreciate it. I ended up making my problem more complicated than it had to be. The solution was to open terminal and do:
adb shell
su
mkdir /system/etc/init.d
cp /storage/emulated/0/Downloads/script.sh /system/etc/init.d/script.sh
If I tried to create the folder through a rooted app (Total Commander), it didn't work. Copying the file through an app didn't work either.

Categories

Resources