Hi.
I was wondering how to do that and what's required for this - turned out that it's dead simple.
Requirements:
Linux machine
Root on the above Linux machine
Already working android on HD2
HD2 booted into Windows Mobile or the SD card taken out of it and mounted to your Linux machine
So...
There are some rootfs.img available to download from: http://ip208-100-42-21.static.xda-developers.com/showthread.php?t=719646 but they may not be working with your build or there's a newer build. The instructions I provide are universal and should work for all builds.
Since we have access to all partition images we can modify anything we like on them so getting root on your android will be easy.
From what I discovered - which maybe is obvious to some but was not to me, was that su binary is located in 2 places (two partitions):
/bin
/system/xbin
and the one in /system/xbin is overmounted by by the one from /bin - probably because the one in /bin is hacked (the standard one may not allow granting root to any application and only allow it to ADB shell).
If you do the following using any terminal emulator from Android:
ls -all /system/xbin/su
you'll see that it's permissions are set to: -rwxrwxrwx or -rwxr-xr-x depending on what build u have (the first one is not really a good permission set since it allows anybody to write to the file - BAD but irrelevant here). What's missing here is the SUID bit. Without SUID permission this binary won't be able to grant root. So what u need to do here is set su as SUID.
I saw on some hacked/rooted rootfs.img that this has been done by adding a chmod 04755 /bin/su and /system/xbin/su lines to startup scripts somewhere near the end of the booting process but my way of doing it is to set SUID on the binary itself.
So...
Assuming that you have your HD2 connected to your Linux machine via USB and it's set to STORAGE mode or you have your SD card inserted to the Linux machine and mounted as /media/disk (the path may be different in your case) you need:
On your Linux machine - Become root (su -) or (sudo bash) or login simply login as root
create yourself a directory (eg rootfs): mkdir rootfs
mount the root partition image to rootfs: mount -o loop /media/disk/rootfs.img rootfs
grant SUID to /bin/su: chmod +s rootfs/bin/su
unmount the image: umount rootfs
safely remove the card/disconnect HD2 (by using your distro ways - eg in KDE4 use "device notifier widget"
insert your SD card to HD2/disconnect HD2 from Linux box's USB port
Fire up haret and boot your Android distro
Enjoy rooted Android
a.key said:
Hi.
I was wondering how to do that and what's required for this - turned out that it's dead simple.
Requirements:
Linux machine
Root on the above Linux machine
Already working android on HD2
HD2 booted into Windows Mobile or the SD card taken out of it and mounted to your Linux machine
So...
There are some rootfs.img available to download from: http://ip208-100-42-21.static.xda-developers.com/showthread.php?t=719646 but they may not be working with your build or there's a newer build. The instructions I provide are universal and should work for all builds.
Since we have access to all partition images we can modify anything we like on them so getting root on your android will be easy.
From what I discovered - which maybe is obvious to some but was not to me, was that su binary is located in 2 places (two partitions):
/bin
/system/xbin
and the one in /system/xbin is overmounted by by the one from /bin - probably because the one in /bin is hacked (the standard one may not allow granting root to any application and only allow it to ADB shell).
If you do the following using any terminal emulator from Android:
ls -all /system/xbin/su
you'll see that it's permissions are set to: -rwxrwxrwx or -rwxr-xr-x depending on what build u have (the first one is not really a good permission set since it allows anybody to write to the file - BAD but irrelevant here). What's missing here is the SUID bit. Without SUID permission this binary won't be able to grant root. So what u need to do here is set su as SUID.
I saw on some hacked/rooted rootfs.img that this has been done by adding a chmod 04755 /bin/su and /system/xbin/su lines to startup scripts somewhere near the end of the booting process but my way of doing it is to set SUID on the binary itself.
So...
Assuming that you have your HD2 connected to your Linux machine via USB and it's set to STORAGE mode or you have your SD card inserted to the Linux machine and mounted as /media/disk (the path may be different in your case) you need:
On your Linux machine - Become root (su -) or (sudo bash) or login simply login as root
create yourself a directory (eg rootfs): mkdir rootfs
mount the root partition image to rootfs: mount -o loop /media/disk/rootfs.img rootfs
grant SUID to /bin/su: chmod +s rootfs/bin/su
unmount the image: umount rootfs
safely remove the card/disconnect HD2 (by using your distro ways - eg in KDE4 use "device notifier widget"
insert your SD card to HD2/disconnect HD2 from Linux box's USB port
Fire up haret and boot your Android distro
Enjoy rooted Android
Click to expand...
Click to collapse
Excellent post mate! Been wondering how to do this myself... I only got as far as mounting and chmod'ng the wrong files
What build did you root, btw?
Will test this in a bit
pongster said:
Excellent post mate! Been wondering how to do this myself... I only got as far as mounting and chmod'ng the wrong files
What build did you root, btw?
Will test this in a bit
Click to expand...
Click to collapse
pongster, long no heared of any new cleanex thinking of making any android builds?
I'm using Desire V5 and it's the one I rooted.
shu8i said:
pongster, long no heared of any new cleanex thinking of making any android builds?
Click to expand...
Click to collapse
Might give it a whirl once I find the time...
pongster said:
Might give it a whirl once I find the time...
Click to expand...
Click to collapse
what happened to ubunto
Rubanzip said:
what happened to ubunto
Click to expand...
Click to collapse
Why are you bumping old threads from 3 months ago?
one question fellos .... this post means booting android directly with out help of windows mobile ....
sathara said:
one question fellos .... this post means booting android directly with out help of windows mobile ....
Click to expand...
Click to collapse
nope. that's called NAND
One thing that I really love about Android, is the Gnu/Linux system running in the background. I use Linux on all my regular machines where I do most work via my beloved terminal.
Playing in CLI on Android Phones is just as much fun only Android is missing a lot of the toys I'm used to. So I'm making a collection of some of these tools, some found on the Web and some Home made.
Here if the first collection of the things I've collected so far.
Most of it can be found in different places on the Web, but I find it a lot easier to just get it in one place.
http://dl.dropbox.com/u/14234754/XDA_GLOBAL/android_cli_extras.tar.gz
This small Archive contains the fallowing:
Bash 4.1 - This shell is made to become the default shell on your phone regardless if you connect via SSH or local terminal. Also added an bashrc file.
SSH Shell Client
Remount script - Makes it easier to optain RW on /system (HTC Users will need S-Off)
Nano Editor with terminfo not defined, fix
Init Script to set a user defined hostname and update the hosts file
Now, I don't remember where everything comes from. I believe that the Nano Editor is from the MoDaCo Forum (The terminfo fix is placed in the /system/bin/sh script). The Remount Script is from somewhere on this forum. Bash, I don't remember. SSH Client is from the Better Terminal APK (Perhaps an SFTP client would be nice to). The rest is just some small home made shell scripts.
The Hostname can be changed in /system/etc/init.d/05userinit (Make sure that your current ROM does not already has init scripts to alter hostname. Some custom ROMs do)
The bashrc file is placed in /system/etc/bashrc
This location can be changed in /system/bin/sh
The remount script makes it faster and easier to option RW on /system.
Just type "remount rw" in the shell to switch to Read/Write and then "remount ro" to switch back to Read-only. HTC Users needs S-Off in order to write to /system.
In order to copy the files to the /system partition, you need to option Read/Write without the remount script. In the Shell type "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system". (HTC Users without S-Off will need to do this using ADB in recovery)
If you use the Better Terminal APK for Android, you need to go to settings and make sure that it uses Android Terminal. Otherwise it will use it's own bash which only works when in Better Terminal and also it's full of errors. Also in the option "Command Line" it should be "/system/bin/sh". Make sure that there is NO - at the end, example "/system/bin/sh - ". You might need to remove it twice before it is gone.
(Just in case anyone should wonder. Yes your phone needs to be rooted)
Also if anyone has more fun CLI stuff for android then please bring it
I periodically get my sdcard to a state where it is read only. Not sure what causes this but a fix is to remount the sdcard. Currently I've been going into CWM and remounting it that way, but would like to do it via the terminal or adb. I found what I thought was the correct command online but I'm getting a usage error when I try it out.
Error:
Usage: mount [-r] [-w] [-o options] [-t type] device directory
Is this command correct for a Droid 2 (A955):
mount -o rw,remount -t /sdcard
Thanks!
I'll need to test this when I get home, but I believe you're missing the device before the directory. (ie. /dev/whatever)
Interesting. Copying and pasting your syntax worked fine for me. Sounds like you need a different copy of busybox. I'm running v1.16.2.
Huh? So it worked for you? Odd.
I just flashed the latest zombiestomped ROM (1.71) a few days ago and that has resolved the issue I was having that necessitated remounting my sdcard all the time. I never did figure out what was causing it to get locked into read-only mode.
Well I appreciate you verifying my syntax. At least now if I ever need to do that in the future I'll know what to do.
No problem. I can almost guarantee it was the version of busybox you had installed, as that's what provides the common linux tools like mount. They aren't the real binaries, but they're meant to be super-small applications that work just like the real thing, intended for small embedded systems.
I copied over the debian image i made for my sgs i9000 to try and run on my galaxy tab since i think the much larger screen, double RAM and faster cpu would make the image run smoother. I hoped the p7510 might be able to replace my laptop for word processing by running openoffice in chroot. I remembed to set the path, user and home variables. After mounting the image i go to chroot but i get the error
"chroot: can't execute /system/bin/sh"
I tried installing 10 other versions of busybox from the market. I am currently using the latest bindroid rom and pershoot kernel. The image worked on my sgs when it ran stock roms and now cm7.1. Is it the bindroid rom? I also tried to use apk manage 4.9 to decompile the rom's framework-res to enable crt off but it always errors out recompiling.
I realize that /system/bin/sh is where android has sh but i thought busybox would be smart enough to know that normal linux like my laptop has it in /bin/sh. My sgs seemed to know its directory of sh was not normal.
i'm having the same problem as well setting up debian to my galaxy tab, same model as you. when i mounted debian, it doesn't have /system/bin/sh, it's just /bin/sh. maybe you should try to specify /bin/sh at the end of the command, if you don't, it will default to /system/bin/sh. maybe you'll have more luck than me. i mounted debian in /data/local/debian and typed chroot /data/local/debian /bin/sh but it says "/bin/sh: precmd: not found". if you or anybody else figures out how to get past that, that would be awesome! thanks!
EDIT: look at the directory structure and see if it's /bin/sh instead of /system/bin/sh and if it is, specify /bin/sh at the end of the chroot command then hit enter and you might get an error, if you do, type: unset PS1 PROMPT_COMMAND .. that worked for me and then you'll get a command prompt and you'll be in linux now and not android. i hope i helped
The actual creation of an arm linux chroot image is probably out here on teh internetz somewhere, but I can assist with my mounting shell script (which works).
My image is of a debian arm chroot, and the image filesystem is ext2 (a good idea for fewer writes. ie innately non-journaling), has been used extensively on fw DE .17 and I'm currently trying it out on WW .29 (thank you, miloj).
I would upload my debian img somewhere, but I've actually broken it somewhat (it works for my needs, but it's nonetheless a bit too hacked up to be reliable).
I've modified it somewhat for generalization, some of it is probably wrong and/or redundant, and it IS hackish and ugly, but it works for me (tm).
* the chroot image only need a root account (and probably bash installed, but it usually is)
* You need busybox installed.
* You need to upload your chroot image named linux.img to the internal sdcard in a folder named linux
A shell script to set things up is attached.
What you need to do:
push the install script and run it:
Code:
adb push installlinuxstuff.sh /data/local/
adb shell sh /data/local/installlinuxstuff.sh
Now you can (from adb shell or terminal emulator on device):
Code:
su -
/data/local/mnt/linux.sh
/data/local/mnt/notlinux.sh
Feel free to remove the install script at
/data/local/installlinuxstuff.sh
when you've got it up and running.
Alternative way to run the scripts from adb shell:
Code:
adb shell su -c /data/local/mnt/linux.sh
adb shell su -c /data/local/mnt/notlinux.sh
I usually symlink start and stop (in my case deb and undeb) shell scripts placed in /data/local/mnt in /system/bin (ie shell scripts with 'su -c /data/local/mnt/whatever.sh' in them) for easy start an stop from terminal emulator, and if you've gotten this far you may welcome the small advice. (in other words - don't do this unless you _really_ know what you're doing)
Debian ARMHF or ARMEL?
If you would uploaded it (good place is google drive , sharing as public, as there are no ads or bull**** and the download is extremely fast) I would love to try your image - after modifying your script so it can work on a UHS-1 class MicroSD I want to try running this off of (should give it a little more speed).
zamaditix said:
Debian ARMHF or ARMEL?
If you would uploaded it (good place is google drive , sharing as public, as there are no ads or bull**** and the download is extremely fast) I would love to try your image - after modifying your script so it can work on a UHS-1 class MicroSD I want to try running this off of (should give it a little more speed).
Click to expand...
Click to collapse
Armel (I use the same chroot installation on my phone in a smaller image file (with less stuff installed)). I've got loads of personal stuff all over it and besides - it's somewhat broken. I really don't want to try to fix it.
So I'm working on retracing my steps, creating a clean armhf ext2 image (debian wheezy base installation for now) and redo the mount script, but I can't make any promises on a release date.
Anyhu - there are loads of images (armel, at least) on teh internetz (BT5 and too many ubuntu, for instance).
Just check so our kernel can mount the filesystem.
Edit: if not you can just create a new image file with a filsystem that's mountable and copy the chroot files to it.
So the ideal image for this tablet is armhf? If I wanted to create a Gentoo image, I would go with armv7? I'm just not sure exactly which ARM architecture this tablet is.
EndlessDissent said:
So the ideal image for this tablet is armhf? If I wanted to create a Gentoo image, I would go with armv7? I'm just not sure exactly which ARM architecture this tablet is.
Click to expand...
Click to collapse
The CPU is the Tegra 3 if you want to google it and it is an ARMv7 w/ NEON extensions chip. ARMv7 specification requires hardware fp so naturally it is ARMhf.
Nice to hear, keep us updated on your progress. I'm currently running an armel copy of Ubuntu 12.04 but it has problems with some packages and others are armhf only.
When I run linux.sh, I get an error that /sdcard can't be mounted because it doesn't exist.
Code:
mount: mounting /sdcard on /data/local/mnt/linux/sdcard failed: No such file or directory
I also tried changing the script to mount /mnt/sdcard, but that didn't work either.
EndlessDissent said:
When I run linux.sh, I get an error that /sdcard can't be mounted because it doesn't exist.
Code:
mount: mounting /sdcard on /data/local/mnt/linux/sdcard failed: No such file or directory
I also tried changing the script to mount /mnt/sdcard, but that didn't work either.
Click to expand...
Click to collapse
Yes, it is somewhat hackish, like I wrote. My image has got an sdcard folder (/sdcard) inside of it where I mount /sdcard from android. (Ie chroot and mkdir /sdcard)
followed this:
http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-rooted-transformer-prime/
make sure you have busybox installed der. Or at least the cp command in /system/bin
works well on my TF300T, Yea its not native but im currently configuring it for kernel building ;-D
FlyingPoo said:
followed this:
http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-rooted-transformer-prime/
make sure you have busybox installed der. Or at least the cp command in /system/bin
works well on my TF300T, Yea its not native but im currently configuring it for kernel building ;-D
Click to expand...
Click to collapse
Why does the mount script remount a non-existing block device with an ancient (according to android) filesystem?
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Edit: I read all the scripts, and they all mount that crap. It's not made for transformers, and on the android device it's made for it leaves /system mounted rw after you've run it, and WHEN run (installed) it modifies too much in /system/bin
Code:
# At first it copies loads of crap to /system/bin, and then:
cd /system/bin/
chmod 4777 *
It's not even "hackish" - it's just... wrong...
Will loop1 work every mount?
Code:
mknod /dev/loop1 b 7 0
losetup /dev/block/loop1
I'm almost only asking, since this thread was supposed to be about scripts?
gasingvar said:
Yes, it is somewhat hackish, like I wrote. My image has got an sdcard folder (/sdcard) inside of it where I mount /sdcard from android. (Ie chroot and mkdir /sdcard)
Click to expand...
Click to collapse
Thanks. I created /sdcard, and it works almost perfectly now. However, mounting devpts at /dev/pts doesn't seem to work. I replaced that line with
Code:
mount --bind /dev $mnt/dev
and it seems to work fine. Is there anything wrong with my method?
/dev/void said:
Why does the mount script remount a non-existing block device with an ancient (according to android) filesystem?
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Edit: I read all the scripts, and they all mount that crap. It's not made for transformers, and on the android device it's made for it leaves /system mounted rw after you've run it, and WHEN run (installed) it modifies too much in /system/bin
Code:
# At first it copies loads of crap to /system/bin, and then:
cd /system/bin/
chmod 4777 *
It's not even "hackish" - it's just... wrong...
Will loop1 work every mount?
Code:
mknod /dev/loop1 b 7 0
losetup /dev/block/loop1
I'm almost only asking, since this thread was supposed to be about scripts?
Click to expand...
Click to collapse
I'm assuming you're talking about the link in the post you quoted, even though you seem to be referencing the OP's use of the word "hackish". The script in the OP doesn't do any of that stuff. It just creates a few directories in /data/local/mnt/ and writes the mount/unmount scripts, which themselves only un/mount appropriate directories for the tablet. As for your question, I'm not nearly experienced enough to answer it. Sorry.
EndlessDissent said:
Thanks. I created /sdcard, and it works almost perfectly now. However, mounting devpts at /dev/pts doesn't seem to work. I replaced that line with
Code:
mount --bind /dev $mnt/dev
and it seems to work fine. Is there anything wrong with my method?
Click to expand...
Click to collapse
AFAIK your mount seems to be more complete, ie more android hardware goodies accessable from the chroot environment. However - that means more things possibly going wrong (like writing to a device who's critical to the android environment).
Personally I'd try to find what "hardware goodies" and whatnot I'd need to get the chroot environment working optimally, and not mount ALL of /dev.
EndlessDissent said:
I'm assuming you're talking about the link in the post you quoted, even though you seem to be referencing the OP's use of the word "hackish". The script in the OP doesn't do any of that stuff. It just creates a few directories in /data/local/mnt/ and writes the mount/unmount scripts, which themselves only un/mount appropriate directories for the tablet. As for your question, I'm not nearly experienced enough to answer it. Sorry.
Click to expand...
Click to collapse
Yes, and the OP is very honest about his script(s) being "hackish", which I interpret to mean 'not optimal, possibly redundant but working', all of which it is (and I applaud the early release, since for instance I could get things rolling), but the ubuntu image installation and mounting scripts from the other poster ( whom I was addressing ) are plain faulty.
I am looking for a armhf build of ubuntu or debian that I can chroot (newer the better), if anyone knows of such a build that would be fantastic but if not does anyone know of an easy to follow guide to compile such a thing?
I found two pretty good guides. I mostly followed THIS ONE, but I found that it doesn't mount enough before "first boot", so what I did was follow the guide until the point where you move the image to the tablet. Then I ran the OP's installlinux.sh script, and then the mount script. However, the mount/unmount scripts need to be edited before using them. Comment out the sdcard line and probably the devpts line (mounting devpts didn't work; Bash complained that devpts didn't exist; I had to replace it with the line I mentioned a few posts above, but as /dev/void says, it could be problematic, so be careful). Mount the image, make the /sdcard directory, exit, unmount, and edit the scripts again to mount/unmount /sdcard.
Next time you enter the chroot, feel free to run the
Code:
sh /debootstrap/debootstrap --second-stage
command to build the image, and follow the linked guide until the next time it tells you to exit the session (NOTE: The second echo "whatever" > sources.list command is wrong; it should be echo "whatever" >> sources.list; Also, remember to replace "squeeze" with the appropriate Debian version, in my case, "testing"). Instead of exiting right after the apt-get update, I'd recommend playing around with the chroot and configuring whatever apps you install. You can just use the OP's scripts now and ignore the script in the linked guide.
When the guide I linked above gets to this line:
Code:
sudo debootstrap --verbose --arch armel --foreign squeeze /mnt/squeeze/ http://ftp.debian.org/debian
just replace armel with armhf, and if you want a testing image, replace squeeze with testing.
Sorry I'm not attaching my image. I made it gigantic (5GB), so I don't really have anywhere to store it, and you probably wouldn't want to download a file that big. Plus, it already has Openbox and a bunch of other things you probably don't want installed. I'm assuming you'd want GNOME or KDE instead.