Diferència entre revisions de la pàgina «Ubuntu on Android»

De GiLUG
Salta a: navegació, cerca
(Base for translation from spanish)
 
(Update SL4A link)
(Hi ha 29 revisions intermèdies del mateix usuari que no es mostren)
Línia 2: Línia 2:
 
----
 
----
  
<big><strong>TRANSLATION IN PROGRESS</strong></big>
+
'''Introduction:''' This is a guide to make work an Ubuntu GNU/Linux container inside an Android operating system session, and by this way have the desktop computer functionality without loosing performance. This is a very detailed guide, util for Debian and derivatives, and also useful to people who wants to create a wizard or improve the procedure.
  
'''Introducción:''' Esta es una guia para hacer funcionar un contenedor de Ubuntu GNU/Linux dentro de una sesión del sistema operativo Android, y así tener la funcionalidad de un ordenador de escritorio sin perder rendimiento. Es una guia muy detallada, tambien útil para quien quiera crear un asistente o mejorar el procedimiento.
+
'''Notes:'''
 +
* At the moment of writing this guide (november 2011), [http://en.wikipedia.org/wiki/Canonical_Ltd. Canonical] still didn't have [http://www.ubuntu.com/devices/android its announced solucion] ready, but since 2014 [https://wiki.ubuntu.com/Touch/Porting they follow Cyanogenmod strategy and with more success]. The best working version for the default desktop (Unity) is the 12.04 (Precise)
 +
* The total downloads proposed can reach to 1GiB of data; if you do all from the device, take care of the data plan prices that applies the internet access provider.
 +
* The possibility of using an LXC container has been explored to have a completely normal container, but [http://ubuntuforums.org/showthread.php?t=2077671 didn't worked] because of the use of [https://sourceforge.net/mailarchive/message.php?msg_id=27043843 bionic lic instead of GNU libc] by Android.
  
'''Notas:'''
 
* En el momento de escribir esta guía (noviembre del 2011), [http://es.wikipedia.org/wiki/Canonical_Ltd. Canonical] todavía no tiene lista [http://www.ubuntu.com/devices/android su propia solución]. La versión con que el escritorio predeterminado (Unity) funciona mejor es la 12.04 (Precise)
 
* El total de descargas que se propone puede llegar a 1GiB de datos; si las hace todas desde el aparato tome en cuenta la tarifa de datos que le aplica el proveedor de acceso a internet.
 
* Se ha explorado la posibilidad de utilizar un contenedor LXC para tener un contenedor completamente normal, pero [http://ubuntuforums.org/showthread.php?t=2077671 no ha funcionado] por el uso que hace Android de [https://sourceforge.net/mailarchive/message.php?msg_id=27043843 bionic lic en lugar de GNU libc].
 
 
__TOC__
 
__TOC__
  
== Permisos de superusuario (root) ==
+
== Superuser permissions (root) ==
Es un requisito tener acceso "su" para administrar el sistema operativo. Puede ver la guia [[Abrir permisos en Android]]
+
It's a requirement to have "su" access to manage the operating system. You can see the guide [[Open permissions in Android]]
  
== Acceso por terminal ==
+
== Terminal access ==
==== Terminal local ====
+
==== Local terminal ====
Siempre es recomendable tener una [http://f-droid.org/repository/browse/?fdid=jackpal.androidterm aplicación de Terminal] (que se puede obtener libremente con [[Gestor de paquetes F-Droid|F-Droid]]) disponible para poder hacer gestiones con movilidad, pero las preparaciones largas y complejas es más comodo hacerlas desde un ordenador de escritorio controlando el aparato conectado por USB.
+
It's advisable always to have a [http://f-droid.org/repository/browse/?fdid=jackpal.androidterm Terminal application] (that you can get freely with [[F-Droid package manager|F-Droid]]) available to can do managements with mobility, but it's more comfortable to do the long and complex preparations from a desktop computer, controlling the device connected through USB.
  
==== Control remoto ====
+
==== Remote control ====
En la distribución Ubuntu GNU/Linux, a partir de la versión 12.10 en el repositorio universal hay disponible el paquete '''android-tools-adb''' que permite el control remoto a un aparato con Android en ''modo de depuración USB''. Tambien hay un [https://launchpad.net/~nilarimogard/+archive/webupd8 repositorio independiente] que proporciona '''android-tools''' para anteriores versiones.
+
In the Ubuntu GNU/Linux distribution, since version 12.01 in the ''universal'' repository there is available the package '''android-tools-adb''' that allows the remote control to a device with Android in ''USB debug mode''. There is also an [https://launchpad.net/~nilarimogard/+archive/webupd8 independent repository] that provides '''android-tools''' for previous versions.
  
Para utilizar el ''Android Debug Bridge'' (ADB) debe tener el aparato en marcha, conectado por USB, y con el modo de «Depuración USB» habilitado en las opciones del desarrollador (developer) de Android
+
To use the ''Android Debug Bridge'' (ADB) you must have the device working, plugged through USB, and with the mode "USB debug" enabled in the developer preferences of Android.
  
:'''ADB por USB'''
+
:'''ADB through USB'''
* Para comprobar la conectividad:
+
* To check the connectivity:
 
  adb devices
 
  adb devices
(debe mostrar una «lista» con un identificador raro que diga que es un dispositivo; device)
+
(must show a "list" with a rare identifier that says it's a device)
* Para abrir una sesión de terminal en el aparato:
+
* To open a terminal session in the device:
 
  adb shell
 
  adb shell
* Para iniciar una sesión como superusuario (root), y tener permisos de administración de Android:
+
* To start a superuser (root) session, and have Android administration permissions:
 
  su
 
  su
* Para finalizar como superusuario y después tambien cerrar la sesión de terminal:
+
* To end as superuser and after also close the terminal session:
 
  exit
 
  exit
 
  exit
 
  exit
  
:'''ADB por red'''
+
:'''ADB through network'''
Muchas conexiones por USB son poco estables (se cortan muy a menudo y te das cuenta de que escribes en tu ordenador), y en estos casos se resuelve por red (wifi). Cuando se hace esto es importante que el aparato no tenga conesión directa a internet (por ejemplo con el operador telefónico) y se trate de una comunicación por el Wifi local.
+
Many connections through USB aren't much stable (break often and you realize that are writing in your computer), and in these cases it's solved with net (Wifi). When this is done, it's important that the device hasn't direct internet connection (for example with the telephony provider) and it's working in a communication through the local Wifi.
* Desde Android, para ver los dispositivos de red que tiene activados (default... dev -->):
+
* From Android, to see the enabled network devices (default... dev -->):
 
  ip route list
 
  ip route list
* Desde Android, para ver la dirección IP de un dispositivo de red (por ejemplo '''wlan0'''):
+
* From Android, to see the IP address of a network device (for example '''wlan0'''):
 
  ifconfig wlan0
 
  ifconfig wlan0
* Para establecer desde el ordenador que la comunicación será via red (por ejemplo a la IP 192.168.1.122):
+
* From the computer, to set the communication to be through network (for example to the IP 192.168.1.122):
 
  adb connect 192.168.1.122
 
  adb connect 192.168.1.122
* Para abrir una sesión de terminal en el aparato:
+
* To open a terminal session in the device:
 
  adb shell
 
  adb shell
* Para iniciar una sesión como superusuario (root) y tener permisos de administración de Android:
+
* To start a superuser (root) session, and have Android administration permissions:
 
  su
 
  su
* Para finalizar como superusuario y tambien cerrar la sesión de terminal:
+
* To end as superuser and after also close the terminal session:
 
  exit
 
  exit
 
  exit
 
  exit
  
:'''Notas adicionales'''
+
:'''Additional notes'''
* En esta guia, en donde se indican instrucciones escritas es para ejecutar en una ventana de terminal local o remoto.
+
* In this guide, where written commands are indicated, they are to be run in a local or remote terminal window.
* Si obtiene mensajes de tipo «Operation not permitted» suele ser porque no ha iniciado como superusuario (su)
+
* If you get messages as "Operation not permitted" , it's often because you didn't begin as superuser (su)
  
== Comprobar las herramientas disponibles ==
+
== Chech the available tools ==
En un terminal compruebe esta instrucción:
+
In a terminal check this command:
 
  chroot
 
  chroot
Le puede decir dos cosas: o bien la presentación de ayuda (con «''usage: chroot...''») o bien el mensahe de error «''chroot: not found''». En este último caso (''not found'') tiene una variante de Android muy recortada, y necesita reemplazarla por otra más libre como [[Reemplazar Android por CyanogenMod|CyanogenMod]] o [http://replicant.us/ Replicant]. Otras alternativas más técnicas son: [[Superponer directorios sobre Android]] o [https://wiki.ubuntu.com/ARM/OmapDesktopInstall Formatear una targeta de memoria].
+
It can answer two things: the help presentatiom (with "''usage: chroot...''") or the error message "''chroot: not found''". In this last case (''not found'') you have an Android variant very clipped, and you need to replace it for another one more free such as [[Replace Android for CyanogenMod|CyanogenMod]] or [http://replicant.us/ Replicant]. Other alternatives more technical are: [[Superimpose directories over Android]] or [https://wiki.ubuntu.com/ARM/OmapDesktopInstall To format a memory card].
  
== Anotar la arquitectura ==
+
== Take note of the architecture ==
Se puede mirar qué generación de procesador utiliza Android con '''una''' de las siguientes instrucciones:
+
The processor generation used by Android can be looked with '''one''' of the following commands:
 
  uname -m
 
  uname -m
 
  cat /proc/cpuinfo
 
  cat /proc/cpuinfo
Si el procesador ARM del aparato soporta coma flotante (ARMv7 o superior, por ejemplo armv7l seria el caso), entonces se pueden utilizar paquetes «armhf» en lugar de «armel». Esto mejora la velocidad de algunos procesos.
+
If the device's ARM processor supports floating-point (ARMv7 or superior, for example armv7l matches), then you can use "armhf" instead of "armel". This enhaces some processes speed.
  
== Preparar el espacio ==
+
== Prepare the space ==
Para que funcionen los enlaces y accesos a dispositivo hace falta que el nuevo contenedor esté en una partición apropiada para GNU/Linux, como por ejemplo Ext3 o Ext4. Con la instrucción '''mount''' se puede ver el formato de cada volumen, y con esta sintaxis se ve muy claro:
+
To allow working of the links and device accesses is needed that the new container resides in a properly partition for GNU/Linux, such as Ext3 or Ext4. With the '''mount''' command you can see the format of each volume, and with the following syntax it's seen very clear:
 
  mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' '
 
  mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' '
Y se puede filtrar para ver sólo lo que nos interesa:
+
And it can be filtered to see only what is interesting for us:
 
  mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' ' | sed -e '/ext.$/!d'
 
  mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' ' | sed -e '/ext.$/!d'
  
Una vez vistas las rutas compatibles, debe valorar el espacio libre que hay con esta instrucción:
+
Once seen the compatible paths, you must value the free space available with this command:
 
  df
 
  df
Si en el espacio libre (Free) no se menciona la unidad de medida (100K, 100M, 100G), significa que se expresa en K (KiB). A tener en cuenta tambien que la ruta /cache funciona «como una papelera interna» y que su contenido puede ser borrado automáticamente.
+
If in the free space there isn't mention of the measurement unity (100K, 100M, 100G), this means that it's expressed in K (KiB). Care that the path /cache works as an "internal trash" and its content can be deleted automatically.
  
Necesita almenos 100MiB para una instalación elemental (''core'' solo), o hacia los 250MiB para un ''debootstrap'', pero se puede llegar a utilizar 2 o 3GiB si instala todas las grandes aplicaciones de escritorio de uso común, aparte de contyar con un poco de espacio de trabajo. Igualmente se pueden hacer instalaciones «para todos los bolsillos».
+
You need at least 100MiB for an elemental installation (only ''core''), or near 250MiB for a ''debootstrap'', but can be reached a use of 2 or 3GiB if you install all the big desktop applications of common use, and apart counting some working space. Also installations "for all the pockets" can be done.
  
Para el resto de guía supondremos que ha escogido la partición '''/data''', y entonces el nuevo sistema operativo lo pone en '''/data/ubuntu'''. Debe habilitar entonces los permisos de escritura, ejecución, dispositivos y superusuario en la partición, y crear el subdirectorio::
+
For the rest of the guide we will suppose that you choosed the partition '''/data''' , and then you put the new operating system in '''/data/ubuntu''' . Then you must enable permissions for writing, executing, devices and superuser in the partition, and create the subdirectory:
 
  mount -o remount,rw,dev,exec,suid,noatime /data
 
  mount -o remount,rw,dev,exec,suid,noatime /data
  PuntoRaiz="/data/ubuntu"
+
  RootPoint="/data/ubuntu"
  mkdir "$PuntoRaiz"
+
  mkdir "$RootPoint"
  cd "$PuntoRaiz"
+
  cd "$RootPoint"
  
== Obtener una base de sistema operativo ==
+
== Get an operating system base ==
  
Esta sería la manera de construirlo desde otro ordenador (suponiendo arquitectura para armhf) en una partición Ext2/Ext3:
+
This is the way to build from another computer (supposing the armhf architecture) in an Ext2/Ext3 partition:
 
  sudo debootstrap --verbose --arch=armhf --foreign precise precise-armhf
 
  sudo debootstrap --verbose --arch=armhf --foreign precise precise-armhf
* Para transportar el arbol de directorios de un dispositivo a otro, hay que copiarlo con permisos de superusuario, para que los atributos y propietarios de ficheros y directorios no se pierdan por el camino. Para abrir así un explorador de carpetas con Ubuntu, se puede ejecutar (Alt+F2) «'''gksudo nautilus'''».
+
* To trainsport the directory tree from a device to another, must be copied qith superuser permissions, to not loose the files and directories attributes. To open in this way a folder explorer with Ubuntu, you can execute (Alt+F2) "'''gksudo nautilus'''".
  
Pero aqui tambien proponemos la manera de hacerlo completamente desde el aparato con Android: descargando una base preparada (del web oficial) con ''sólo una'' de estas instrucciones, según la versión y variante que necesite (se publicaran más versiones en cdimage.ubuntu.com):
+
But here we also propose the way to do it completely from the Android device: downloading a prepared base (from official website) with '''only one''' of the following commands, depending on version and variant you need (more versions are published in cdimage.ubuntu.com):
  '''wget <nowiki>http://cdimage.ubuntu.com/ubuntu-core/releases/precise/release/ubuntu-core-12.04.1-core-armhf.tar.gz</nowiki>'''
+
  '''<nowiki>wget http://cdimage.ubuntu.com/ubuntu-core/releases/precise/release/ubuntu-core-12.04.2-core-armhf.tar.gz</nowiki>'''
  wget <nowiki>http://cdimage.ubuntu.com/ubuntu-core/releases/oneiric/release/ubuntu-core-11.10-core-armel.tar.gz</nowiki>
+
  <nowiki>wget http://cdimage.ubuntu.com/ubuntu-core/releases/oneiric/release/ubuntu-core-11.10-core-armel.tar.gz</nowiki>
  wget <nowiki>http://cdimage.ubuntu.com/ubuntu-core/releases/quantal/release/ubuntu-core-12.10-core-armhf.tar.gz</nowiki>
+
  <nowiki>wget http://cdimage.ubuntu.com/ubuntu-core/releases/quantal/release/ubuntu-core-12.10-core-armhf.tar.gz</nowiki>
  wget <nowiki>http://cdimage.ubuntu.com/releases/precise/release/ubuntu-12.04-preinstalled-desktop-armhf+ac100.tar.gz</nowiki>
+
  <nowiki>wget http://cdimage.ubuntu.com/releases/precise/release/ubuntu-12.04-preinstalled-desktop-armhf+ac100.tar.gz</nowiki>
  wget <nowiki>http://cdimage.ubuntu.com/releases/oneiric/release/ubuntu-11.10-preinstalled-desktop-armel+ac100.tar.gz</nowiki>
+
  <nowiki>wget http://cdimage.ubuntu.com/releases/oneiric/release/ubuntu-11.10-preinstalled-desktop-armel+ac100.tar.gz</nowiki>
Nota: Las «preinstaled» traen todo el software de una instalación típica, pero tambien elementos que hay que limpiar para arrancar el contenedor.
+
Note: The "preinstalled" ones have all the software for a typical installation, but also elements that bust be cleaned to boot the container.
  
Con el fichero descargado, toca desempaquetarlo:
+
With the file downloaded, it's the turn of unpack it:
  tar -xzf ubuntu-core-12.04.1-core-armhf.tar.gz
+
  tar -xzf ubuntu-core-12.04.2-core-armhf.tar.gz
  rm ubuntu-core-12.04.1-core-armhf.tar.gz
+
  rm ubuntu-core-12.04.2-core-armhf.tar.gz
  
== Adaptar la base ==
+
== Adjust the base ==
  
Corrija algunos enlaces dentro del directorio de la base, para adecuarlos más a la situación:
+
Correct come links in the base's directory, to adequate them to the situation:
  chmod 755 "$PuntoRaiz"
+
  chmod 755 "$RootPoint"
 
  if [ -d /acct ] ; then mkdir -p acct ; fi
 
  if [ -d /acct ] ; then mkdir -p acct ; fi
 
  cd var
 
  cd var
 
  if [ -L run ] ; then rm run ; ln -s ../run run ; fi
 
  if [ -L run ] ; then rm run ; ln -s ../run run ; fi
 
  if [ -L lock ] ; then rm lock ; ln -s ../run/lock lock ; fi
 
  if [ -L lock ] ; then rm lock ; ln -s ../run/lock lock ; fi
  cd "$PuntoRaiz"
+
  cd "$RootPoint"
  
Limpie directorios que a veces vienen con contenido para una instalación nativa:
+
Clean directories that sometimes have content for a native installation:
 
  if [ -d proc ] ; then rm -R proc/* ; fi
 
  if [ -d proc ] ; then rm -R proc/* ; fi
 
  if [ -d dev ] ; then rm -R dev/* ; fi
 
  if [ -d dev ] ; then rm -R dev/* ; fi
Línia 119: Línia 118:
 
  if [ -d var/run/dbus ] ; then rm -R var/run/dbus/* ; fi
 
  if [ -d var/run/dbus ] ; then rm -R var/run/dbus/* ; fi
  
== Montar recursos de Android ==
+
== Mount Android resources ==
  
  mount -o bind "/proc" "$PuntoRaiz/proc"
+
  mount -o bind "/proc" "$RootPoint/proc"
  mount -o bind "/dev" "$PuntoRaiz/dev"
+
  mount -o bind "/dev" "$RootPoint/dev"
  mount -o bind "/dev/pts" "$PuntoRaiz/dev/pts"
+
  mount -o bind "/dev/pts" "$RootPoint/dev/pts"
  mount -o bind "/sys" "$PuntoRaiz/sys"
+
  mount -o bind "/sys" "$RootPoint/sys"
  if [ -d /acct ] ; then mount -o bind "/acct" "$PuntoRaiz/acct" ; fi
+
  if [ -d /acct ] ; then mount -o bind "/acct" "$RootPoint/acct" ; fi
  if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$PuntoRaiz/dev/cpuctl" ; fi
+
  if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$RootPoint/dev/cpuctl" ; fi
  
Si quiere hacer disponibles las carpetas de Android, se debe que mirar qué particiones hay montadas. Se puede hacer con un simple '''mount''' o con esta instrucción que simplifica la información:
+
If you want to make Android's folders available, you must check which partitions are mounted. It can be done with a simple '''mount''' or with this command that simplifies information:
 
  mount | sed -e '/ \/mnt\//!d' | sed -e '/^\//!d' | cut -f 2,3 -d ' ' | cut -f 2- -d '/' | cut -f 1 -d ' ' | sed -e 's/^/\//g'
 
  mount | sed -e '/ \/mnt\//!d' | sed -e '/^\//!d' | cut -f 2,3 -d ' ' | cut -f 2- -d '/' | cut -f 1 -d ' ' | sed -e 's/^/\//g'
Si por ejemplo queremos montar /mnt/sdcard hacemos:
+
If, for example, you want to mount /mnt/sdcard , do the following:
  mkdir -p "$PuntoRaiz/mnt/sdcard"
+
  mkdir -p "$RootPoint/mnt/sdcard"
  mount -o bind "/mnt/sdcard" "$PuntoRaiz/mnt/sdcard"
+
  mount -o bind "/mnt/sdcard" "$RootPoint/mnt/sdcard"
  
== Entrar en el nuevo sistema y establecer servicios elementales ==
+
== Enter to the new system and set the basic services ==
Desde la incorporación del sistema de inicio de servicios Upstart, [http://gyp.blogs.balabit.com/2011/01/using-upstart-in-a-chroot/ los contenedores Chroot no inician los servicios como una instalación normal], y hay que hacerlo manualmente.
+
Since the implementation of the services starting system Upstart [http://gyp.blogs.balabit.com/2011/01/using-upstart-in-a-chroot/ the Chroot containers don't start the services as a normal installation], and it must be done manually.
  chroot "$PuntoRaiz" /bin/su
+
 
 +
  chroot "$RootPoint" /bin/su
 
  mount -a
 
  mount -a
  
Asegúrese de que figure alguna cosa montada, para que no fallen algunas utilidades:
+
Sure that appears something mounted, to don't fail some utilities:
 
  if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi
 
  if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi
  
Complete el ''debootstrap'' si es el caso, en la misma arquitectura:
+
Complete the ''debootstrap'' if it's the case, in the same architecture:
 
  if [ -x /debootstrap/debootstrap ] ; then /debootstrap/debootstrap --second-stage ; fi
 
  if [ -x /debootstrap/debootstrap ] ; then /debootstrap/debootstrap --second-stage ; fi
  
Parche para evitar error de inicio de servicios Upstart:
+
Patch to avoid Upstart services startup error:
 
  dpkg-divert --local --rename --add /sbin/initctl
 
  dpkg-divert --local --rename --add /sbin/initctl
 
  ln -s /bin/true /sbin/initctl
 
  ln -s /bin/true /sbin/initctl
  
Configure la red:
+
Configure the network:
 
  echo "nameserver 4.2.2.2" > /etc/resolv.conf
 
  echo "nameserver 4.2.2.2" > /etc/resolv.conf
 
  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
 
  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
Línia 155: Línia 155:
 
  echo "127.0.0.1 localhost" > /etc/hosts
 
  echo "127.0.0.1 localhost" > /etc/hosts
  
Compruebe si hay repositorios establecidos:
+
Check if there are repositories set:
 
  cat /etc/apt/sources.list
 
  cat /etc/apt/sources.list
Si no había nada, o los «universe» estan deshabilitados con #, escribalos con las siguientes instrucciones (ejemplo para Ubuntu 12.04, llamado «precise»):
+
If there wasn't anything, or the "universe" are disabled with #, write them with the following commands (example for Ubuntu 12.04, called "precise"):
 
  Version="precise"
 
  Version="precise"
 
  <nowiki>echo "deb http://ports.ubuntu.com/ ${Version} main universe" > /etc/apt/sources.list</nowiki>
 
  <nowiki>echo "deb http://ports.ubuntu.com/ ${Version} main universe" > /etc/apt/sources.list</nowiki>
Línia 169: Línia 169:
 
  apt-get update
 
  apt-get update
  
Instale servicios y herramientas para evitar quejas (los paquetes ''-es'' son para el idioma castellano):
+
Install services and tools to avoid bad messages (the packages ''-es'' are for castillian language):
:Nota: si aparece algún recuadro de pregunta o mensaje, se cambia de opción con el TABulador, y se pulsan los botones con el espacio, lo cual es fácil de hacer si se está trabajando con ADB desde un ordenador.
+
:Note: if appears some asking or message square, the option is changed with the TABulator key, and buttons are pressed with spacebar, thing to be easier if you are working with ADB from a computer.
 
  apt-get install dbus dbus-x11
 
  apt-get install dbus dbus-x11
 
  mkdir -p /var/run/dbus
 
  mkdir -p /var/run/dbus
 
  apt-get install language-pack-es
 
  apt-get install language-pack-es
 
  update-locale
 
  update-locale
  IdiomaPredeterminado="es_ES.UTF-8"
+
  DefaultLanguage="es_ES.UTF-8"
  export LANG="$IdiomaPredeterminado"
+
  export LANG="$DefaultLanguage"
  export LANGUAGE="$IdiomaPredeterminado"
+
  export LANGUAGE="$DefaultLanguage"
  echo "LANG=\"$IdiomaPredeterminado\"" >> /etc/default/locale
+
  echo "LANG=\"$DefaultLanguage\"" >> /etc/default/locale
  echo "LANGUAGE=\"$IdiomaPredeterminado\"" >> /etc/default/locale
+
  echo "LANGUAGE=\"$DefaultLanguage\"" >> /etc/default/locale
Inicie el servicio DBus del cual dependen muchas aplicaciones (no se puede aprovechar el de Android):
+
Start DBus service that has a lot of applications depending on (cannot benefit with Android's one):
 
  DbusPid="$(dbus-daemon --system --print-pid --fork)"
 
  DbusPid="$(dbus-daemon --system --print-pid --fork)"
  
Instale la parte básica de Ubuntu y aplique actualizaciones. Este proceso tarda bastante:
+
Install the basic part of Ubuntu and apply updates. This process takes time:
 
  apt-get install ubuntu-minimal ubuntu-standard
 
  apt-get install ubuntu-minimal ubuntu-standard
 
  apt-get upgrade
 
  apt-get upgrade
Instale escritorio y aplicaciones que le interese. Este proceso puede tardar MUCHO:
+
Install desktop and applications you are interested in. This process can take MUCH TIME:
 
  apt-get install sudo ubuntu-desktop libreoffice libreoffice-l10n-es language-pack-gnome-es
 
  apt-get install sudo ubuntu-desktop libreoffice libreoffice-l10n-es language-pack-gnome-es
(si aparece un recuadro de mensaje o pregunta, se desplaza con el TABulador, y se pulsa con el espacio).
+
(if appears some asking or message square, the option is changed with the TABulator key, and buttons are pressed with spacebar).
  
== Abrir una cuenta de usuario normal ==
+
== Open a normal user account ==
Utilizando el escritorio y aplicaciones como usuario normal (no root) mejora la seguridad y la admisión por parte de algunos elementos que lo requieren.
+
Using the desktop and applications as normal user (not root) improves the security and the admission by some elements that requires it.
 
  cp -a /etc/adduser.conf /etc/adduser.conf.bak
 
  cp -a /etc/adduser.conf /etc/adduser.conf.bak
 
  cat /etc/adduser.conf.bak | sed -e 's/^#EXTRA_GROUPS=/EXTRA_GROUPS=/g' > /etc/adduser.conf
 
  cat /etc/adduser.conf.bak | sed -e 's/^#EXTRA_GROUPS=/EXTRA_GROUPS=/g' > /etc/adduser.conf
  NombreUsuaria=usuario
+
  UserName=user
  adduser --add_extra_groups --gecos "" $NombreUsuaria
+
  adduser --add_extra_groups --gecos "" $UserName
Incluir la nueva cuenta ($NombreUsuaria) en el grupo común de usuarios y grupos de administración que haya:
+
Include the new account ($UserName) in the common user group and administration groups there is:
  usermod --append --groups users $NombreUsuaria
+
  usermod --append --groups users $UserName
  usermod --append --groups sudo $NombreUsuaria
+
  usermod --append --groups sudo $UserName
  usermod --append --groups adm $NombreUsuaria
+
  usermod --append --groups adm $UserName
  usermod --append --groups admin $NombreUsuaria
+
  usermod --append --groups admin $UserName
Crear un grupo especial en donde incluir el usuario, para que pueda abrir puertos de entrada
+
Create an special group where to include the user, to be able to open input ports
 
  addgroup --gid 3003 sockets
 
  addgroup --gid 3003 sockets
  usermod --append --groups sockets $NombreUsuaria
+
  usermod --append --groups sockets $UserName
  
== Habilitar interfaz gráfica ==
+
== Enable graphical interface ==
Aunque ya ha aparecido alguna [http://f-droid.org/repository/browse/?fdid=au.com.darkside.XServer herramienta X-Server] para utilizar aplicaciones en pantalla directamente sin control remoto, de momento exponemos el método tradicional 2011-2012 (suponiendo como ejemplo que la pantalla del aparato tiene una resolución de 1280x720):
+
Although it appeared some [http://f-droid.org/repository/browse/?fdid=au.com.darkside.XServer X-Server tool] to use applications directly in the screen without remote control, for the moment we expose the traditional method 2011-2012 (supposing in the example the device screen has a resolution of 1280x720):
 
  apt-get install xvfb x11vnc xtightvncviewer
 
  apt-get install xvfb x11vnc xtightvncviewer
 
  if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
 
  if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
Línia 213: Línia 213:
 
  chmod a+rx /tmp/xvnc.sh
 
  chmod a+rx /tmp/xvnc.sh
 
  su -l $NombreUsuaria -c /tmp/xvnc.sh
 
  su -l $NombreUsuaria -c /tmp/xvnc.sh
Se quedará esperando conexiones (verá PORT=5900). Es necesario no cerrar este terminal mientras se quiera tener Ubuntu disponible.
+
It will be waiting for connections (you will see PORT=5900). It's necessary to not close this terminal while you want to have Ubuntu available.
  
== Abrir el escritorio de Ubuntu desde Android ==
+
== Open Ubuntu desktop from Android ==
Se puede utilizar cualquier [http://f-droid.org/repository/browse/?fdid=android.androidVNC programa de control remot per VNC], que se puede encontrar fácilmente con el [[Gestor de paquetes F-Droid]].
+
Any [http://f-droid.org/repository/browse/?fdid=android.androidVNC remote control program for VNC] can be used, that can be found easily with the [[F-Droid package manager]].
  
Se conecta a la dirección '''localhost''' y con el puerto normal '''5900'''. Sin usuario (''nickname'') ni tampoco contraseña (''password''). Tiene un acceso suficientemente seguro porque sólo admitirá conexiones desde el mismo aparato (-localhost).
+
Connect to the address '''localhost''' and with the normal port '''5900'''. Without user (''nickname'') nor password. You have an enough secure access because it only will allow connections from the same device (-localhost).
  
== Salida ==
+
== Exit ==
Si quiere volver a utilizar Android es suficiente con cerrar el VNC, o símplemente minimizarlo para hacer otras cosas. Si detiene el aparato con Android no pasa nada; es como si tambien detuviera el escritorio de Ubuntu como si fuera un ordenador.
+
If you want to use Android again it's enough with closing VNC, or simply minimize to do other things. If you shutdown the device with Android don't worry; it's as you also close the Ubuntu desktop as it was a computer.
  
Si quiere detener el sistema Ubuntu sin detener ni reiniciar Android, debe salir de la sesión por el mismo escritorio de Ubuntu, igual como si lo hiciera de un ordenador normal: con el botón gráfico de detener el ordenador, pero la opción de salir como usuario. Si ve una ventana de terminal tambien cerrándola se finaliza la sesión. Con las siguientes indicaciones hará una salida completamente limpia del contenedor.
+
If you want to stop the Ubuntu system without stopping nor restarting Android, you must exit from the session in the same Ubuntu desktop, same as you do it from a normal computer: with the graphical shutdown button, but with the user logout option. If you see a terminal window, also closing it the session is closed. With the following indications you will do a completely clean exit from the container.
  
Detener servicios: En la ventana de Terminal en donde tenía el x11vnc esperando conexiones, si este todavía espera, lo puede interrumpir con {Control} + {C}. Después el resto:
+
Stopping services: In the Terminal window where you had the x11vnc waiting for connections, if it's still waiting, you can break it with {Control} + {C}. After this the rest:
 
  kill $DbusPid
 
  kill $DbusPid
 
  rm -f /var/run/dbus/pid
 
  rm -f /var/run/dbus/pid
Línia 231: Línia 231:
 
  umount -a
 
  umount -a
 
  exit
 
  exit
Si por ejemplo ha montado la carpeta de Android /mnt/sdcard :
+
If for example you mounted the Android folder /mnt/sdcard :
  umount "$PuntoRaiz/mnt/sdcard"
+
  umount "$RootPoint/mnt/sdcard"
  if [ -d /dev/cpuctl ] ; then umount "$PuntoRaiz/dev/cpuctl" ; fi
+
  if [ -d /dev/cpuctl ] ; then umount "$RootPoint/dev/cpuctl" ; fi
  if [ -d /acct ] ; then umount "$PuntoRaiz/acct" ; fi
+
  if [ -d /acct ] ; then umount "$RootPoint/acct" ; fi
  umount "$PuntoRaiz/sys"
+
  umount "$RootPoint/sys"
  umount "$PuntoRaiz/dev/pts"
+
  umount "$RootPoint/dev/pts"
  umount "$PuntoRaiz/dev"
+
  umount "$RootPoint/dev"
  umount "$PuntoRaiz/proc"
+
  umount "$RootPoint/proc"
 
  exit
 
  exit
 
  exit
 
  exit
  
== Para repetir la experiencia ==
+
== To repeat the experience ==
* Si no ha finalizado la sesión dentro de Ubuntu, símplemente puede volver a conectar con el programa-cliente de VNC.
+
* If you haven't ended the session from inside Ubuntu, you can simply connect again with the CNV client program.
* Lo mejor, está claro, es poder tener iconos directos en el escritorio de Android, tanto para montar el contenedor como para conectar con el escritorio por VNC. Este wiki agradecerá mucho las aportaciones sobre este tema.
+
* The best, of course, is to have direct icons in the Android desktop, both to mount the container and to connect to the desktop via VNC. This wiki will thank the contributions about this.
  
En otros casos, como por ejemplo que haya detenido el aparato o finalizado el contenedor Ubuntu completamente, escriba estas instrucciones en una ventana de Terminal (datos del mismo ejemplo de esta página, que hay que personalizar):
+
In other cases, such as you have stopped the device or stopped the Ubuntu container completely, write these instructions in a Terminal window (data from the same example in this page, which must be customized):
 
  su
 
  su
 
  mount -o remount,rw,dev,exec,suid,noatime /data
 
  mount -o remount,rw,dev,exec,suid,noatime /data
  PuntoRaiz="/data/ubuntu"
+
  RootPoint="/data/ubuntu"
  mount -o bind "/proc" "$PuntoRaiz/proc"
+
  mount -o bind "/proc" "$RootPoint/proc"
  mount -o bind "/dev" "$PuntoRaiz/dev"
+
  mount -o bind "/dev" "$RootPoint/dev"
  mount -o bind "/dev/pts" "$PuntoRaiz/dev/pts"
+
  mount -o bind "/dev/pts" "$RootPoint/dev/pts"
  mount -o bind "/sys" "$PuntoRaiz/sys"
+
  mount -o bind "/sys" "$RootPoint/sys"
  if [ -d /acct ] ; then mount -o bind "/acct" "$PuntoRaiz/acct" ; fi
+
  if [ -d /acct ] ; then mount -o bind "/acct" "$RootPoint/acct" ; fi
  if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$PuntoRaiz/dev/cpuctl" ; fi
+
  if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$RootPoint/dev/cpuctl" ; fi
  mount -o bind "/mnt/sdcard" "$PuntoRaiz/mnt/sdcard"
+
  mount -o bind "/mnt/sdcard" "$RootPoint/mnt/sdcard"
  chroot "$PuntoRaiz" /bin/su
+
  chroot "$RootPoint" /bin/su
 
  mount -a
 
  mount -a
 
  if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi
 
  if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi
 
  DbusPid="$(dbus-daemon --system --print-pid --fork)"
 
  DbusPid="$(dbus-daemon --system --print-pid --fork)"
  NombreUsuaria=usuari
+
  UserName=usuari
 
  if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
 
  if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
 
  MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 1/1"
 
  MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 1/1"
 
  echo "x11vnc $MoreOptions -env FD_GEOM=${1:-1280x720x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
 
  echo "x11vnc $MoreOptions -env FD_GEOM=${1:-1280x720x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
 
  chmod a+rx /tmp/xvnc.sh
 
  chmod a+rx /tmp/xvnc.sh
  su -l $NombreUsuaria -c /tmp/xvnc.sh
+
  su -l $UserName -c /tmp/xvnc.sh
Conectar con la aplicación-cliente de VNC a la dirección '''localhost''' y con el puerto normal '''5900'''. Sin usuario ni tampoco contraseña.
+
Connect with the VNC client application to the address '''localhost''' and with the normal port '''5900'''. Without user nor password.
  
Evidentemente lo mejor es tener las instrucciones en scripts (ficheros de texto ejecutables): del primer «mount» hasta el «chroot» en un script en Android (por ejemplo /system/bin/m) y el resto en un script en Ubuntu (por ejemplo /usr/local/bin/x). De esta forma, en un terminal ya sólo habría que hacer:
+
Obviously the best is to have the commands in scripts (executable text files): from the first "mount" until the "chroot" in an Android script (for example /system/bin/m) and the rest in a script in UBuntu (for example /usr/local/bin/x). By this way, the only steps in a terminal could be:
 
  su
 
  su
 
  m
 
  m
 
  x
 
  x
Y para hacerlo en una sola instrucción, puede cambiar la instrucción '''chroot "$PuntoRaiz" /bin/su''' por '''chroot "$PuntoRaiz" /bin/su -c /usr/local/bin/x''' , y entonces tambien un script en Android (/system/bin/u) que contenga una sola línea con '''su -c m''' . Con esto, inicia el servicio con una sola instrucción en el terminal:
+
And to do is in a single command, you can change the line '''chroot "$RootPoint" /bin/su''' by '''chroot "$RootPoint" /bin/su -c /usr/local/bin/x''' , and then also write a script in Android (/system/bin/u) that contents a single line with '''su -c m''' . With this, the service starts with a single command in the terminal:
 
  u
 
  u
(recuerde a dar permiso de ejecución a los scripts, por ejemplo con: chmod 755 /system/bin/u )
+
(remember to give execution permission to the scripts, for example with: chmod 755 /system/bin/u )
  
==== Lanzadores en el escritorio de Android ====
+
==== Launchers in Android desktop ====
Con el [http://code.google.com/p/android-scripting/ SL4A] puede preparar un programillo Bash (''Shell script'') que tambien se puede ejecutar con mostrar la ventana de terminal (background). Con esto puede sustituir «u» que hemos puesto de ejemplo, creando un ''script'' llamado por ejemplo '''Ubuntu.sh''' y con contenido '''su -c m'''
+
With [https://github.com/kuri65536/sl4a/releases SL4A] you can prepare a Bash script (''Shell script'') that can also be run without showing the terminal window (in background). With this you can replace "u" that we have written as an example, creating a ''script'' called for example '''Ubuntu.sh''' and with content '''su -c m'''
  
Para crear un icono en el escritorio (Home) que lance la Ubuntu de fondo, oprima el fondo del escritorio durante un rato hasta que abra un menú de opciones, y elija crear un acceso/lanzador personalizado (''Custom shortcut''). Seleccione la actividad "Scripts" que lleva el icono de los ojos iluminados (SL4A), seleccione su programillo "Ubuntu.sh" y elija que se inicie de fondo/background (botón con engranaje). Le puede acabar personalizando el título como «Ubuntu 0» y acepta.
+
To crate an icon on the desktop (Home) to launch Ubuntu in background, press the desktop background during some time until it opens an options menu, and select to create a customized link/launcher (''Custom shortcut''). Select the activity "Scripts" that has the shining-eyes icon (LS4A), select your program "Ubuntu.sh" and select that it starts in background (gear button). You can finish customizing a title as "Ubuntu 0" and press Ok.
  
La misma técnica puede utilizar para crear un lanzador que conecte directamente por VNC: pulsando largamente en el fondo del escritorio, Lanzador personalizado (''Custom shortcut''), elegir actividad (''Pick your activity''), Conexión VNC, elegir la de «localhost:5900», póngale un título como «Ubuntu 1» y acepte.
+
You can use the same technique to create a launcher that connects directly through VNC: long-pressing on the desktop background, Customized launcher (''Custom shortcut''), select activity (''Pick your activity''), VNC connection, select the "localhost:5900", give it a title as "Ubuntu 1" and Ok.
  
Con estos dos lanzadores, ya tiene la Ubuntu en 2 pulsaciones: primero al icono SL4A que trabaja de fondo, y después al icono de VNC que le conecta. '''No lance nuévamente el icono de SL4A si no se ha asegurado de que está detenido'''. Puede conectar y desconectar tantas veces como quiera mientras la Ubuntu esté arrancada de fondo con SL4A.
+
With these 2 launchers, you already have Ubuntu in 2 taps: first to the SL4A icon that works in background, and after the VNC icon that connects. '''Don't launch again the SL4A icon if you aren't sure that it's stopped'''. You can connect and disconnect as many times as you want, while Ubuntu is launched in background with SL4A.
  
Un problema detectado: Si se le abre el menú pero no le aparece la opción de crear lanzador/acceso/shortcut en el escritorio (sólo ofrece cambiar el fondo), seguramente está utilizando el escritorio «Trebuchet» que tiene alguna carencia. Puede instalar el gestor de escritorio [http://f-droid.org/repository/browse/?fdid=org.adw.launcher AnDerWeb] para arreglarlo, pero no aprovecha los iconos que tuviera colocados con el anterior.
+
A known issue: If the menu opens but the option to create a launcher/link/shortcut doesn't appear in the desktop (it only offers to change background), you are probably using the "Trebuchet" desktop that lacks some feature. You can install the desktop manager [http://f-droid.org/repository/browse/?fdid=org.adw.launcher AnDerWeb] to fix it, but it doesn't maintain the previously set icons.
  
== Como ver las cosas más grandes ==
+
== How to see the things bigger ==
Hay aparatos de bolsillo que tienen una gran densidad de puntos en una pantalla táctil, es decir, mucha resolución en una pantalla tan pequeña. Aprovechar toda la resolución en estas situaciones hace difícil acertar los elementos del escritorio con el dedo.
+
There are pocket devices that have a high point density in a touchscreen, that is, much resolution in a so small screen. Taking all the resolution in these situations makes difficult to hit the desktop elements with a finger.
  
Si en el ejemplo de esta guía queremos ver las cosas el ''doble'' de grandes, cambiamos la resolución de 1280x720 por 640x360, y la escala de 1/1 por 2/1. Esto significa dividir por 2 la resolución y aumentar la pequeña imagen al soble para que igualmente llene la pantalla. La operación se puede hacer en cualquier proporción; aquí un ejemplo para hacerlo a dos tercios (que implica un 50% de aumento):
+
If in this guide example you want to see the things ''twice'' larger, change the resolution of 1280x720 by 640x360, and the scale of 1/1 by 2/1. This means to divide by 2 the resolution and increasing the small image to double to it fills the screen. The operation can be done in any proportion; here an example to do it at two thirds (that implies a 50% of growth):
 
  MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 3/2"
 
  MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 3/2"
 
  echo "x11vnc $MoreOptions -env FD_GEOM=${1:-853x480x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
 
  echo "x11vnc $MoreOptions -env FD_GEOM=${1:-853x480x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
 
1280/3x2 = 853 ; 720/3x2 = 480 ; escala 3/2
 
1280/3x2 = 853 ; 720/3x2 = 480 ; escala 3/2
 +
 +
== Other sources ==
 +
* [https://fsfe.org/campaigns/android/liberate.en.html Liberate your device] (Free Software Foundation)
 +
* [https://wiki.ubuntu.com/Touch/Install#Instructions_for_flashing_a_phone_or_tablet_device_with_Ubuntu Instructions for flashing a phone or tablet device with Ubuntu]
 +
* [https://wiki.ubuntu.com/Touch/Porting Ubuntu porting guide] (touch)
 +
* [https://help.ubuntu.com/community/PortableDevices/Android Android devices with some Ubuntu use]

Revisió del 17:29, 11 abr 2017

Català - Castellano - English


Introduction: This is a guide to make work an Ubuntu GNU/Linux container inside an Android operating system session, and by this way have the desktop computer functionality without loosing performance. This is a very detailed guide, util for Debian and derivatives, and also useful to people who wants to create a wizard or improve the procedure.

Notes:

Superuser permissions (root)

It's a requirement to have "su" access to manage the operating system. You can see the guide Open permissions in Android

Terminal access

Local terminal

It's advisable always to have a Terminal application (that you can get freely with F-Droid) available to can do managements with mobility, but it's more comfortable to do the long and complex preparations from a desktop computer, controlling the device connected through USB.

Remote control

In the Ubuntu GNU/Linux distribution, since version 12.01 in the universal repository there is available the package android-tools-adb that allows the remote control to a device with Android in USB debug mode. There is also an independent repository that provides android-tools for previous versions.

To use the Android Debug Bridge (ADB) you must have the device working, plugged through USB, and with the mode "USB debug" enabled in the developer preferences of Android.

ADB through USB
  • To check the connectivity:
adb devices

(must show a "list" with a rare identifier that says it's a device)

  • To open a terminal session in the device:
adb shell
  • To start a superuser (root) session, and have Android administration permissions:
su
  • To end as superuser and after also close the terminal session:
exit
exit
ADB through network

Many connections through USB aren't much stable (break often and you realize that are writing in your computer), and in these cases it's solved with net (Wifi). When this is done, it's important that the device hasn't direct internet connection (for example with the telephony provider) and it's working in a communication through the local Wifi.

  • From Android, to see the enabled network devices (default... dev -->):
ip route list
  • From Android, to see the IP address of a network device (for example wlan0):
ifconfig wlan0
  • From the computer, to set the communication to be through network (for example to the IP 192.168.1.122):
adb connect 192.168.1.122
  • To open a terminal session in the device:
adb shell
  • To start a superuser (root) session, and have Android administration permissions:
su
  • To end as superuser and after also close the terminal session:
exit
exit
Additional notes
  • In this guide, where written commands are indicated, they are to be run in a local or remote terminal window.
  • If you get messages as "Operation not permitted" , it's often because you didn't begin as superuser (su)

Chech the available tools

In a terminal check this command:

chroot

It can answer two things: the help presentatiom (with "usage: chroot...") or the error message "chroot: not found". In this last case (not found) you have an Android variant very clipped, and you need to replace it for another one more free such as CyanogenMod or Replicant. Other alternatives more technical are: Superimpose directories over Android or To format a memory card.

Take note of the architecture

The processor generation used by Android can be looked with one of the following commands:

uname -m
cat /proc/cpuinfo

If the device's ARM processor supports floating-point (ARMv7 or superior, for example armv7l matches), then you can use "armhf" instead of "armel". This enhaces some processes speed.

Prepare the space

To allow working of the links and device accesses is needed that the new container resides in a properly partition for GNU/Linux, such as Ext3 or Ext4. With the mount command you can see the format of each volume, and with the following syntax it's seen very clear:

mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' '

And it can be filtered to see only what is interesting for us:

mount | cut -f 1-5 -d ' ' | sed -e 's/ on / /g' | sed -e 's/ type / /g' | cut -f 2-3 -d ' ' | sed -e '/ext.$/!d'

Once seen the compatible paths, you must value the free space available with this command:

df

If in the free space there isn't mention of the measurement unity (100K, 100M, 100G), this means that it's expressed in K (KiB). Care that the path /cache works as an "internal trash" and its content can be deleted automatically.

You need at least 100MiB for an elemental installation (only core), or near 250MiB for a debootstrap, but can be reached a use of 2 or 3GiB if you install all the big desktop applications of common use, and apart counting some working space. Also installations "for all the pockets" can be done.

For the rest of the guide we will suppose that you choosed the partition /data , and then you put the new operating system in /data/ubuntu . Then you must enable permissions for writing, executing, devices and superuser in the partition, and create the subdirectory:

mount -o remount,rw,dev,exec,suid,noatime /data
RootPoint="/data/ubuntu"
mkdir "$RootPoint"
cd "$RootPoint"

Get an operating system base

This is the way to build from another computer (supposing the armhf architecture) in an Ext2/Ext3 partition:

sudo debootstrap --verbose --arch=armhf --foreign precise precise-armhf
  • To trainsport the directory tree from a device to another, must be copied qith superuser permissions, to not loose the files and directories attributes. To open in this way a folder explorer with Ubuntu, you can execute (Alt+F2) "gksudo nautilus".

But here we also propose the way to do it completely from the Android device: downloading a prepared base (from official website) with only one of the following commands, depending on version and variant you need (more versions are published in cdimage.ubuntu.com):

wget http://cdimage.ubuntu.com/ubuntu-core/releases/precise/release/ubuntu-core-12.04.2-core-armhf.tar.gz
wget http://cdimage.ubuntu.com/ubuntu-core/releases/oneiric/release/ubuntu-core-11.10-core-armel.tar.gz
wget http://cdimage.ubuntu.com/ubuntu-core/releases/quantal/release/ubuntu-core-12.10-core-armhf.tar.gz
wget http://cdimage.ubuntu.com/releases/precise/release/ubuntu-12.04-preinstalled-desktop-armhf+ac100.tar.gz
wget http://cdimage.ubuntu.com/releases/oneiric/release/ubuntu-11.10-preinstalled-desktop-armel+ac100.tar.gz

Note: The "preinstalled" ones have all the software for a typical installation, but also elements that bust be cleaned to boot the container.

With the file downloaded, it's the turn of unpack it:

tar -xzf ubuntu-core-12.04.2-core-armhf.tar.gz
rm ubuntu-core-12.04.2-core-armhf.tar.gz

Adjust the base

Correct come links in the base's directory, to adequate them to the situation:

chmod 755 "$RootPoint"
if [ -d /acct ] ; then mkdir -p acct ; fi
cd var
if [ -L run ] ; then rm run ; ln -s ../run run ; fi
if [ -L lock ] ; then rm lock ; ln -s ../run/lock lock ; fi
cd "$RootPoint"

Clean directories that sometimes have content for a native installation:

if [ -d proc ] ; then rm -R proc/* ; fi
if [ -d dev ] ; then rm -R dev/* ; fi
if [ -d sys ] ; then rm -R sys/* ; fi
if [ -d var/run/dbus ] ; then rm -R var/run/dbus/* ; fi

Mount Android resources

mount -o bind "/proc" "$RootPoint/proc"
mount -o bind "/dev" "$RootPoint/dev"
mount -o bind "/dev/pts" "$RootPoint/dev/pts"
mount -o bind "/sys" "$RootPoint/sys"
if [ -d /acct ] ; then mount -o bind "/acct" "$RootPoint/acct" ; fi
if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$RootPoint/dev/cpuctl" ; fi

If you want to make Android's folders available, you must check which partitions are mounted. It can be done with a simple mount or with this command that simplifies information:

mount | sed -e '/ \/mnt\//!d' | sed -e '/^\//!d' | cut -f 2,3 -d ' ' | cut -f 2- -d '/' | cut -f 1 -d ' ' | sed -e 's/^/\//g'

If, for example, you want to mount /mnt/sdcard , do the following:

mkdir -p "$RootPoint/mnt/sdcard"
mount -o bind "/mnt/sdcard" "$RootPoint/mnt/sdcard"

Enter to the new system and set the basic services

Since the implementation of the services starting system Upstart the Chroot containers don't start the services as a normal installation, and it must be done manually.

chroot "$RootPoint" /bin/su
mount -a

Sure that appears something mounted, to don't fail some utilities:

if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi

Complete the debootstrap if it's the case, in the same architecture:

if [ -x /debootstrap/debootstrap ] ; then /debootstrap/debootstrap --second-stage ; fi

Patch to avoid Upstart services startup error:

dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

Configure the network:

echo "nameserver 4.2.2.2" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
echo "127.0.0.1 localhost" > /etc/hosts

Check if there are repositories set:

cat /etc/apt/sources.list

If there wasn't anything, or the "universe" are disabled with #, write them with the following commands (example for Ubuntu 12.04, called "precise"):

Version="precise"
echo "deb http://ports.ubuntu.com/ ${Version} main universe" > /etc/apt/sources.list
echo "# deb-src http://ports.ubuntu.com/ ${Version} main universe" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "deb http://ports.ubuntu.com/ ${Version}-updates main universe" >> /etc/apt/sources.list
echo "# deb-src http://ports.ubuntu.com/ ${Version}-updates main universe" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "deb http://ports.ubuntu.com/ ${Version}-security main universe" >> /etc/apt/sources.list
echo "# deb-src http://ports.ubuntu.com/ ${Version}-security main universe" >> /etc/apt/sources.list
apt-get update

Install services and tools to avoid bad messages (the packages -es are for castillian language):

Note: if appears some asking or message square, the option is changed with the TABulator key, and buttons are pressed with spacebar, thing to be easier if you are working with ADB from a computer.
apt-get install dbus dbus-x11
mkdir -p /var/run/dbus
apt-get install language-pack-es
update-locale
DefaultLanguage="es_ES.UTF-8"
export LANG="$DefaultLanguage"
export LANGUAGE="$DefaultLanguage"
echo "LANG=\"$DefaultLanguage\"" >> /etc/default/locale
echo "LANGUAGE=\"$DefaultLanguage\"" >> /etc/default/locale

Start DBus service that has a lot of applications depending on (cannot benefit with Android's one):

DbusPid="$(dbus-daemon --system --print-pid --fork)"

Install the basic part of Ubuntu and apply updates. This process takes time:

apt-get install ubuntu-minimal ubuntu-standard
apt-get upgrade

Install desktop and applications you are interested in. This process can take MUCH TIME:

apt-get install sudo ubuntu-desktop libreoffice libreoffice-l10n-es language-pack-gnome-es

(if appears some asking or message square, the option is changed with the TABulator key, and buttons are pressed with spacebar).

Open a normal user account

Using the desktop and applications as normal user (not root) improves the security and the admission by some elements that requires it.

cp -a /etc/adduser.conf /etc/adduser.conf.bak
cat /etc/adduser.conf.bak | sed -e 's/^#EXTRA_GROUPS=/EXTRA_GROUPS=/g' > /etc/adduser.conf
UserName=user
adduser --add_extra_groups --gecos "" $UserName

Include the new account ($UserName) in the common user group and administration groups there is:

usermod --append --groups users $UserName
usermod --append --groups sudo $UserName
usermod --append --groups adm $UserName
usermod --append --groups admin $UserName

Create an special group where to include the user, to be able to open input ports

addgroup --gid 3003 sockets
usermod --append --groups sockets $UserName

Enable graphical interface

Although it appeared some X-Server tool to use applications directly in the screen without remote control, for the moment we expose the traditional method 2011-2012 (supposing in the example the device screen has a resolution of 1280x720):

apt-get install xvfb x11vnc xtightvncviewer
if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 1/1"
echo "x11vnc $MoreOptions -env FD_GEOM=${1:-1280x720x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
chmod a+rx /tmp/xvnc.sh
su -l $NombreUsuaria -c /tmp/xvnc.sh

It will be waiting for connections (you will see PORT=5900). It's necessary to not close this terminal while you want to have Ubuntu available.

Open Ubuntu desktop from Android

Any remote control program for VNC can be used, that can be found easily with the F-Droid package manager.

Connect to the address localhost and with the normal port 5900. Without user (nickname) nor password. You have an enough secure access because it only will allow connections from the same device (-localhost).

Exit

If you want to use Android again it's enough with closing VNC, or simply minimize to do other things. If you shutdown the device with Android don't worry; it's as you also close the Ubuntu desktop as it was a computer.

If you want to stop the Ubuntu system without stopping nor restarting Android, you must exit from the session in the same Ubuntu desktop, same as you do it from a normal computer: with the graphical shutdown button, but with the user logout option. If you see a terminal window, also closing it the session is closed. With the following indications you will do a completely clean exit from the container.

Stopping services: In the Terminal window where you had the x11vnc waiting for connections, if it's still waiting, you can break it with {Control} + {C}. After this the rest:

kill $DbusPid
rm -f /var/run/dbus/pid
if [ "$(mount | grep -e "/selinux")" != "" ] ; then umount /selinux ; fi
umount -a
exit

If for example you mounted the Android folder /mnt/sdcard :

umount "$RootPoint/mnt/sdcard"
if [ -d /dev/cpuctl ] ; then umount "$RootPoint/dev/cpuctl" ; fi
if [ -d /acct ] ; then umount "$RootPoint/acct" ; fi
umount "$RootPoint/sys"
umount "$RootPoint/dev/pts"
umount "$RootPoint/dev"
umount "$RootPoint/proc"
exit
exit

To repeat the experience

  • If you haven't ended the session from inside Ubuntu, you can simply connect again with the CNV client program.
  • The best, of course, is to have direct icons in the Android desktop, both to mount the container and to connect to the desktop via VNC. This wiki will thank the contributions about this.

In other cases, such as you have stopped the device or stopped the Ubuntu container completely, write these instructions in a Terminal window (data from the same example in this page, which must be customized):

su
mount -o remount,rw,dev,exec,suid,noatime /data
RootPoint="/data/ubuntu"
mount -o bind "/proc" "$RootPoint/proc"
mount -o bind "/dev" "$RootPoint/dev"
mount -o bind "/dev/pts" "$RootPoint/dev/pts"
mount -o bind "/sys" "$RootPoint/sys"
if [ -d /acct ] ; then mount -o bind "/acct" "$RootPoint/acct" ; fi
if [ -d /dev/cpuctl ] ; then mount -o bind "/dev/cpuctl" "$RootPoint/dev/cpuctl" ; fi
mount -o bind "/mnt/sdcard" "$RootPoint/mnt/sdcard"
chroot "$RootPoint" /bin/su
mount -a
if [ "$(mount)" = "" ] ; then mount -o bind /selinux /selinux ; fi
DbusPid="$(dbus-daemon --system --print-pid --fork)"
UserName=usuari
if [ "$Copyrect" = "" ] ; then CrOptions="-nowirecopyrect -noscrollcopyrect" ; else CrOptions="-ncache" ; fi
MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 1/1"
echo "x11vnc $MoreOptions -env FD_GEOM=${1:-1280x720x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh
chmod a+rx /tmp/xvnc.sh
su -l $UserName -c /tmp/xvnc.sh

Connect with the VNC client application to the address localhost and with the normal port 5900. Without user nor password.

Obviously the best is to have the commands in scripts (executable text files): from the first "mount" until the "chroot" in an Android script (for example /system/bin/m) and the rest in a script in UBuntu (for example /usr/local/bin/x). By this way, the only steps in a terminal could be:

su
m
x

And to do is in a single command, you can change the line chroot "$RootPoint" /bin/su by chroot "$RootPoint" /bin/su -c /usr/local/bin/x , and then also write a script in Android (/system/bin/u) that contents a single line with su -c m . With this, the service starts with a single command in the terminal:

u

(remember to give execution permission to the scripts, for example with: chmod 755 /system/bin/u )

Launchers in Android desktop

With SL4A you can prepare a Bash script (Shell script) that can also be run without showing the terminal window (in background). With this you can replace "u" that we have written as an example, creating a script called for example Ubuntu.sh and with content su -c m

To crate an icon on the desktop (Home) to launch Ubuntu in background, press the desktop background during some time until it opens an options menu, and select to create a customized link/launcher (Custom shortcut). Select the activity "Scripts" that has the shining-eyes icon (LS4A), select your program "Ubuntu.sh" and select that it starts in background (gear button). You can finish customizing a title as "Ubuntu 0" and press Ok.

You can use the same technique to create a launcher that connects directly through VNC: long-pressing on the desktop background, Customized launcher (Custom shortcut), select activity (Pick your activity), VNC connection, select the "localhost:5900", give it a title as "Ubuntu 1" and Ok.

With these 2 launchers, you already have Ubuntu in 2 taps: first to the SL4A icon that works in background, and after the VNC icon that connects. Don't launch again the SL4A icon if you aren't sure that it's stopped. You can connect and disconnect as many times as you want, while Ubuntu is launched in background with SL4A.

A known issue: If the menu opens but the option to create a launcher/link/shortcut doesn't appear in the desktop (it only offers to change background), you are probably using the "Trebuchet" desktop that lacks some feature. You can install the desktop manager AnDerWeb to fix it, but it doesn't maintain the previously set icons.

How to see the things bigger

There are pocket devices that have a high point density in a touchscreen, that is, much resolution in a so small screen. Taking all the resolution in these situations makes difficult to hit the desktop elements with a finger.

If in this guide example you want to see the things twice larger, change the resolution of 1280x720 by 640x360, and the scale of 1/1 by 2/1. This means to divide by 2 the resolution and increasing the small image to double to it fills the screen. The operation can be done in any proportion; here an example to do it at two thirds (that implies a 50% of growth):

MoreOptions="-create -localhost -xrandr $CrOptions -rfbport 5900 -nopw -forever -permitfiletransfer -nevershared -scale 3/2"
echo "x11vnc $MoreOptions -env FD_GEOM=${1:-853x480x16} -afteraccept 'x-session-manager &' -logfile '.x11vnc.log'" > /tmp/xvnc.sh

1280/3x2 = 853 ; 720/3x2 = 480 ; escala 3/2

Other sources