How to change environment variable without patch kernel ??? - Galaxy Note 3 Q&A, Help & Troubleshooting

I want to install busybox to other path, so i need to change $PATH
but $PATH define in init.environ.rc, but this file is in ramdisk and will be rewrote on every boot
Is there any way to change it without patch kernel? because i hate screen display that "kernel is not xxxxx, set warranty bit kernel"
I tried install-recovery.sh and install-recovery-2.sh. but it not work, it may not run at every boot so install-recovery-2.sh will not be loaded
if run install-recovery-2.sh manually, create dir, install busybox and soft link is worked but still can not change $PATH...
in init.rc file, what dos "seclabel u:r:flash_recovery:s0" mean?
Code:
service flash_recovery /system/etc/install-recovery.sh
class main
seclabel u:r:flash_recovery:s0
oneshot
install-recovery.sh
Code:
#!/system/bin/sh
# If you're implementing this in a custom kernel/firmware,
# I suggest you use a different script name, and add a service
# to launch it from init.rc
# Launches SuperSU in daemon mode only on Android 4.3+.
# Nothing will happen on 4.2.x or older, unless SELinux+Enforcing.
# If you want to force loading the daemon, use "--daemon" instead
/system/xbin/daemonsu --auto-daemon &
# Some apps like to run stuff from this script as well, that will
# obviously break root - in your code, just search this file
# for "install-recovery-2.sh", and if present, write there instead.
/system/etc/install-recovery-2.sh
install-recovery-2.sh
Code:
#!/system/bin/sh
#Script for init Busybox on every boot by BZH
busybox_path=/system/etc
busybox_bin=busybox-armv7l-1221
busybox_install_path=/root/bin
$busybox_path/$busybox_bin mount -o rw,remount /
$busybox_path/$busybox_bin mkdir -p /root/bin
$busybox_path/$busybox_bin cp $busybox_path/$busybox_bin $busybox_install_path/
$busybox_path/$busybox_bin chmod -R 755 /root
$busybox_install_path/$busybox_bin --install -s $busybox_install_path/
$busybox_install_path/$busybox_bin ln -s $busybox_install_path/$busybox_bin /system/bin/busybox
$busybox_install_path/$busybox_bin ln -s $busybox_install_path/$busybox_bin /system/xbin/busybox
sync
$busybox_path/$busybox_bin mount -o ro,remount /
export PATH="/root/bin:$PATH"

up...

Related

[Q] Got root via adb, how do I make it permanent?

Code below works as far as getting root via adb
But after reboot I get following error:
Code:
? su
link_image[1717]: 2977 missing essential tablesCANNOT LINK EXECUTABLE
Do you know what's missing here?
Code:
./adblinux push psneuter /data/local/tmp
./adblinux push su-v3 /data/local/tmp
./adblinux push busybox /data/local/tmp
./adblinux shell chmod +x /data/local/tmp/psneuter
./adblinux shell chmod +x /data/local/tmp/su-v3
./adblinux shell
$ /data/local/tmp/psneuter
# exit
./adblinux shell
# cat /proc/mounts
# mount -o rw,remount -t yaffs2 /dev/stl5 /system
# busybox cp -vaf /data/local/tmp/su-v3 /system/xbin/su
# ls -l /system/xbin/su
# busybox chown 0.2000 /system/xbin/su
# busybox chmod 06755 /system/xbin/su
# ls -l /system/xbin/su
# rm /system/bin/su
# busybox ln -s /system/xbin/su /system/bin/su
# ls -l /system/bin/su
# busybox cp -f /data/local/tmp/busybox /system/xbin
# busybox chown 0.2000 /system/xbin/busybox
# busybox chmod 0755 /system/xbin/busybox
# ls -l /system/xbin/busybox
# exit
./adblinux install -r Superuser.apk
./adblinux reboot
Hi,
I am new here, but advanced linux user
I have already done this succesfully on my X10i - thanks 1st working howto on linux OS
Theres propably mistake with these steps:
./adblinux shell chmod +x /data/local/tmp/psneuter
./adblinux shell chmod +x /data/local/tmp/su-v3
In my case these commands left errors. They have to simply mark these binaries as executable. But chmod +x * doesnt work (dont ask why ) - so I marked them as executables (su,psneuter,busybox) in desktop linux os before transfer and it worked.
The next mistake is in the line:
busybox cp -vaf /data/local/tmp/su-v3 /system/xbin/su
Because busybox is not yet in the system path - so you have to type:
# /data/local/tmp/busybox cp -vaf /data/local/tmp/su-v3 /system/xbin/su
Until
# /data/local/busybox cp -f /data/local/tmp/busybox /system/xbin
You can use busybox directly.
chmod +x doesn't work on android, you have to use chmod 777 or 666 or the like to get it to work properly.
Semperverus said:
chmod +x doesn't work on android, you have to use chmod 777 or 666 or the like to get it to work properly.
Click to expand...
Click to collapse
Or do it on linux GUI and mark as executable before transfer to Android device

