bump last modified date
[www.git] / tutorials / debian_on_samsung_galaxy.shtml
index 8cf176c72be542ae80d279b39deb0bee09d2c09c..b36b4e62e7a11ddee0bb7567b377cd593fe3a0a3 100644 (file)
@@ -21,14 +21,14 @@ AND on the tutorials index page!
 -->
 
 <h1>Installing Debian GNU/Linux in a chroot on a Samsung Galaxy S II</h1>
-<p><em>(Last updated 2011-11-25)</em></p>
+<p><em>(Last updated 2011-11-26)</em></p>
 
 <p>
 There are numerous how-tos on the web for installing a Debian chroot onto
 a smartphone running Android, but most of them either give you an image
 to install on your phone (which doesn't teach you anything) or have you
 set up the Debian system on your desktop and copy it to the phone.
-Neither of these options appeal to me, so I've done it my own way and
+Neither of these options appeals to me, so I've done it my own way and
 written this document to light the way for others, too.
 </p>
 
@@ -40,13 +40,31 @@ Assumptions made:
 <li>
 You have an Android smartphone with access to a root shell via SSH. I run
 <a href="http://www.cyanogenmod.com/">CyanogenMod 7.1</a> on my Galaxy S
-II, but any Android system with root SSH access will do.
+II, but any Android system with root SSH access will do, provided it has
+the following utilities:
+  <ul>
+  <li><tt>cat</tt></li>
+  <li><tt>chroot</tt></li>
+  <li><tt>dd</tt></li>
+  <li><tt>ln</tt></li>
+  <li><tt>mkdir</tt></li>
+  <li><tt>mke2fs</tt></li>
+  <li><tt>mount</tt></li>
+  <li><tt>tar</tt></li>
+  <li><tt>wget</tt> (used by <tt>cdebootstrap</tt>)</li>
+  </ul>
+If you don't have these utilities available to you, you will either need
+to find a way of installing them, or else find alternative ways of
+performing some of the steps in this how-to. Doing either is outside the
+scope of this how-to, but most of these utilities are provided by
+<tt>busybox</tt> on my device, so installing <tt>busybox</tt> should get
+you most of the way there.
 </li>
 <li>
 You have a reasonably fast and high-capacity Internet connection
 available on your Android phone. I will not be held responsible for any
 excess usage charges you incur on your mobile Internet package while
-downloading Debian onto your phone. ;)
+downloading Debian onto your phone. ;-)
 </li>
 <li>
 You have a basic understanding of Debian and its packaging system. This
@@ -57,8 +75,9 @@ this method probably isn't for you.
 </ul>
 
 <p>
-If not all of these assumptions are true, please don't contact me if
-something doesn't go right for you when following this how-to.
+If not all of these assumptions are true, please don't contact me just to
+complain if something doesn't go right for you when following this
+how-to. Of course, alternative suggestions are welcome!
 </p>
 
 <h2>Preparation</h2>
@@ -77,10 +96,11 @@ So, to install <tt>cdebootstrap</tt>:
 <ul>
 <li>
 Download the <a href="http://packages.debian.org/sid/cdebootstrap-static">cdebootstrap-static</a>
-package for your architecture. Both armel and armhf packages should work
-on recent Android phones; if you have an older phone, you may need to
-stick with armel. I'll be using armhf in this tutorial, but you are free
-to choose whichever architecture suits you best.
+package for your architecture. Both <tt>armel</tt> and <tt>armhf</tt>
+packages should work on recent Android phones; if you have an older
+phone, you may need to stick with <tt>armel</tt>. I'll be using
+<tt>armhf</tt> in this tutorial, but you are free to choose whichever
+architecture suits you best.
 </li>
 <li>
 Now, copy the files needed for <tt>cdebootstrap</tt> to work across to
@@ -98,7 +118,7 @@ $ mkdir /tmp/cdebootstrap && cd /tmp/cdebootstrap<br>
 $ ar x /path/to/cdebootstrap-static_0.5.8+b1_armhf.deb data.tar.gz<br>
 $ tar xzOf data.tar.gz ./usr/lib/cdebootstrap/cdebootstrap_0.5.8+b1_armhf.tar.gz | ssh root@$PHONE 'tar xzC /data/local/bin/'
 </code>
-Obviously, replace <tt>$PHONE</tt> with the hostname of your phone.
+Remember to replace <tt>$PHONE</tt> with the hostname of your phone.
 </li>
 <li>
 Unfortunately, the version of <tt>cdebootstrap</tt> included in the
