Fedora 12 running on Android

Linux based operating system for mobile phones.
User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Fedora 12 running on Android

Post by Void Main » Sat Nov 06, 2010 4:33 pm

I'm running Fedora 12 on my myTouch Slide 3G Android phone as of just a few minutes ago. Here's how I did it:

- Download the prebuilt root file system for the ARM version of Fedora 12
- Create a 1GB file system image to extract the file system image to
-- dd if=/dev/zero of=fedora.img bs=1M count=1000
-- mkfs.ext2 fedora.img
-- mkdir mnt
-- su
-- mount fedora.img mnt -o loop
-- cd mnt
-- tar -xvjf ../rootfs-f12.tar.bz2 --strip-components=1
-- cd ..
-- umount mnt

Now copy the fedora.img to your sdcard so it ends up in /sdcard/fedora then create a startup script. I created one called /data/bin/fedora:

Code: Select all

export kit=/sdcard/fedora
if [ ! -d /data/local/fedora ]
then
mkdir /data/local/fedora
fi
export mnt=/data/local/fedora
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export USER=root
export TERM=linux
#export LANG=en_US
export HOME=/root
mount -t ext2 -o loop,noatime $kit/fedora.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
sysctl -w net.ipv4.ip_forward=1
chroot $mnt /bin/bash

#After exit command is executed clear it all up
echo " "

