Install Debian on Android (part 2)
In the last post, I’ve installed Lil’Debi to have a chroot Debian on my HTC Desire Z. Today, I’m going to use another Linux installer which is called, well, Linux Installer. You can install it from the Android Market.
Linux Installer, like Lil’Debi, is an app that will download Debian packages from a repository and create a disk image on your device. So when you mount the disk image and chroot, you get a Linux environment. The concept is the same.
Installing the Linux Installer app is fast, nothing special here.
After starting up the app, you are presented with, basically, a blank screen. First thing is to go into Settings.
Most of the default settings are just fine, you don’t need to change anything, except in a few areas:
- Use loop file: This option will use a container file to store the disk image. The installer will create a file called linux.loop, and will typically be kept on /mnt/sdcard, unless you want to put it somewhere else. Set this option if you are not sure what you do.
- Preferred distribution: Choose between Debian or Ubuntu. I chose Debian.
- Distribution version: Select the version of Linux distro (Debian or Ubuntu) you want. I chose Squeeze.
- Hostname: Set the hostname used by Linux. Basically, it is your computer name, if you are installing Linux on a computer.
- Domain name: Your domain name, if you bother at all.
- Loop file: This is the file name and path of the Linux disk image file. By default, it is placed at /mnt/sdcard/Linux.loop. If you want to put it somewhere else, just change the path here. The installer will keep reminding you, during the installation, that having the disk image file on the external storage card is not safe, blah blah …, because most people have their Android device mount the SD card as USB storage when the device is connected to a computer. If you are in that situation, always remember to umount your Linux disk before you connect your device to a computer. Some people don’t have space large enough in the internal memory, so there is no choice but to put it on external storage.
- File size: How much disk space you want to allocate for your Linux installation. If you want to install a lot of softwares, give it more space. If you have storage space to spare, that is.
- Ext version: The version of file system to be used in the Linux disk. You have the choices between ext2, ext3 and ext4.
- Allow write to /system: This option allows the installer to write scripts to your system. The installation documentation does not mention anything about this option, but you have to set it, otherwise, you will run into error because it can’t install the initialization scripts.
- Allow remount with dev/exec: Set this to true as well.
- I am registered…: If you have registered, check this and enter your username and password. You can register here.
That’s all the options that you might to customize. Everything else can be left as it is.
When you come back to the main screen, you see a button Create target loop. Press on this button to create the Linux container disk. This will take a while, depending on how large the disk is.
Once your container disk is created, you now see another button called Format loop target. Press on this button to format the disk, it will also create the file system needed to install Linux. This will take a few seconds to finish.
After formatting, you now have three buttons. The third button is Mount loop. You need to mount your Linux disk before you can do anything. So press on this button to mount it.
When you press on the Mount loop button, a warning dialog pops up, warning you that your loop file is on a removable storage, and it is unsafe, etc, etc. This is what I’ve mentioned earlier. Just press on the Override button.
Mounting the disk (it is actually a virtual disk) takes a few seconds. When the disk is mounted, you can see two buttons: Stop loop env, and Install distribution in LOOP.
Since we haven’t installed Linux yet, just press on the install button. A progress dialog pops up, showing that the installation process is going on. This will take a while, depending on your network bandwidth, so you might want to have your device connect to a power source, just in case.
The progress dialog is not showing any useful information. However, beneath it, on the upper left corner, you can see an incrementing number, showing how many packages have been downloaded and processed. This is the only assuring information, in case you are wondering whether the installer is doing anything or not.
After all necessary packages are downloaded and installed, you will see another button: Install linuxhroot script in Android. Press on this button to continue. This will create all the scripts on Android, allowing you to chroot to a real Linux environment. This will fail if you haven’t checked the Allow write to /system option in Settings.
After installing the scripts, you are done. You can now try it out, with a terminal emulator. If you don’t have a terminal emulator app, just install the Android Terminal Emulator.
Start up the terminal emulator, run the command:
Voila, you are now in a full Linux environment. If you are a Linux user, you should really feel at home here. The packaging and layout is much nicer than what we got from Lil’Debi. But the installation process is quite confusing, it could have been more automated. And the other shortcoming is that, in the chroot Linux environment, there is no easy way to access contents on the SD card. It would have been nice if the mount point of all Android external storages are also located under the
/mnt directory, this would have allowed us to access the contents directly, and it would have been so handy. If you want though, you can bind mount manually.
To access the contents of your SD card from the chroot Linux environment, you have to bind mount the /mnt/sdcard directory.
- Open the Android Terminal Emulator, then run
sucommand to get a root shell. Note that here, we are not chroot into Debian yet.
- Create the directory
/data/local/mnt/Linux/mnt/sdcard, because your Linux disk image is mounted on
/data/local/mnt/Linux, and when you chroot, you see it as your
/directory. We are creating this directory as the mount point of your SD card, so that when you are in chroot Linux, you can access the contents of your SD card from the mount point
- run the command
mount -o bind /mnt/sdcard /data/local/mnt/Linux/mnt/sdcard
- Now run the linuxchroot to get into chroot Debian. Now you should be able to access your SD card from the mount point /mnt/sdcard.
When you are done linuxing in your terminal emulator, exit it and go back to Linux Installer, and press on Stop loop env to umount your Linux disk. In the next installment, we are going to install other software and have fun with it.