Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Installing Gentoo on Android chroot. (T-Mobile G2)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 426

PostPosted: Tue Apr 12, 2011 3:32 pm    Post subject: Installing Gentoo on Android chroot. (T-Mobile G2) Reply with quote

The fist thing I had to do was root my phone. Visionary was the easiest tool I found. Next I needed a terminal, so I found Android terminal emulator. Then I needed a stage to work with. So I downloaded stage3-armv7a-20110403.tar.bz2 and unpacked it to /mnt/sdcard/gentoo. At this point I found out that Android mounts the sdcard with noexec mount option. I don't know how to get around that yet. So after poking around I decided to unpack the stage3 to /data/gentoo. And hello gentoo on android. Chroot worked, and now I'm in gentoo.

So now I have 2 questions. How do I mount the sdcard with exec permissions? Where do I find resolv.conf in Android so I can access network in chroot?[/list]
_________________
MB: Biostar TForce 6100 AM2 @ 250x10
CPU: AMD Athlon 64 3800+ X2 @ 2500mhz
MEM: G. Skill DDR2-800 2GB @ DDR2-1000
GPU: nVidia GeForce 7600 GT
OS: Gentoo Linux 2006.1
Back to top
View user's profile Send private message
djdunn
l33t
l33t


Joined: 26 Dec 2004
Posts: 692
Location: Arrakis

PostPosted: Wed Apr 13, 2011 12:28 pm    Post subject: Reply with quote

your going to cause me to need to try this... not want but need...

I dont know a lot about the android, I do know that exec even semi related to the sdcards as in trying to update certain apps with their info stored on the sdcard doesnt really work.

hmm i have a 32 gig card so it might be different thing for me but can you put some sort of logging software on it? so you can see the output of the terminal when you plug in the sdcard you can see what it says in /var/log/messages.

thats where I would go. because i think they do use some sort of auto-detection or detection on insert maybe hal or something similar? Can you get any hints from the running services?
_________________
"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present."

-Master Oogway
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 426

PostPosted: Wed Apr 13, 2011 1:19 pm    Post subject: Reply with quote

I got the network to work inside the chroot now. Turns out Android has a tool called getprop that reads various configuration settings, including DNS addresses. Once I had those all that needed done was adding a nameserver line to Gentoo's resolv.conf. Syncing portage now.

Still haven't figured out the sdcard mount options yet. After sync completes I'll check messages and see if anything in there points me in the right direction. However at this point I think all I need to do is mount -o remount,rw,exec /mnt/sdcard. Will try soon.
_________________
MB: Biostar TForce 6100 AM2 @ 250x10
CPU: AMD Athlon 64 3800+ X2 @ 2500mhz
MEM: G. Skill DDR2-800 2GB @ DDR2-1000
GPU: nVidia GeForce 7600 GT
OS: Gentoo Linux 2006.1
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 426

PostPosted: Thu Apr 14, 2011 4:46 pm    Post subject: Reply with quote

Ok, so now I got the sdcard partially figured out. I just wound up formatting the sdcard to ext3 then mounted the partition tp /mnt/gentoo. So I'm rocking some gentoo on my phone now. Pretty cool stuff.
_________________
MB: Biostar TForce 6100 AM2 @ 250x10
CPU: AMD Athlon 64 3800+ X2 @ 2500mhz
MEM: G. Skill DDR2-800 2GB @ DDR2-1000
GPU: nVidia GeForce 7600 GT
OS: Gentoo Linux 2006.1
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 426

PostPosted: Fri Apr 15, 2011 4:35 am    Post subject: Reply with quote

Well, I seem to be stuck again. It seems that inside the chroot some programs are able to resolve domain names properly, but others don't. For example rsync seems to work fine, because emerge --sync works. But wget doesn't work, it shows an error resolving names for the different gentoo mirrors. Ping seems to work fine too.

So anybody know why wget can't resolv DNS but other programs can?
_________________
MB: Biostar TForce 6100 AM2 @ 250x10
CPU: AMD Athlon 64 3800+ X2 @ 2500mhz
MEM: G. Skill DDR2-800 2GB @ DDR2-1000
GPU: nVidia GeForce 7600 GT
OS: Gentoo Linux 2006.1
Back to top
View user's profile Send private message
disi
Veteran
Veteran


Joined: 28 Nov 2003
Posts: 1354
Location: Out There ...

PostPosted: Fri Apr 15, 2011 7:07 am    Post subject: Reply with quote

duby2291 wrote:
Well, I seem to be stuck again. It seems that inside the chroot some programs are able to resolve domain names properly, but others don't. For example rsync seems to work fine, because emerge --sync works. But wget doesn't work, it shows an error resolving names for the different gentoo mirrors. Ping seems to work fine too.

So anybody know why wget can't resolv DNS but other programs can?


It's this option in make.conf to not download as root or something, some fetch option...
I had that on another arm device.