[Q] Mount system in adb to read and write on Nexus 7?

Hi guys,
For the Nexus 7, is there a command I can execute in adb shell root to mount the /system/ to enable reading and writing?
For example for the Galaxy Nexus it was...
mount -o rw,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.0/by- name/system /system
What is it for the Nexus 7?
Thanks!
mdrdroid said:
Hi guys,
For the Nexus 7, is there a command I can execute in adb shell root to mount the /system/ to enable reading and writing?
For example for the Galaxy Nexus it was...
mount -o rw,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.0/by- name/system /system
What is it for the Nexus 7?
Thanks!
Click to expand...
Click to collapse
Shot in the dark:
Code:
adb shell
su
mount -o remount rw /system
then, for example, you should be able to do:
Code:
cp /system/build.prop [destination]
cp [source] /system/
cwoggon said:
Shot in the dark:
Code:
adb shell
su
mount -o remount rw /system
then, for example, you should be able to do:
Code:
cp /system/build.prop [destination]
cp [source] /system/
Click to expand...
Click to collapse
Thank you for replying!
I did try your shot in the dark, however when I tried to do a mkdir test for example I still got:
[email protected]:/ # mkdir test
mkdir failed for test, Read-only file system
I believe the format is like:
Usage: mount [-r] [-w] [-o options] [-t type] device directory
But I don't know the specifics. Any thoughts is appreciated!
What I posted above works on my GNex, was /system your active directory when you tried to mkdir?
I would try on my N7, but its ready to be RMA'd...
Code:
[email protected]:/system # mount -o remount rw /system
mount -o remount rw /system
[email protected]:/system # mkdir test
mkdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
test
usr
vendor
xbin
[email protected]:/system # rmdir test
rmdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
usr
vendor
xbin
[email protected]:/system #
cwoggon said:
What I posted above works on my GNex, was /system your active directory when you tried to mkdir?
I would try on my N7, but its ready to be RMA'd...
Code:
[email protected]:/system # mount -o remount rw /system
mount -o remount rw /system
[email protected]:/system # mkdir test
mkdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
test
usr
vendor
xbin
[email protected]:/system # rmdir test
rmdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
usr
vendor
xbin
[email protected]:/system #
Click to expand...
Click to collapse
Your advice worked, I over complicated it. I just did this again on my N7 and worked perfectly. Thank you very much!!!

SecurityScript & unbloatscript & batch install userapp scripts