@@ -133,7 +153,7 @@ The easiest way to set up a file system is to simply create a file in
 larger than 2 GiB, the FAT file system it lives on will complain and you
 will lose the image next time you reboot. This happened to me the first
 time I tried it, and I hadn't made a backup, so I had to do it all over
-again. :(
+again. :-(
 </p>
 
 <p>
@@ -145,6 +165,7 @@ So, ssh to your phone, and run the following commands:
 # mke2fs -Fj /mnt/sdcard/debian.img<br>
 # mkdir /debian<br>
 # mount -t ext3 -o noatime,errors=remount-ro /mnt/sdcard/debian.img /debian
+# for fs in /dev /proc /sys; do mount -o bind "$fs" "/debian$fs"; done
 </code>
 
 <p>
@@ -164,11 +185,15 @@ Now comes the fun bit, where we actually set up a Debian system. Still on
 your phone, run <tt>cdebootstrap</tt> to set up a file system tree in
 <tt>/debian</tt>. You may want to tweak the options below; I'm using
 <tt>ftp.debian-ports.org</tt> as my mirror because (at the time of
-writing) the armhf architecture is not yet fully integrated into the
-official archive. If you're using armel, or if you happen to live in the
-future, you can use your normal Debian mirror for this. Obviously, feel
-free to replace <tt>unstable</tt> with whichever suite you want to
-install.
+writing) the <tt>armhf</tt> architecture is not yet fully integrated into
+the official archive. If you're using <tt>armel</tt>, or if you happen to
+live in the future, you can use your normal Debian mirror for this.
+Don't forget to replace <tt>unstable</tt> with whichever
+<a href="http://www.debian.org/releases/">suite</a> you want to install,
+but be aware that (at the time of writing) <tt>armhf</tt> only exists in
+<tt>unstable</tt> -- if you want <tt>stable</tt> or <tt>testing</tt>, and
+you downloaded an <tt>armhf</tt> <tt>cdebootstrap</tt> binary, you will
+need to specify the <tt>-aarmel</tt> option to <tt>cdebootstrap</tt>.
 </p>
 
 <code>
@@ -202,7 +227,7 @@ Debian:
 At this point, <tt>dpkg</tt> may run into some problems. As the package
 archive changes over time and different people install different suites,
 your problems will very likely not be the same as mine, so here's where
-your familiarity with the Debian package tools comes in. ;)
+your familiarity with the Debian package tools comes in. ;-)
 </p>
 
 <p>
@@ -225,6 +250,25 @@ other remaining circular dependencies that could be fixed in a similar
 way.
 </p>
 
+<p>
+Once you have resolved a few circular dependencies and want to try again,
+it is a good idea to run:
+</p>
+
+<code>
+# dpkg --configure -a
+</code>
+
+<p>
+before telling <tt>dpkg</tt> to try installing packages again, as the
+shell glob <tt>*.deb</tt> will simply present the packages in
+alphabetical order, which is usually not a sensible order in terms of
+satisyfing dependencies. <tt>dpkg --configure -a</tt> will make sure that
+packages which are already installed (and thus don't depend on any which
+aren't installed yet) get configured before those which aren't already
+installed (and might depend on installed packages being configured).
+</p>
+
 <h2>Installing a standard Debian package set</h2>
 
 <p>
@@ -238,12 +282,36 @@ dependency issues have been resolved, and everything in
 </p>
 
 <code>
+# echo 'deb http://ftp.debian-ports.org/debian unstable main' >/etc/apt/sources.list<br>
+# echo 'nameserver 8.8.8.8' >/etc/resolv.conf<br>
+# aptitude update<br>
+# aptitude install debian-ports-archive-keyring<br>
 # aptitude install '~prequired|~pimportant|~pstandard'
 </code>
 
 <p>
 What you choose to install beyond this depends on your wants and needs,
-and how you like your Debian. ;)
+and how you like your Debian. ;-)
+</p>
+
+<h2>Initialising the Debian system at boot time</h2>
+
+<p>
+I have written a couple of simple scripts to ease getting Debian up and
+running. They come in pairs; one of them lives in Android and chroots to
+Debian, and the other lives in Debian and gets run after the chroot. You
+can find a copy of these scripts in
+<a href="http://git.steven-mcdonald.id.au/?p=android-debian.git;a=tree">Gitweb</a>,
+or clone the git repository with:
+</p>
+
+<code>
+$ git clone git://git.steven-mcdonald.id.au/android-debian.git
+</code>
+
+<p>
+For usage information, please refer to the <tt>README</tt> in that git
+repository.
 </p>
 
 </div>