Running Fedora on the Galaxy S

The Samsung Galaxy S is a quite cool smartphone running Linux under the hood. Linux, but not Fedora. Until now.

Update: new post with screenshots and video.

You need a Galaxy S (or probably any decent Android unit). You need root on your device, the superuser package, busybox, and a way to log in via ssh. I used the QuickSSHD package available via marked. A VNC viewer and terminal emulator may also come handy, so you can abuse your Galaxy S also when you are on the run.

Information on how to root your phone is all over the net. No need to repeat that here.

Actually running Fedora alone on the Galaxy S may become possible in some distant future, but for now, we have to be content with running a chroot session of Fedora, and running X11 apps via VNC. As Fedora already exists for ARM, all we have to do is to unpack a root filesystem and chroot into it. Easy!

To avoid filling the internal sdcard, it may be a good idea to use an ext3 or ext4 (NOT vfat or msdos) formatted extra sdcard, or a loop-mounted image. The easiest way to get started though, is just using the internal sdcard, so that is what is demonstrated in the following. You probably want to keep an eye on disk space usage. Start an extra shell via ssh, and run df from time to time.

# df /data/local

Now, let’s get started.

Start with logging into your phone over ssh. I have put an entry “galaxys” in my /etc/hosts. Your phone’s ip address is visible in the QuickSSHD main window.

$ ssh root@galaxys

Make a home for your Fedora root filesystem. /data/local will do

# cd /data/local
# mkdir fedora
# cd fedora

Download a Fedora root filesystem tarball. The latest available is f12. The system wget was by some reason unable to resolve names correctly, but fetching via ip address worked. ymmv. The ip address for ftp.linux.org.uk is 195.92.253.2.

# wget http://195.92.253.2/pub/linux/arm/fedora/rootfs/rootfs-f12.tar.bz2

Unpack the file system. This may take a few minutes. Then remove the tarball to free some disk space.

# bzcat rootfs-f12.tar.bz2 | tar -xvf -
# rm rootfs-f12.tar.bz2

Make a start script

# vi /data/local/bin/startfedora

Add something like this:

#!/bin/sh
#
# Simple script to start a fedora chroot
#
path=$PATH
home=$HOME
term=$TERM
shell=$SHELL

fedora="/data/local/fedora/rootfs-f12"

echo Mounting kernel filesystems...
busybox mount -t proc proc $fedora/proc
busybox mount --bind /sys $fedora/sys
busybox mount --bind /dev $fedora/dev
busybox mount -t devpts devpts $fedora/dev/pts

echo Starting Fedora in chroot at
echo $fedora ...
export TERM=vt100
export HOME=/root
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export SHELL=/bin/bash
export EDITOR=vi

/system/bin/chroot $fedora $SHELL -l

# Graceful exit
echo Unmounting kernel filesystems...
busybox umount $fedora/dev/pts
busybox umount $fedora/dev
busybox umount $fedora/sys
busybox umount $fedora/proc

# Restore environment
PATH=$path
HOME=$home
TERM=$term
SHELL=$shell
echo Done.

Make the script executable

# chmod +x /data/local/bin/startfedora

Start the fedora chroot

# startfedora

If everything worked, you are now inside the fedora chroot, actually running fedora on your phone. Wow!

# cat /etc/fedora-release
# uname -a

Now, let’s do some maintenance work, to make it actually usable

Rebuild the rpm database

# rm -vf /var/lib/rpm/__db.*
# rpm --rebuilddb

Add a working resolv.conf

# echo "nameserver 8.8.4.4" > /etc/resolv.conf

Fix the mtab

# rm -f /etc/mtab
# vi /etc/mtab

This will do:

rootfs / rootfs ro,relatime 0 0
proc /proc proc rw,relatime 0 0
sys /sys sysfs rw,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
proc /proc proc rw 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0

Check that /, /proc, /sys, /dev and /dev/pts is mounted

# ls / /proc /sys /dev /dev/pts

Update lastest packages

# yum update

You may want to run apps in an X server via VNC. Quite cool.

# yum install blackbox xterm tigervnc-server xorg-x11-xauth bitstream-vera-sans-fonts xorg-x11-server-utils
# mkdir /root/.vnc
# vi /root/.vnc/xstartup

A simple xstart script for vnc

#!/bin/sh
xterm &
blackbox &
sleep 1
xsetroot -solid midnightblue

Start the VNC server

# chmod +x /root/.vnc/xstartup
# vncserver -geometry 800x480 :1

You can now connect to your phone via any vnc client on port 5901. If you want to show off running X on the device itself, connect to 127.0.0.1

The sky (and disk space) is the limit.

Before exiting the Fedora chroot, make sure you kill all the processes you have started, including the VNC server.

# vncserver -kill :1
# exit