I "made" a security script for cm/aosp and wanted to share. Ok, so I copied a lot from what I could find off the net, and thought I would share Seems as if this closes some of the security holes in android in general, but also cm/aokp.
If any of these are rediculous please help contribute to making it better. I just added what I thought could be true.
Warning: doesnt work on touchwiz roms, only cm/aosp
Warning: at own risk, I take no responsibility
Warning: this could render other scripts useless.
Warning: I am no codemonkey, I find after boot I need to manually apply ro access with rootexplorer for some of the directories used here. Havent been able to solve that with tasker/init.d scripts.
How to use:
run in terminal with su privileges.
Or set as script/task/init.d to run on boot. For some stuff to stick you need to do this. I recommend tasker, thats what I ran this with on boot.
Sources are to various to mention. One of them is secdroid. A lot of what that app has I could verify from a lot of sources. But is missing a lot of other stuff.
Tested Improvements are welcome! Donations/beer also
Spoiler
#!/system/bin/sh
mount -o remount, -rw /sbin
mount -o remount, -rw /system
mount -o remount, -rw /system/xbin
####enable the adbd daemon and busybox
mount -o remount, -rw -t rootfs rootfs /
chmod 777 /sbin/adbd
chmod 777 /system/xbin/busybox
###Disable NFC
chmod 000 /dev/ttyO3
chmod 000 /dev/tty3
###hardening TCP/IP stack for IPV4
###Avoid a smurf attack
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1;
###ICMP broadcast
busybox sysctl -e -w net.ipv4.conf.all.accept_redirects=0;
###ICMP redirects ipv4
busybox sysctl -e -w net.ipv6.conf.all.accept_redirects=0;
###ICMP redirects ipv6
busybox sysctl -e -w net.ipv4.conf.all.send_redirects=0;
### ICMP redirects
busybox sysctl -e -w net.ipv4.conf.all.accept_source_route=0; ###source routing disable
busybox sysctl -e -w net.ipv4.conf.all.forwarding=0;
###Forwarding traffic
busybox sysctl -e -w net.ipv4.conf.all.rp_filter=1;
busybox sysctl -e -w net.ipv4.conf.all.log_martians=1;
###filter martians
busybox sysctl -e -w net.ipv4.tcp_max_syn_backlog=1280;
###TCP syn half-opened
sysctl -w net.ipv4.ip_forward=0;
###Block Redirects
busybox sysctl -e -w net.ipv4.conf.default.accept_redirects=0;
busybox sysctl -e -w net.ipv4.conf.all.secure_redirects=0;
busybox sysctl -e -w net.ipv4.conf.default.secure_redirects=0;
###Block Source-Routing
busybox sysctl -e -w net.ipv4.conf.default.accept_source_route=0;
busybox sysctl -e -w net.ipv4.conf.all.accept_source_route=0;
### IPv4 Tweaks
busybox sysctl -e -w net.ipv4.tcp_timestamps=0;
busybox sysctl -e -w net.ipv4.tcp_sack=1;
busybox sysctl -e -w net.ipv4.tcp_fack=1;
busybox sysctl -e -w net.ipv4.tcp_congestion_control=cubic;
busybox sysctl -e -w net.ipv4.tcp_window_scaling=1;
###Protection against SYN Attacks
busybox sysctl -e -w net.ipv4.tcp_syncookies=1;
busybox sysctl -e -w net.ipv4.conf.all.rp_filter=1;
busybox sysctl -e -w net.ipv4.conf.default.rp_filter=1;
busybox sysctl -e -w net.ipv4.tcp_synack_retries=2;
busybox sysctl -e -w net.ipv4.tcp_syn_retries=2;
busybox sysctl -e -w net.ipv4.tcp_max_syn_backlog=1024;
busybox sysctl -e -w net.ipv4.tcp_max_tw_buckets=16384;
busybox sysctl -e -w net.ipv4.icmp_echo_ignore_all=1;
###Turn on protection for bad icmp error messages
busybox sysctl -e -w net.ipv4.icmp_ignore_bogus_error_responses=1;
busybox sysctl -e -w net.ipv4.tcp_no_metrics_save=1;
busybox sysctl -e -w net.ipv4.tcp_fin_timeout=15;
busybox sysctl -e -w net.ipv4.tcp_keepalive_intvl=30;
busybox sysctl -e -w net.ipv4.tcp_keepalive_probes=5;
busybox sysctl -e -w net.ipv4.tcp_keepalive_time=1800;
###Tune IPv6 and disable lol
busybox sysctl -e -w net.ipv6.conf.default.router_solicitations=0;
busybox sysctl -e -w net.ipv6.conf.default.accept_ra_rtr_pref=0;
busybox sysctl -e -w net.ipv6.conf.default.accept_ra_pinfo=0;
busybox sysctl -e -w net.ipv6.conf.default.accept_ra_defrtr=0;
busybox sysctl -e -w net.ipv6.conf.default.autoconf=0;
busybox sysctl -e -w net.ipv6.conf.default.dad_transmits=0;
busybox sysctl -e -w net.ipv6.conf.default.max_addresses=1;
busybox sysctl -e -w net.ipv6.conf.all.disable_ipv6=1;
busybox sysctl -e -w net.ipv6.conf.default.disable_ipv6=1;
busybox sysctl -e -w net.ipv6.conf.lo.disable_ipv6=1;
### Don't act as a router
busybox sysctl -e -w net.ipv4.ip_forward=0;
busybox sysctl -e -w net.ipv4.conf.all.send_redirects=0;
busybox sysctl -e -w net.ipv4.conf.default.send_redirects=0;
### Removing/ disabling unnecessary binaries. Some of them have access to Internet
mount -o remount, -rw /system/xbin
rm -f /system/xbin/irsii
rm -f /system/xbin/nano
rm -f /system/xbin/nc
rm -f /system/xbin/telnet
rm -f /system/xbin/telnetd
rm -f /system/xbin/telnetd
rm -f /system/xbin/opcontrol
chmod 000 /system/xbin/irsii
chmod 000 /system/xbin/nc
chmod 000 /system/xbin/netserver
chmod 000 /system/xbin/netperf
chmod 000 /system/xbin/opcontrol
chmod 000 /system/xbin/scp
chmod 740 /system/xbin/rsync
chmod 740 /system/xbin/sdptest
chmod 000 /system/xbin/ssh
chmod 000 /system/xbin/sshd
chmod 000 /system/xbin/ssh-keygen
chmod 740 /system/xbin/strace
chmod 000 /system/xbin/tcpdump
chmod 740 /system/xbin/vim
chmod 000 /system/xbin/nano
chmod 000 /system/xbin/telnet
mount -o remount, -ro /system/xbin
###Let's make sure they aren't in bin either
rm -f /system/bin/irsii
rm -f /system/bin/nano
rm -f /system/bin/nc
rm -f /system/bin/telnet
rm -f /system/bin/telnetd
rm -f /system/bin/opcontrol
chmod 000 /system/bin/irsii
chmod 000 /system/bin/nc
chmod 000 /system/bin/netserver
chmod 000 /system/bin/netperf
chmod 000 /system/bin/opcontrol
chmod 000 /system/bin/scp
chmod 740 /system/bin/rsync
chmod 740 /system/bin/sdptest
chmod 000 /system/bin/ssh
chmod 000 /system/bin/sshd
chmod 000 /system/bin/ssh-keygen
chmod 740 /system/bin/strace
chmod 000 /system/bin/tcpdump
chmod 740 /system/bin/vim
chmod 000 /system/bin/nano
chmod 000 /system/bin/telnet
### This disables Bluetooth (Most users want it on)
###chmod 000 /system/bin/bluetoothd
### ONLY root should need these:
chmod 750 /system/bin/iptables
chmod 750 /system/bin/ping
### Let's remove suid from ping (prevent a Privilege escalation attack)
mount -o remount, -rw /system/xbin
chmod 777 /system/xbin/busybox
mount -o remount, -rw /system/bin
busybox chmod -s /system/bin/ping
mount -o remount, -ro /system/bin
chmod 000 /system/xbin/busybox
mount -o remount, -ro /system/xbin
###disable the Packet Management binary - Prevents installing apps
via ADB or remotely
###disable ssh
###remove uiautomator permissions havent found a use for it anyways
mount -o remount, -rw /system/bin
chmod 000 /system/bin/pm
chmod 000 /system/bin/ssh
chmod 000 /system/bin/sshd
chmod 000 /system/bin/sshd
chmod 000 /system/bin/start-ssh
chmod 000 /system/bin/uiautomator
mount -o remount, -ro /system/bin
mount -o remount, -rw /sbin
###Disable the adbd daemon again
mount -o remount, -rw -t rootfs rootfs /
chmod 000 /sbin/adbd
###Prevents adb from running. This protects against attacks like P2P-ADB by Kos
###disable config ssh. No server for me...
###remove files with dictionary for terminals lol wtf
mount -o remount, -rw /etc
rm -rf /etc/terminfo/*
mv /etc/ssh/ssh_config /etc/ssh/ssh_config.donthinkso
mount -o remount, -ro /etc
###close
mount -o remount, -ro -t rootfs rootfs /
mount -o remount, -ro /sbin
mount -o remount, -ro /system/xbin
mount -o remount, -ro /system
mount -o remount, -ro /
###Cause I cant code lol no errors reported. Test without exit 0 to see in terminal if it works for your rom. its here so tasker wont error out if it cant find something.
exit 0
edit, put a /* after terminfo to delete all there
edit, small fix in code, not yet able to properly mount system and root as ro
Unbloatscript
Just removing some of the stuff I dont use. You can add/remove what you like
edit: some apps might forceclose if they are running, thats no issue.
After running wipe cache and dalvik and reboot. To further clean.
warning I added reboot at end so device will reboot!
Spoiler
#!/system/bin/sh
mount -o remount, -rw /sbin
mount -o remount, -rw /system
mount -o remount, -rw /system/xbin
# enable the adbd daemon and busybox
chmod 777 /sbin/adbd
chmod 777 /system/xbin/busybox
rm -f /system/app/QuickSearchBox.apk
rm -f /system/app/VoiceSearchStub.apk
rm -f /system/app/Talkback.apk
rm -f /system/app/Talk.apk
rm -f /system/app/Email2.apk
rm -f /system/app/Exchange2.apk
rm -f /system/app/HoloSpiralWallpaper.apk
rm -f /system/app/MagicSmokeWallpapers.apk
rm -f /system/app/VoiceDialer.apk
rm -f /system/app/VpnDialogs.apk
rm -f /system/app/Apollo.apk
rm -f /system/app/BasicDreams.apk
rm -f /system/app/CMFileManager.apk
rm -f /system/app/CMWallpapers.apk
rm -f /system/app/Development.apk
rm -f /system/app/DSPManager.apk
rm -f /system/app/LiveWallpapers.apk
rm -f /system/app/LiveWallpaperPicker.apk
rm -f /system/app/LockClock.apk
rm -f /system/app/MagicSmokeWallpapers.apk
rm -f /system/app/MediaUploader.apk
rm -f /system/app/NoiseField.apk
rm -f /system/app/Phasebeam.apk
rm -f /system/app/SoundRecorder.apk
rm -f /system/app/Term.apk
rm -f /system/app/Trebuchet.apk
rm -f /system/app/WAPPushManager.apk
###remove dalvik and cache
rm -f /data/dalvik-cache/*
rm -f /cache/dalvik-cache/*
rm -f /cache/lost+found/*
chmod 000 /sbin/adbd
chmod 000 /system/xbin/busybox
mount -o remount, -ro /sbin
mount -o remount, -ro /system/xbin
mount -o remount, -ro /system
exit 0
reboot
Edit, added remove dalvik cache, cache and Reboot after running this to prevent fc. You will get some of apps running but that should be no issue
edit, closing, foolish me didnt mount as ro. and removed a bit of other code
edit some more cleaning
Batch install script
As I run a lot of scripts to automate my post flash activities. I set my phone on airplane mode and run the following script batch install from a certain folder.
Its nowhere near as sophisticated as Chasmodos roms scripts, but it does the job for my user apps
Here I have a folder (batchlove) where I store my backed upped apps (no data) from playstore on my external sdcard. So far play recognizes the apps and lets me update it. However then you would need tro update the apks in this folder in order to always have up to date versions.You can put apks backed up with a lot off aps here.
Ofcourse I dont keep my tasker app here because it installs everything in that folder, and installing tasker while running this script is not a good idea.
You can run this script from a terminal as wel.
Spoiler
#!/system/bin/sh
mount -o remount, -rw /sbin
mount -o remount, -rw /system
mount -o remount, -rw /system/xbin
mount -o remount, -rw /system/bin
# enable the adbd daemon and busybox
mount -o remount, -rw -t rootfs rootfs /
chmod 777 /sbin/adbd
chmod 777 /system/xbin/busybox
chmod 777 /system/bin/pm
cd /storage/sdcard1/batchlove;
for app in *.apk; do pm install -r $app; done
chmod 000 /sbin/adbd
chmod 000 /system/xbin/busybox
chmod 000 /system/bin/pm
mount -o remount, -rw /sbin
mount -o remount, -rw /system
mount -o remount, -rw /system/xbin
mount -o remount, -rw /system/bin
exit 0
You copied SecDroid and added some stuff, now you call it your own project. Why not continue SecDroid?
SecUpwN said:
You copied SecDroid and added some stuff, now you call it your own project. Why not continue SecDroid?
Click to expand...
Click to collapse
I copied a bunch of other stuff also, as even secdroid is not the source of most of those lines. It is an awesome initiative though. An app for the masses. For those insterested http://forum.xda-developers.com/showthread.php?t=2086276.
With the script, not really my project, I wanted to set the values immediately as I flash every other day. I got a script for that. As I would still need that for reopening the closed the stuff,every once in a while.
edit submitted most to secdroid git for the security script
added some extra scripts, handy for unbloat/batchinstall.
tip: get tasker, save these scripts as tasks, backup tasker data (from within tasker) and add task to move the backup to external card. Then you only need to install tasker copy the backup to sdcard, restore and run. Its another way
if enough people are interested I can export these scripts as apps from tasker, just install and it will do what the script does.
remember to check folder permissions as these dont always stick lol
hope you find it handy, if anyone has a script that is handy please share
delete

[Guide] Debian on Android (rooted)

Hi, this is a guide to install a Linux image on your rooted Android phone with the debootstrap + chroot method.
In this guide, we'll install a Debian image, but the steps are practically the same, with a few tweaks.
If you need help to install a Linux image, feel free to ask on this thread.
For this guide, all credit goes to them:
http://linux-expert.net/?Trucs_et_astuces___Android___Tutoriel_%3A_Chroot_Debian (in french)
http://forum.xda-developers.com/showthread.php?p=45457799
http://forum.xda-developers.com/showthread.php?t=2312013
http://forum.xda-developers.com/showthread.php?t=631389
http://forum.xda-developers.com/showthread.php?t=1418546
http://forum.xda-developers.com/showpost.php?p=5671794&postcount=124
VNC
________________
I. On your PC
So first, you have to create the .img file that will contain the OS.
In a GNU/Linux environment (PC) and with the root permissions, type these commands:
Code:
# mkdir debian
# dd if=/dev/zero of=wheezy-armhf.img bs=1M count=0 seek=2048
[COLOR="Red"](NOTE: "of=" will be the name of our .img file and "seek=" the size of the file (MB). Here, we create a file named "wheezy-armhf.img" of 2 GB)[/COLOR]
# mkfs.ext4 -F wheezy-armhf.img
# mount -o loop wheezy-armhf.img /debian
Then we have to fill up the filesystem.
Code:
# debootstrap --foreign --arch=armhf wheezy debian/
# umount debian
Finally, move it to your SD Card. In my case, I moved it on /data/local/
II. On your phone
On your phone, in a terminal emulator and with the root permissions, type the following commands:
Code:
# mount -o rw,remount rootfs /
# export LINUXROOT=/linux
(NOTE: here we'll install Debian on the root of the internal memory, in "/", but we can also install Debian on the SD Card or in /data/loca/linux by changing the path after "LINUXROOT=")
# mkdir $LINUXROOT
# busybox mknod /dev/block/loop100 b 7 100
# losetup /dev/block/loop100 /sdcard/wheezy-armhf.img
# mount -t ext4 /dev/block/loop100 $LINUXROOT
# chroot $LINUXROOT /bin/sh
# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# /debootstrap/debootstrap --second-stage
The debootstrap's second part should start. Grab a cup of coffee while it's working!
When it's finish, leave the chroot by typing
Code:
# exit
# su
Let's mount the filesystem. We're close!
Code:
# mount -t proc none /proc
# mount -t sysfs none /sys
# mount -o bind /dev /dev
# mount -t devpts none /dev/pts
Now, we have to set the environment variable. Ensure that you have set the correct path of LINUXROOT in case you've chosen another path than /linux.
Code:
# export LINUXROOT=/linux
# export TMPDIR=/tmp
# export USER=root
# export HOME=/root
# export SHELL=/bin/bash
# export TERM=linux
# export LC_ALL=C
# export LANGUAGE=C
# export LANG=C
And finally, chroot.
Code:
# chroot $LINUXROOT /bin/bash
su
Welcome on Debian!
III. DNS and Mirrors
Set a DNS. We'll set the free Google DNS but you can set yours if you want.
Code:
echo -e "domain local\nsearch local\n" >> /etc/resolv.conf
echo -e "# DNS Google\nnameserver 8.8.8.8\nnameserver 8.8.4.4\n" >> /etc/resolv.conf
You can add mirrors to your sources.list if you want. I'm french so I added french mirrors:
Code:
# echo -e "## Debian Wheezy sources.list\n\n" > /etc/apt/sources.list
# echo -e "## Debian.org FR mirror\ndeb http://ftp.fr.debian.org/debian/ wheezy main contrib non-free\ndeb-src http://ftp.fr.debian.org/debian/ wheezy main contrib non-free\n\n" >> /etc/apt/sources.list
# echo -e "## Debian security updates\ndeb http://security.debian.org/ wheezy/updates main contrib non-free\ndeb-src http://security.debian.org/ wheezy/updates main contrib non-free\n >> /etc/apt/sources.list
IV. VNC
To access your Debian in a graphical environment from your PC or your phone, you have to set up a VNC Server and install a Desktop Environment. Let's install VNC and LXDE.
We'll follow the steps described on the LXDE wiki:
Code:
su
# apt-get update
# apt-get install lxde
# apt-get install tightvncserver
Set up the VNC server by typing the following command, which will ask you to set two passwords (let the second password if you want):
Code:
# vncserver
Kill the session:
Code:
# vncserver -kill :1
Go to /root/.vnc/ and edit the xstartup file: comment out #/etc/X11/xsession and add these two lines:
icewm
lxsession
Click to expand...
Click to collapse
To start a VNC session, type "vncserver -geometry x". For the Nexus 4, we would type "vncserver -geometry 1184x768"
To access your Desktop Environment from your phone, download android-vnc-viewer and launch it.
In the password field, type your password. In the address field, type "127.0.0.1", in port type "5901" and select 24-bit color (4bpp).
V. Script
I've made three scripts to mount, launch and unmount Debian. Whenever you reboot your phone, you'll have to mount Debian, set the environment variables and chroot.
VI. Credit
All credit goes to them:
http://linux-expert.net/?Trucs_et_astuces___Android___Tutoriel_%3A_Chroot_Debian (in french)
http://forum.xda-developers.com/showthread.php?t=2312013
http://forum.xda-developers.com/showthread.php?t=631389
http://forum.xda-developers.com/showthread.php?t=1418546
http://forum.xda-developers.com/showpost.php?p=5671794&postcount=124
VNC
Sorry for my bad english, I hope this will help
EDIT: Feel free to correct me!
Hi, I have 2021 updates, if someone interested. Tested with rooted LineageOS 17 (selinux permissive - not sure if required, my ROM is permissive, didn't set it explicitly):
for 32-bit ARM, ext4 created by 64-bit Linux didn't work, obviously there is some 64-bit feature that was not supported at least with my kernel (3.14). I've in the end created the FS on the Android, but using "-O '^64bit'" could be sufficient in the Linux. UPDATE: I've in the end used F2FS instead of EXT4.
above mknod+losetup+mount didn't work for me (neither 'mount -o loop -t ext4 <img>'), I've used 'mount -t ext4 $(losetup -sf /sdcard/stable-armhf.img) $LINUXROOT' in the end (obviously the device name needs to be saved somewhere if one wants to cleanly umount)
there was issue with network access denied even if you are root, see here. I've fixed it by creating the group 'inet/3003' in the chroot and issuing 'newgrp inet' inside it (more details in the link).
Anyways, thanks a lot for the above instructions, it helped me much!

wrongly mounted s4 i9506 = now bricked?

I just rooted my SG S4 Android 5.0.1 with auto-root. Everything worked fine (root complete and SU installed) till I think I gave a bad mount command in the root directory on the phone in terminal (i guess here it went wrong, not sure. Or perhaps during installation of bash or nano) when I was installing bash and nano. Since it rebooted, I **lost the wifi and cannot adb shell into my phone** anymore from mac.
Afterwards, I managed to flash clockwork mod recovery v6.0.4.6. and was able to mount /system, which enabled the ./adb shell again. However i can now only pwd and cd, everything else gets this error: /sbin/sh: ls: Permission denied
I think my phone is still recoverable, however I don't know what to do and don't want to risk making things worse. Which andoird wizard can help me please?
**Below here were my bash nano install commands:**
./adb shell
su
mount -o remount,rw /system
cp -r /storage/extSdCard/bashnano/terminfo /system/etc
cp /storage/extSdCard/bashnano/profile /etc
cp /storage/extSdCard/bashnano/bash /data
cp /storage/extSdCard/bashnano/nano /data
chmod 755 /data/bash
chmod 755 /data/nano
cd /system/bin/
mv sh sh.old
ln -s /data/bash sh
ln -s /data/bash bash
ln -s /data/nano nano
export TERMINFO=/etc/terminfo
export TERM=linux
mount -o remount,ro /system
**P.S. So I also performed a regular mount in root, which i think is what made things bad, but not totally sure!**
ansjovis86 said:
I just rooted my SG S4 Android 5.0.1 with auto-root. Everything worked fine (root complete and SU installed) till I think I gave a bad mount command in the root directory on the phone in terminal (i guess here it went wrong, not sure. Or perhaps during installation of bash or nano) when I was installing bash and nano. Since it rebooted, I **lost the wifi and cannot adb shell into my phone** anymore from mac.
Afterwards, I managed to flash clockwork mod recovery v6.0.4.6. and was able to mount /system, which enabled the ./adb shell again. However i can now only pwd and cd, everything else gets this error: /sbin/sh: ls: Permission denied
I think my phone is still recoverable, however I don't know what to do and don't want to risk making things worse. Which andoird wizard can help me please?
**Below here were my bash nano install commands:**
./adb shell
su
mount -o remount,rw /system
cp -r /storage/extSdCard/bashnano/terminfo /system/etc
cp /storage/extSdCard/bashnano/profile /etc
cp /storage/extSdCard/bashnano/bash /data
cp /storage/extSdCard/bashnano/nano /data
chmod 755 /data/bash
chmod 755 /data/nano
cd /system/bin/
mv sh sh.old
ln -s /data/bash sh
ln -s /data/bash bash
ln -s /data/nano nano
export TERMINFO=/etc/terminfo
export TERM=linux
mount -o remount,ro /system
**P.S. So I also performed a regular mount in root, which i think is what made things bad, but not totally sure!**
Click to expand...
Click to collapse
If you can get into download mode ,flash stock rom from Sammobile

Categories

Resources