echo "Shutting down Fedora"
umount $mnt/dev/pts
umount $mnt/proc 
umount $mnt/sys 
umount $mnt
Run the script from a shell on the phone via connectbot or "adb shell". Now you should be chrooted into the Fedora environment. You need to create the /dev/* stuff as udev isn't running. You could start udev "/sbin/start_udev" which is what I did but it takes over the phone's GUI but after a restart all my /dev/* stuff was there, or I created it when I ran /sbin/MAKEDEV. Now you can start sshd "service sshd start" (don't forget to set root's password), ssh to your fedora installation on your phone and then do a yum update and yum install more software if you wish. That's all for now.
Last edited by Void Main on Mon Nov 08, 2010 11:12 am, edited 1 time in total.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Nov 06, 2010 6:39 pm

Got lxde under vnc working now after yum installing vnc server package, some lxde packages and the urw font package:

Image

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Mon Nov 08, 2010 2:00 pm

Couple of other notes. I decided to create my voidmain user account and realized I couldn't do anything network related under this user (run vncserver, firefox, etc). I then ran across this:

http://android-dls.com/wiki/index.php?t ... root_users:
Sockets for non-root users:

New users within the debian root cannot by default do anything that involves the network. Adding said users (as root) to a group with an id of 3003 will give them this access.

Code: Select all

# groupadd -g 3003 sockets
usermod -G sockets username
So I created a group called sockets with a group number of 3003 and added my voidmain user to that group and now I can network under that account. :)

A couple of notes on vncserver. It will not shut down and clean up after itself in either Fedora or Ubuntu installations on Android so I modified the Kill subroutine of the /usr/bin/vncserver script:

After this line:

Code: Select all

    warn "Killing Xvnc process ID $pid\n";
modify the kill like and add a few more lines:

Code: Select all

    warn "Killing Xvnc process ID $pid\n";
    system("kill -9 $pid");
    system("rm -f /tmp/.X11-unix/X*");
    system("rm -f /tmp/.X?-lock");
    system("pkill -9 -f /usr/bin/lxsession");
    system("pkill -9 -f /usr/libexec/");
Also replace your ~/.vnc/xstartup with this xstartup (assuming you are using the lxde window manager):

Code: Select all

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid black
lxterminal &
/usr/bin/lxsession -s LXDE &
One last thing. I couldn't start firefox until after I started the messagebus service. I think it may only have to be started once to create the necessary dbus system id. It might not have to be started again after a reboot, haven't tested.

Another screenshot (click on it for higher res):

Image
Last edited by Void Main on Sat Dec 11, 2010 5:48 pm, edited 3 times in total.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Dec 11, 2010 11:14 am

I put lighttpd+php+phpsysinfo on the phone. You can view it (if I am home and have the phone connected to my network) here:

http://voidmain.is-a-geek.net:83/

or

http://voidmain.is-a-geek.net:8300/

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sat Dec 11, 2010 4:54 pm

Cool stuff :)
I think I'm gonna try put F12 on my SGS too just to try it out.
but I wonder, is it still a phone that I can use or is it just a small PC?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Dec 11, 2010 5:53 pm

It's both. It continues to function as your phone just like normal. You're not actually booting a different kernel. All you are doing is "chrooting" into a Fedora (or Ubuntu) file system image. So whatever you do under that shell that you chrooted with is Fedora and the rest of the phone contues on it's merry way. So in your chrooted shell you can start fedora's sshd, web server, X, etc, etc. If you look at the process list you will see processes running from both the phone side and from the chrooted side as they are both using the same running kernel.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sat Dec 11, 2010 6:04 pm

So it's not really a replacement of the OS on the phone then?
Like the ones I did with my SGS phone the other day.
I had to fill he check box to reformat when adding the first version of the OS
and when just upgrading no "reformat" and this made me think that this TOO would totally replace the "phone-OS"

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Dec 12, 2010 8:58 am

No, this does not replace the OS. All the instructions are in the first post. It's nothing more than copying a single file to your SD card (the file is an image of a file system).

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Fedora 12 running on Android

Post by Basher52 » Sun Feb 20, 2011 8:38 pm

If I'm gonna try this, do I need to use iptables as firewall.
Since it's more like a PC then a phone when using this and like browsing the net and all.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: Fedora 12 running on Android

Post by Void Main » Mon Feb 21, 2011 4:03 am

Android already uses iptables. Also my phone provider does not allow incoming connections over the mobile data network and appears to NAT the connection. I have an httpd server running and can get to it over my wifi connection but cannot get to it via the address on the mobile interface or the NATed address. So, the only thing you might be concerned about is your wifi interface, and of course you're only going to add exposure as you run network apps (web server, ssh, etc).

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: Fedora 12 running on Android

Post by Void Main » Sun Sep 18, 2011 10:28 am

I refined the startup/shutdown procedure a little bit so now I can start it up with the click of a button which will get the file systems mounted and start sshd and the web server and enter a bash shell. Just exit the shell to shut down Fedora. So to start Fedora I have an entry in ConnectBot called "Fedora" that does nothing more than execute my /data/bin/fedora script which contains:

Code: Select all

export kit=/sdcard/fedora
if [ ! -d /data/local/fedora ]
then
mkdir /data/local/fedora
fi
export mnt=/data/local/fedora
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export USER=root
export TERM=linux
#export LANG=en_US
export HOME=/root
mount -t ext2 -o loop,noatime $kit/fedora.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
sysctl -w net.ipv4.ip_forward=1
#chroot $mnt /bin/bash
chroot $mnt /bin/1

#After exit command is executed clear it all up
echo " "

echo "Shutting down Fedora"
umount $mnt/dev/pts
umount $mnt/proc 
umount $mnt/sys 
umount $mnt
In the Fedora file system image I have a /bin/1 and a /bin/2 script.

/bin/1:

Code: Select all

if ifconfig | grep -q 192.168.0; then
  echo "search voidmain.home" > /etc/resolv.conf
  echo "nameserver 192.168.0.1" >> /etc/resolv.conf
else
  echo "nameserver 8.8.8.8" > /etc/resolv.conf
fi
service sshd start
service lighttpd start
mount /sd
echo "Type \"exit\" to stop Fedora"
bash
/bin/2
/bin/2:

Code: Select all

service lighttpd stop
service sshd stop
umount /sd
If your wifi interface is up you should be able to get to the web server and ssh into Fedora running on your phone. I also have it mount the SD card under /sd so I can manipulate things via SSH. You could also start up vncserver in the "/bin/1" script and shut it down in the "/bin/2" script if you want to start a graphical environment.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Re: Fedora 12 running on Android

Post by Calum » Fri Oct 14, 2011 5:02 am

this whole process sounds really simple actually.
So with regards to the fact you're not replacing the OS, that makes this a dual boot system, does it?

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Re: Fedora 12 running on Android

Post by Basher52 » Fri Oct 14, 2011 2:59 pm

If I'm not incorrect, which I usually am :P
This is not a dual boot system.

I asked him about this and at that point it sounded to me like a "phone" system
and in that you can boot up F12.
This since you create a F12 system within the Phone-OS-system, if you get my meaning here.
by Basher52 » Sun Dec 12, 2010 12:54 am
Cool stuff :)
I think I'm gonna try put F12 on my SGS too just to try it out.
but I wonder, is it still a phone that I can use or is it just a small PC?



Postby Void Main » Sun Dec 12, 2010 1:53 am
It's both. It continues to function as your phone just like normal. You're not actually booting a different kernel. All you are doing is "chrooting" into a Fedora (or Ubuntu) file system image. So whatever you do under that shell that you chrooted with is Fedora and the rest of the phone contues on it's merry way. So in your chrooted shell you can start fedora's sshd, web server, X, etc, etc. If you look at the process list you will see processes running from both the phone side and from the chrooted side as they are both using the same running kernel.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: Fedora 12 running on Android

Post by Void Main » Sat Oct 15, 2011 4:43 pm

Calum wrote:this whole process sounds really simple actually.
So with regards to the fact you're not replacing the OS, that makes this a dual boot system, does it?
When I think of dual boot I think of booting one OS or the other. That isn't what this is. You don't actually boot up another kernel, you use the already running Linux kernel from the Android OS. Just mount the Fedora file system and chroot into it. Both Fedora and Android will be running alongside of each other, both sharing the same running kernel. It's very similar to booting into Rescue mode from your CD/DVD, mounting your partitions from your hard drive and chrooting into it. Once chrooted, you can run anything from that shell just like you had booted the file system directly. That is, you can start sshd, vncserver, etc. If you start up sshd and ssh in from another host it will look like you are logged into a regular Fedora system. You can "yum install", etc, etc.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Re: Fedora 12 running on Android

Post by Calum » Tue Oct 18, 2011 6:14 am

that's very clever. So it's like using a fedora "application/utilities" suite.
I'm quite curious how the various details work (things like whether any executables are duplicated, and what the path is to decide which of two versions to use and so on), i guess the internet will have those details though, i just need to google it all up. :-)

Post Reply