//edit: userfetch needs to be disabled in FEATURES, I think.
_________________
Gentoo on Uptime Project - Larry is a cow
Back to top
View user's profile Send private message
duby2291
Guru
Guru


Joined: 17 Oct 2004
Posts: 426

PostPosted: Sat Apr 16, 2011 4:34 am    Post subject: Reply with quote

Thanks that was the answer.

OC'd while on AC to 1497mhz running emerge -e world now.

EDIT: When emerge got to python it crapped out with a sandbox access violation. I know this isn't the proper fix, but I was able to get around it by using FEATURES=-sandbox emerge --resume. Then when python finished I stopped it, and then ran emerge --resume to continue. I only allowed python to install with the sandbox feature turned off. I'm on 87 of 130 now.
_________________
MB: Biostar TForce 6100 AM2 @ 250x10
CPU: AMD Athlon 64 3800+ X2 @ 2500mhz
MEM: G. Skill DDR2-800 2GB @ DDR2-1000
GPU: nVidia GeForce 7600 GT
OS: Gentoo Linux 2006.1
Back to top
View user's profile Send private message
warrawarra
Tux's lil' helper
Tux's lil' helper


Joined: 30 May 2007
Posts: 84

PostPosted: Tue Apr 26, 2011 8:24 pm    Post subject: Reply with quote

If you get stuck with android pm a developer in JetDroid.org as there is a few old time gentoo freaks that is doing some good work.
Back to top
View user's profile Send private message
DrivinTin
n00b
n00b


Joined: 19 Sep 2004
Posts: 11

PostPosted: Sun May 01, 2011 1:31 am    Post subject: Reply with quote

So I am now to the android, actually only had it a few days so still learning a lot. But one thing i did notice is the /mnt/sdcard is not actually the external sdcard on my device. I have a /mnt/_ExternalSD that my phone mounts that is the actual removable card. I am downloading the stage3 now and hopefully will get mine up running soon.
Back to top
View user's profile Send private message
DrivinTin
n00b
n00b


Joined: 19 Sep 2004
Posts: 11

PostPosted: Tue May 03, 2011 6:16 pm    Post subject: Reply with quote

So here are some things I did to get Gentoo going on mine.

First off I have the G2x, I knows the way they handle the external SD card is a bit different, so that is something to look at on your own phone.

You could actually root your device and do this all from the phone itself as far as I can tell, but I am lazy and want to copy and paste so I used the adb shell that is in the SDK.

The first thing that confused me is the SD Card. Like I said I have /mnt/sdcard which is actually internal storage for the phone, then I have /mnt/sdcard/_ExternalSD which is the removable card. When my phone mounts it the mount looks pretty nasty:

Code:
/dev/block/vold/179:17 /mnt/sdcard/_ExternalSD vfat rw,dirsync,nosuid,nodev,noexec,noatime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0


So me being lazy once again I installed the ROM Manager app on the phone, ran the partition tool (FROM THE BOOTMANAGER, this is the only way to get a partition larger than 512M). It partitioned the cards to a 4 gig ext3, I did a 64 meg swap, and the rest to fat.

So now the phone would mount the sdcard with the vfat but not the other two partitions. So to find them i went to the /dev/block and listed the devices instead of using the numeric values.

Code:
brw------- root     root     179,  19 2011-05-03 01:12 mmcblk1p3
brw------- root     root     179,  18 2011-05-03 01:12 mmcblk1p2
brw------- root     root     179,  17 2011-05-03 01:12 mmcblk1p1
brw------- root     root     179,  16 2011-05-03 01:12 mmcblk1


You can see the vfat up above is mounter on 179:17 so that is on mmcblk1, did an fdisk print on it:

Code:
Disk /dev/block/mmcblk1: 15.9 GB, 15931539456 bytes
255 heads, 63 sectors/track, 1936 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

              Device Boot      Start         End      Blocks  Id System
/dev/block/mmcblk1p1               1        1432    11496093+  c Win95 FAT32 (LBA)
/dev/block/mmcblk1p2            1432        1930     4000000  83 Linux
/dev/block/mmcblk1p3            1930        1937       62050  82 Linux swap


There is my linux partition, good ol 83. So i did a quick mke2fs -j /dev/block/mmcblk1p2
Now the root file system is read only, so changed that so I could mount the partition directly.

mount -o rw,remount -t sysfs / /

Then made the mount point that I like

mkdir /mnt/gentoo

Mounted the partition I just made

mount /dev/block/mmcblk1p2 /mnt/gentoo

Ugh, I had a lot more typed and just lost it... Anyways that will get you up and running for the rest of the chroot over to Gentoo. I manually set my resolv.conf, and am just using wifi for now. I have noticed some builds hang on checking ptyranges and a C overflow check. Still working out some issues, but it is fun to mess with.

OH, DO NOT START SSHD
You have to go in and make a change to the sshd_config and change the AddressFamily inet. If set to AddressFamily all or not set at all, it will kill the phone and force a reboot when you try to start up the SSHd service.
Back to top
View user's profile Send private message
warrawarra
Tux's lil' helper
Tux's lil' helper


