Posté(e) 17 mars 201214 a Salut, je partage un tuto que je viens d'ecrire. Il en existe probablement une centaine déja de tuto de ce style mais je voulais comprendre et noter mes etapes. Dans android et le market, il me manquait vraiment trop d'outils de base du monde gnu (la couche applicative qui tourne sur Ubuntu, debian, Fedora, etc..). Notamment pour moi des langages de développement (perl, python,..), serveur web robuste, .. des centaines de choses en fait. Attention, ce tuto ne comprend pas la partie XWindow donc le resultat sera "tout en console". Pour avoir un vrai système graphique avec gestion parfaite du touchpad et que le clavier qu'on a dans android apparaisse aux bons moment, c'est probablement pas aussi direct et spécifique à chaque telephone/tablette. Il faut un ordi qui a debootstrap (Ubuntu et Debian l'ont, je conseille toujours Debian) Ce tuto permet aussi d'installer une ubuntu, il faut remplacer 'sid' par la distro qu'on veut. Distributions disponibles: breezy dapper edgy etch feisty gutsy hardy hoary hoary.buildd intrepid jaunty karmic lenny lucid maverick natty oldstable oneiric potato precise sarge sarge.buildd sarge.fakechroot sid squeeze stable testing unstable warty warty.buildd wheezy woody Les explications sont en anglais mais les commandes sont internationales :) Si vous rencontrez des problèmes, je pourrai essayer d'y repondre. On the device, you will need a kernel with loop support (otherwise, you need a standalone ext2/3/4 partition) and gnu/posix commands , it can be through busybox. You need at least:chroot (built for this architecture, if not you can find one ARMel in debian repositories) (busybox is there if you have sshdroid that you can download for free in the market, fsck is also there) On your computer, you need a few things to prepare your image (but its possible to do everything on the tablet if you search a bit) To bootstrap, you will need a machine with debootstrap, can be found in debian or ubuntu at least. This will install a debian system with the target architecture in a directory. On your computer: #create loop file. this is a "disk partition in a file" #the following line create a 600MB image, adapt to your needs dd if=/dev/zero of=debian.img seek=599999999 bs=1 count=1 #format the disk partition with a filesystem of your choice (it needs unix permissions and ability to have exec, bind, ..) mke2fs -F debian.img #mount the new partition to a directory mkdir debian && mount -o loop debian.img debian #Install debian sid. Adapt to your needs:have a look at debootstrap manpage to see all distribution available. #All ubuntu and debian (goes back to woody) are available. I recommend debian and I use sid, name for unstable branch #We do it in 2 times using --foreign debootstrap --verbose --arch armel --foreign sid debian http://ftp.fr.debian.org/debian #Unmount to send image to the device umount debian We now have a portable ARMel debian unstable filesystem in the file debian.img (not fully configured for users and network and not including /boot like kernel, and virtual directories like /dev, /sys, /proc etc..) Now we will send image to device. we will store our debian on the external SD, adapt to your needs Even if the external SD is in FAT, the included filesystem, in this file will be the one you have chosen before ext2/3/4 In the following, my SD Card is in /mnt/external1, change the steps to fit your setup! Send to the device scp debian.img root@192.168.1.14:/mnt/external1 Connect to the device to finish install overthere ssh root@192.168.1.14 Mount the disk. The debian virtual disk will be mounted to the android /data/local/mnt #Create target directory if not already existing mkdir -p /data/local/mnt && cd /data/local #Mount the loop disk. We use noatime so that the external sd is not synced too often to keep lifetime of external SD mount -o loop,noatime -t ext2 /mnt/external1/debian.img mnt/ #Use Chroot: this will change your current shell / to point to /data/local/mnt #The kernel is still the one you are running.. #Finalize with second stage of debootstrap chroot mnt/ /debootstrap/debootstrap --second-stage We will now finish to configure the debian system: apt-get, users, network #Set apt-get to get packages from sid repository. Adapt to your needs echo 'deb http://ftp.fr.debian.org/debian sid main' > mnt/etc/apt/sources.list #Set network server to use for resolving names to IP (like debian.org when using apt-get) #We use here google NameServer echo 'nameserver 4.2.2.2' >mnt/etc/resolv.conf #This is a detail but there for safety reason. With this, when you are within your debian, your prompt will be #(debian)localhost:~# #It can be interesting to know wether you are in android or in debian to avoid doing stupid mistakes particularly with rm ;) echo debian > mnt/etc/debian_chroot To have this special prompt, colours and for a few alias, in mnt/root/.bashrc, uncomment some lines to have this: # ~/.bashrc: executed by bash(1) for non-login shells.# Note: PS1 and umask are already set in /etc/profile. You should not # need this unless you want different defaults for root. PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ ' # umask 022 # You may uncomment the following lines if you want `ls' to be colorized: export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' # # Some more alias to avoid making mistakes: # alias rm='rm -i' # alias cp='cp -i' # alias mv='mv -i' We will now again change / to point to /data/local/mnt and execute bash inside this You are now in your new debian system chroot mnt /bin/bash #chroot included in android (not the one from busybox) is very limited so you always have to login again to get all system variables set /bin/su - cat /etc/debian_version wheezy/sid For minimal tty support (for ssh and screen at least) you will need pts. /proc is needed for any linux to get process and kernel informations exported by the kernel and /sys is the same regarding your HW config #Mount devpts, proc and sysfs filesystem. The system will now where to find information from the running kernel. mount -t devpts devpts /dev/pts mount -t proc proc /proc mount -t sysfs sysfs /sys With this, you are sharing pts, proc and sys with your android so don't be surprised if you run ps to see also android processes. You are not anymore using your gnu commands with limited busybox, you are running a complete debian system with all options! /bin/su - #we might want to see all real partitions of the android system from within debian #this is not always needed. We will link to the knowledge our kernel has of our disks rm /etc/mtab ln -s /proc/mounts /etc/mtab #setup a password for root passwd <enter twice your new root password> You now have a complete, configured debian system running with architecture ARMel. Thanks to the debian team for making such amazing tools. You can go further and install gnome. An easy way then to connect to it is through vnc: your debian will have the desktop "exported" to a network connection through x11vnc, and with android vnc viewer, you connect to it the problem is it will be slower than direct window system and keyboard, mouse, etc.. is specific to your device in debian you will find several virtual keyboards. experiment youself. Everytime you reboot, you will loose mount points. You can create this script to execute to get in the chroot wether or not you rebooted Put it in /mnt/external1/debian.sh Everytime you want to start debian, make sure you are root and call it with "sh /mnt/external1/debian.sh" (without quotes) cd /data/local#these four lines will return warnings if the mounts are already there if you did not reboot #(device busy) Ignore this mount -o loop -t ext2 /mnt/external1/debian.img mnt/ mount -t devpts devpts mnt/dev/pts mount -t proc proc mnt/proc mount -t sysfs sysfs mnt/sys #Start Debian chroot mnt /bin/bash #Unmount Debian and remove loop #Android umount does not allow multiple mountpoints, only busybox so we do it in 4 commands cd /data/local umount mnt/dev/pts umount mnt/proc umount mnt/sys umount mnt losetup -d /dev/block/loop0 In debian, start a new login shell if HOME is broken /bin/su - Manually stop debian if needed exit exit #until you should see your prompt without the (debian) meaning your are out of debian cd /data/local umount mnt/dev/pts umount mnt/proc umount mnt/sys umount mnt #remove the loop link. adapt if you already had several loops, here only one means I got loop0 during the first mount losetup -d /dev/block/loop0 Avoiding mistakes Its not a good idea to work in your debian as root, so create a new user #Be sure to be in debian system not android! (debian):~#adduser toto #... give password and confirm with Y #create a group to allow users to use network sockets addgroup --gid 3003 sockets usermod -G sockets -a toto #then everytime you want to start debian, run the script like before but login as user (add toto at the end) /bin/su - toto #you can then play with sudo to gain root if you really need (debian)toto@localhost:~$ perl -e 'print "Have fun!\n"' Have fun! Modifié 17 mars 201214 a par gaffy4141
Rejoignez la conversation
Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.