Bo{g,n}us points:
* For now, the VNC server has to run as root. I’d be interested in any workaround. Start a display manager instead of a shell session? Running a nested X server?
* You may add your own user within the fedora chroot. Just run the normal adduser and password commands
* You can run a local openssh-server sshd within the chroot jail. Just configure it to run on another port than 22 to not get in QuickSSHD’s way, and start it with “service sshd start”.

11 Responses to “Running Fedora on the Galaxy S”

  1. Chris says:

    Some screenshots would have been nice…

  2. John says:

    I just signed up with ATT for 2 years and with a galaxy note phone. The phone’s screen is already 5.3 inches large. And I use it now to type this message on a HDTV connected to the phone. I would like to give this chroot solution a shot because I don’t have a home PC. The phone is the only PC I have.

  3. Ingvar says:

    John, that sounds like a bad idea. My hack with running Fedora on the Galaxy S was purely for fun. I would not recommend running Fedora as a PC on your Galaxy S. You will get better use from an old second hand PC.

  4. John says:

    I am able to follow through your startfedora and xstartup scripts to run fedora 17 arm on my galaxy note. I used last week’s released arm-xfce image from fedoraproject.org . So, it is the default xfwm4 instead of blackblack command to open up the window in vnc client.

    The hardest part for my situation is actually extracting fedoraproject.org’s tar file because they use PAX tar, which my android root-explorer/androzip can not extract. And actually the arm-xfce image is too big for my phone’s root partition and I had to use external sdcard. But external sdcard’s partition is of vfat, which can not run linux root file system. So, the only way I could do it was pulling out the micro sdcard and slips it in to a normal sdcard jacket and run in on a regular PC to finally dump the entire arm-xfce file system on to the sdcard. I will tell more about this weekend project that cut my power cord to a home PC in http://www.java-vpws.com .

  5. John says:

    This is the answer to cutting the real cord and saving our time from writting letters to poor windows laptop OEMs whining for refund of unused windows.The customer service workers in OEMs make less than the OM. And this is a break for them as well.

  6. ingvar says:

    John, you can save space by unpacking the trball on another box, and remove the stuff you don’t need, like locales in other languages, for instance.

  7. John says:

    Ingvar, Thanks. I did notice the large chunk of locales when I worked on my ex-PC. The whole exercise set my mind in a different direction. The first thing I searched in my android PC in the full blood arm firefox was “fedora phone”, and then I posted my first reply to any google group with the forum about this exercise. I am able to edit my google doc spreadsheet of my monthly bills in my android PC now. The vnc across 127.0.0.1 is much, much faster than any LAN network. But, every thing I touch is old. And since I posted on google group, it is heading to retirement . So is fedora arm heading to some change I guess. I think this exercise could lay the exit strategy of fedora -personal, meaning a partition that lives on, and then hello to everything-hardware-accelerated android. I am downloading hdmi full-screen firmware included rom now.

  8. John says:

    I hope VNC client in android market can have a client that caters to localhost. I am typing this message in arm fullblood firefox. Today when I tried to play google music, it told me to deauthorize, in a settings page, some devices in my account to allow my newly reflashed galaxy to play. But, android browsers can not rendor the “settings” gear button in google.com. I don’t trust the android browsers. I came in to my fullblood firefox to go to the same help web page, and the “settings” gear button is readily visible. I went back to android browser, and click on the blank space of the supposedly existing gear button. And the clicking worked out of blank space in android browser.

    Android browser can’t be used to post with text boxes. The character/cursor tracing is not right. The cursor is 2 charactors behind the letter that is about to be added. And the enter key is not interpreted by android as adding a new line, if you noticed my previous 3 postings were all single paragraphed. That was because whenever I press Enter, android took me to submet this text box. Android browser is not meant to be used to produce. Android browser is made to consume.

    People dont understand the true meaning of being mobile. I lived the entire last half a year in hotels and I think mobile meaning advanced technology allowing us to do things we used to do on desktop. It is the compressing process that mobile is about, not the spreading things to pieces, not the cutting out what we could do. A localhost specialized VNC client can get rid of ZRLE encoding and pipe raw X communication through VNC. And local VNC can get rid of scaling the pixels when projecting to HDMI. The scrolling should become faster if no floating point calculations involved in scaling.

  9. prashant says:

    Hiii
    I am completely unknown to do all this stuff….
    Can you pleasp post complete steps with screenshots or video from the starting(rooting the phone)…I am currently using galaxy note 2

  10. Ingvar says:

    prashant,
    Sorry, I have no plans on doing this. Also, you should know what you are doing, and know your tools before applying these kind of changes to your phone. It’s not just a series of commands, and with the power of root you may harm your phone beyond repairs. You have been warned.

    You should start by browsing the xda-developers’ forums to get your device rooted. Google will help you. Then download a tarball snapshot of a Fedora (or any other Linux distro) ARM system. Google should be able to help you with this too. Slim that down to a minimal system that will suite inside your phone’s root filesystem. Transfer it by some sshd daemon. There are several on Google Play Marked.

    Good luck,

    Ingvar

Leave a Reply