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”.