Joined: 30 May 2007
Posts: 84

PostPosted: Thu Jun 23, 2011 11:30 am    Post subject: Reply with quote

If you had issues with sshd then why not just use android adb to connect.
There is sshd and telnet apps or use telnetd in android before chrooting.

adb devices
...this shows your phone...
adb shell
$ or root prompt, not sure if your phone has to be rooted but you likely had to root your phone to get this far.

You might want to chmod -R 777 or similar the /opt/androi* folders as you have to emerge as root and then run
the sdk manager as user and adb as user as well.[/code]

http://android-dls.com/wiki/index.php?title=ADB

ADB how-to for gentoo:
http://wiki.cyanogenmod.com/wiki/Howto:_Install_the_Android_SDK
Code:
Gentoo Linux

    emerge dev-util/android-sdk-update-manager
    run /opt/android-sdk-update-manager/tools/android
    install platform-tools package
    ADB will be at /opt/android-sdk-update-manager/platform-tools/adb
    Edit your .bashrc file and add this line:

        export PATH="/opt/android-sdk-update-manager/platform-tools/:${PATH}"
Back to top
View user's profile Send private message
DrivinTin
n00b
n00b


Joined: 19 Sep 2004
Posts: 11

PostPosted: Thu Jun 23, 2011 8:06 pm    Post subject: Reply with quote

warrawarra wrote:
If you had issues with sshd then why not just use android adb to connect.
There is sshd and telnet apps or use telnetd in android before chrooting.



Yeah looking back I did not make it clear how I was connecting to the phone. I was actually using adb, the SSHd I was actually referring to was the one in the gentoo chroot. I have used the app versions of the SSHd also. The one in the chroot env is the one that will crash the phone.
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 153
Location: ~/

PostPosted: Fri Nov 18, 2011 4:51 am    Post subject: Reply with quote

Has anybody had any luck with getting network or other types of permissions as a regular user in an android chroot? xfce4 is nice and all on my phone, but running as root is a bit silly.
Back to top
View user's profile Send private message
ShurikenMOOO
n00b
n00b


Joined: 29 Dec 2011
Posts: 2

PostPosted: Thu Dec 29, 2011 10:40 am    Post subject: Reply with quote

Hey, I am not actually a Gentoo user (I come from the great world of Archlinux :P) but I believe I can help you with your network problem.

I am running a debian chroot in my Android phone, but it should be the same for all distros.

I found this "AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */"
So all you have to do is create a aid_inet group with id 3003 (the ID is the important part) and then add a normal user to that group.
Then the kernel with give that user network permissions. This is part of android security concept, where every app has its own user id and permissions are extra groups ;)

That way you can work as a normal user ;)
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 153
Location: ~/

PostPosted: Thu Dec 29, 2011 6:58 pm    Post subject: Reply with quote

ShurikenMOOO wrote:
I found this "AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */"


Interesting, have you been able to give a regular user in a chroot permissions for audio and video as well?
Back to top
View user's profile Send private message
ShurikenMOOO
n00b
n00b


Joined: 29 Dec 2011
Posts: 2

PostPosted: Fri Dec 30, 2011 9:11 am    Post subject: Reply with quote

I didn't try and don't have time to at the moment, but you can try yourself.

http://android-dls.com/wiki/index.php?title=Android_UIDs_and_GIDs

You can find GIDs for audio and graphics there. :)

Edit: But now that I think of it, there are no special permissions needed to run audio or graphics I believe, so it should work automatically. I don't have time to test it atm tho :<
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 153
Location: ~/

PostPosted: Sun Jan 01, 2012 10:17 pm    Post subject: Reply with quote

Thanks for the link!
Back to top
View user's profile Send private message
Adwin
Tux's lil' helper
Tux's lil' helper


Joined: 13 Mar 2005
Posts: 128
Location: Poland

PostPosted: Thu Mar 15, 2012 8:56 am    Post subject: Reply with quote

duby2291 wrote:
Well, I seem to be stuck again. It seems that inside the chroot some programs are able to resolve domain names properly, but others don't. For example rsync seems to work fine, because emerge --sync works. But wget doesn't work, it shows an error resolving names for the different gentoo mirrors. Ping seems to work fine too.

So anybody know why wget can't resolv DNS but other programs can?


Seems like reviving an old thread, but the answer to your problem is that Android has certain programs accessing network functions should be linked against bionic libc & not glibc.

btw, I usually keep my chroots in a loop device;
too many inodes on a small device like a phone can impede performance.
Here's a little script I made in order to automatically chroot into the environment (automatic system/sdcard discovery & mount)
http://www.box.com/s/ncrs2o8i5lc6vj7pgpxy

Read it first and adapt it to your needs.
Advice: if some functions seem to be failing, you need to use their busybox equivalent (not toolbox)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum