Monday, April 16, 2012

Arch Linux LXDE /w Xorg Mouse Keyboard on Nook Color Android Tablet

by Thomas Polasek



My goal was simple, install a full linux os on my Nook Color tablet. I was surprised to find out that nobody has bothered to run an Xorg server on the android device itself, practically all solutions went through VNC to access the Xorg server.

I will show you how to boot up an Arch Linux distro with mouse and keyboard support that runs the Xorg server on the linux framebuffer (/dev/graphics/fb0). 





Part 1.

Root your Nook Color

Install Clockwork Recovery Mod

Install the Nook Color Cm7.2-RC1 MiRaGe rom
 http://forum.xda-developers.com/showthread.php?t=1344873

Install the Nook Tweaks app from the google market
 https://play.google.com/store/apps/details?id=com.dalingrin.nookcolortweaks&hl=en

Install the SSHDroid app (optional) from the google market
https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en

Part 2. (Linux OS)

Plug in 4GB+ MicroSD Card (with an Ext4 partition)

Mount the SD Card on your OSX or Linux OS
mkdir -p /mnt/sdcard
mount /dev/sdb1 /mnt/sdcard (Replace /dev/sdb1 with your sdcard device)
Download and Extract Arch Linux distro for ARM7 OMAP to your SD Card
          cd /mnt/sdcard
          mkdir arch
          cd arch
tar xvzf ArchLinuxARM-omap-smp-latest.tar.gz
rm -f ArchLinuxARM-omap-smp-latest.tar.gz

Part 3. 
Connect the MicroSD to your Nook Color Tablet

Run the SSHDroid app or connect via adb shell

Connect to your Nook Color via SSH from your linux machine and make sure our SDCard is writeable/executable
su
bash
cd /mnt/sdcard (this is the mounted directory of your MicroSD card with arch linux on it, yours might be different)
mount -o remount,rw,exec /mnt/sdcard

Chroot into your arch linux distro (you should probably make this a script)
If you need additional/supplementary information here is a good link
http://www.mayrhofer.eu.org/debian-on-android

export mnt=/mnt/sdcard/arch (This is your Arch Linux distro location)

# mount linux essentials to our chroot environment
mount -o bind /dev $mnt/dev
mount -t devpts devpts $mnt/dev/pts
mount -t proc none $mnt/proc
mount -t sysfs sysfs $mnt/sys

# export environmental variables for our chroot
export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH
export TERM=xterm
export HOME=/root
export USER=root

#chroot into our arch linux distro
chroot $mnt /bin/bash

Part 4. (in your arch chroot environment)

Setup our DNS (only have to do this once)
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 4.2.2.2" >> /etc/resolv.conf

Update arch
pacman -Syu

Install Xorg and LXDE on your Arch Linux Chroot
pacman -S xorg-xinit xf86-video-fbdev xf86-input-evdev lxde

Edit your /etc/X11/Xorg.conf file
cd /etc/X11
rm Xorg.conf
sudo wget http://y.uk.to/files/xorg.conf (or try http://pastebin.com/raw.php?i=8CM7NKhd)
You may need to edit the device references for the keyboard and mouse in Xorg.conf! (/dev/input/event5 and /dev/input/event4 might be different)
More information is found below

Go on your Nook Tablet and Run the Nook Tweaks app
Turn on USB-Settings ---> USB Host Mode
Turn on USB-Settings ---> External VBus

Connect your USB devices to your Nook Color Tablet
Obtain a female to female usb connector
Connect a hub to one side of the female connector
Connect a usb keyboard/mouse to the hub
Connect a mini-usb to the nook and then to the other side of the female connector

If you need to figure out what devices your keyboard and mouse are on, then
cd /dev/input

run the cat command on each input* .... and check if your keyboard/mouse input results in a change on the output from cat
for example, when I press a key on my keyboard cat /dev/input/event5  outputs some binary characters.

Now we will setup our linux framebuffer (****UPDATE 1****)

           pikpok sent me this suggestion in the comments section.
You can use "setprop ctl.stop media & setprop ctl.stop zygote" in adb shell to kill zygote server and media, if you want to return to android you can replace stop with start and run again, it's much better than chmod :)
Now we will setup our linux framebuffer (hack)
Try pikpok's suggestion first, if it doesn't work then try out this hack of mine.
Temporary hack to stop the android system from accessing the frame buffer device. I plan on writing a patch that toggles access to this framebuffer from linux. But right now what I do is
I change permissions on the framebuffer and then wait for the android system to lose connection to the framebuffer device.
Once android loses the connection I run the Xorg server on the framebuffer, it hijacks the graphics output.
If anyone has any idea on a better way to this please feel free to post on the comments section.
Eventually (again this is a hack) the android system will appear to freeze (the screen stops updating)
cd /dev/graphics
chmod 000 /dev/graphics/fb0
chown root:root /dev/graphics/fb0
If the graphics don't freeze right away, then keep running and killing the xorg server over and over until it does.
Start LXDE session (starts Xorg Server)
xinit /usr/bin/lxsession &

If everything is configured good, you will get a full LXDE desktop with mouse and keyboard support.
For any xorg server problems, have a look at the /var/log/Xorg*.log file

To stop the xorg server you can run  (not the safest way but it doesn't really matter for this)
         killall X 

BAM. Fully working linux system using the linux framebuffer with mouse/keyboard support.

In addition to support the USB keyboard and mouse, it is possible for other USB devices that are support ed by linux to be connected. Example of devices such as USB-DVI, USB-SERIAL, Arduino, etc...

Notes about the SD Card and EMMC:
It is possible to chroot into any part of the filesystem of Nook as long as you have rwx access. For my personal usage I chroot into the 8th partition on the EMMC (~4GB) of space and run Arch Linux from there, I find the EMMC runs faster than the SD Card.
****UPDATE 1****
Working on making a full bootable Arch Linux image with the Android Kernel, and without all the Android system fluff.

145 comments:

  1. I'd be glad to help out with any questions, please feel free to post them here =)

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Is sound supported? ALSA Audio to be more precise

      Delete
    3. Is sound supported? ALSA Audio to be more precise

      Delete
  2. This is fantastic, thanks for sharing! I'm receiving a Transformer Prime soon and I'd love to get Arch running on the bare hardware somehow. Hopefully this process can be modified for other tablets; it doesn't seem like there's anything preventing that. I wonder if there's a way to boot Android in headless mode. If there were, it might be possible to run an init script of some sort which would perform the chroot and start X automatically.

    ReplyDelete
    Replies
    1. There is nothing platform specific about this, all you need is an Android kernel that supports USB hosting and has proper frame-buffer device. I agree, it'd be great to have a init script to chroot and boot X without the Android system baggage. Right now I am looking for ways to shut down most of the existing Android system, so that I can free up the ram... Android takes approximately 300mb/512mb... which doesn't leave too much for LXDE.

      Delete
  3. this is pretty badass, ill certainly be following this, plus someones posted a link to this on XDA so this will probably attract attention there too. just wondering though, does everything work? like flash player, sound, bluetooth and whatnot. really excited to see this develop, id use this as a daily driver in a heartbeat.

    ReplyDelete
  4. This is what I need, I have prestigio multipad 3384B but whole partition is YAFFS2 read-only sysytem, I was about to convert it to ext3 and mount it that way but I don't have the time (partition offset made problems)
    Now it seems I don't need to do this...I can't wait to try this!

    ReplyDelete
  5. You can use "setprop ctl.stop media & setprop ctl.stop zygote" in adb shell to kill zygote server and media, if you want to return to android you can replace stop with start and run again, it's much better than chmod :)

    ReplyDelete
  6. I'm trying to get this working on my Galaxy S phone (gen1). Care to post the xorg.conf? (link doesn't work)

    ReplyDelete
    Replies
    1. Here it is: http://pastebin.com/raw.php?i=8CM7NKhd. Cheers =)

      Delete
  7. Yay, I got it working! I had to kill bootanim and do

    setprop ctl.stop media
    setprop ctl.stop zygote in adb shell. (thanks pikpok)

    I'm running openbox-session, then did DISPLAY=:0 xterm &, which started xterm fine. However, I have no input on the phone :P

    Maybe there's a way to get touch drivers...

    ReplyDelete
    Replies
    1. Here are the available input devices: http://nopaste.info/dbfa041cce.html

      No matter how I configure xorg.conf (or udev rules) I cannot get the mouse pointer to move. :-/

      Delete
    2. Are you using the "evdev" driver for the touch screen device? I believe you will need a different touch-specific xorg driver to use the touch screen as a mouse.

      Delete
    3. Let me start out by saying awesome! I am going to try this as soon as possible on my Nook Color. ThomasP, for archlinux, in the Arch User Repositories (AUR), there is an evdev multitouch driver. When I got the time to try this out, I was going to install that and try it out. In addition, I don't know if you need to use the Android kernel. The current stable Linux kernel (3.3.2) has Android drivers merged into it.

      Delete
    4. For anyone interested, /dev/input/event2 is the touchscreen input. ThomasP, I'm in chroot, but the system won't update. Everything on the update list comes back with "exists in filesystem" as a conflict. I looked in the Arch Linux forums, and nothing works as a fix. Any thoughts?

      Delete
  8. is there anyway you can help us out on the xda ubuntu thread for the NC...it would be awesome for someone who actually has linux running natively on their device...

    here's the link...
    http://forum.xda-developers.com/showthread.php?p=25026630&posted=1#post25026630

    ReplyDelete
  9. I also think it sounds pretty exciting what you're up to have. I just wondered what the benefits really are not a VNC solution. Do you have better access to USB devices from arch linux that way. Or is it a question of speed. That the system works faster when not using VNC? (and not full X11 but just frambuffer. I love that idea)

    /mikkel

    ReplyDelete
  10. and one more question from me. The tuch screen will worke if you run xorg through VNC. But if you run it this way on the framebuffer the tuch screen will not work whil xorg running. Only external mouse will work is that correct what I asume here?

    /mikkel

    ReplyDelete
  11. Any new updates? Got a bit quiet...

    ReplyDelete
  12. I am doing this on an atrix and I can't seem to get the framebuffer to play nice with X I keep getting

    [ 3407.759] (WW) Falling back to old probe method for fbdev
    [ 3407.760] (II) Loading sub module "fbdevhw"
    [ 3407.760] (II) LoadModule: "fbdevhw"
    [ 3407.760] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
    [ 3407.761] (II) Module fbdevhw: vendor="X.Org Foundation"
    [ 3407.761] compiled for 1.12.1, module version = 0.0.2
    [ 3407.761] ABI class: X.Org Video Driver, version 12.0
    [ 3407.761] (EE) open /dev/graphics/fb0: Operation not permitted
    [ 3407.761] (EE) No devices detected.

    I can't seem to get past that. I am trying to start xfce but it won't work with just startx command either. Any help appreciated also I love the guide and people like you are making me way more linux knowledgable than necessary heh

    ReplyDelete
  13. I'm running CM9 on my sgs2. I killed the zygote & media server, but i got the bootanimation. When i started the X server (XFCE) I got linux for about a second...
    I tried the hack method, with no luck at all... nothing happened! :\

    ReplyDelete
  14. Kill the boot animation.

    ReplyDelete
    Replies
    1. Find the process, for example ps aux |grep boot, or ps aux |grep ani . My boot animation process was just called bootanim. This depends on your ROM.

      Delete
    2. on cm9 is bootanimation :D
      it works!!! now lets see how to make touchscreen work... :)

      Delete
  15. Hey, works great. You just have to be a bit patient when you run xinit. It takes a few seconds of waiting at a blank screen before the desktop loads. Anybody here have the skill to create a script that performs the mounting, chroot, and X11 so that I don't have to do so much typing?

    ReplyDelete
    Replies
    1. My only snag is that when I kill X and then run setprop to restart my android homescreen, it just triggers a reboot. Not a huge deal, but would like a smoother way to shut down Archie and go back to Android with restarting.

      Delete
    2. Try this:

      Script 1 (mounts,exports,chroots)

      CHROOT_SCRIPT.SH
      #!/bin/bash
      export mnt=/mnt/sdcard/arch (This is your Arch Linux distro location)

      # mount linux essentials to our chroot environment
      mount -o bind /dev $mnt/dev
      mount -t devpts devpts $mnt/dev/pts
      mount -t proc none $mnt/proc
      mount -t sysfs sysfs $mnt/sys

      # export environmental variables for our chroot
      export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH
      export TERM=xterm
      export HOME=/root
      export USER=root

      #chroot into our arch linux distro
      chroot $mnt /bin/bash

      You could add a second script on the Arch system that kills the android screen and then loads xorg.

      Delete
    3. When I type each line, it all works great. When I make a shell script and execute it, I get the following error:

      mount: mounting none on /proc failed: Device or resource busy
      mount: mounting sysfs on /sys failed: Device or resource busy

      The other mount commands and exports work fine. Maybe there is some sort of timing issue here....?

      Delete
    4. well, why so much trouble?

      #!/system/bin/sh
      export mnt=/data/local/mnt #mount point

      if [ "$1" == "stop" ]; then
      umount $mnt/sys
      umount $mnt/proc
      umount $mnt/sdcard
      umount $mnt/dev/pts
      umount $mnt/dev
      umount $mnt
      elif [ "$1" == "startx" ]; then
      mount -t ext2 /dev/block/vold/179:26 $mnt #conf this
      mount -o bind /dev/ $mnt/dev
      mount -t devpts devpts $mnt/dev/pts
      mkdir -p $mnt/sdcard
      mount -o bind /mnt/sdcard/ $mnt/sdcard
      mount -t proc proc $mnt/proc
      mount -t sysfs sysfs $mnt/sys
      setprop ctl.stop media & setprop ctl.stop zygote
      busybox chroot $mnt /usr/bin/startxfce4 & #conf this
      elif [ "$1" == "stopx" ]; then
      setprop ctl.start media & setprop ctl.start zygote
      busybox chroot $mnt '/usr/bin/killall startxfce4' #check if works
      else
      mount -t ext2 /dev/block/vold/179:26 $mnt
      mount -o bind /dev/ $mnt/dev
      mount -t devpts devpts $mnt/dev/pts
      mkdir -p $mnt/sdcard
      mount -o bind /mnt/sdcard/ $mnt/sdcard
      mount -t proc proc $mnt/proc
      mount -t sysfs sysfs $mnt/sys
      busybox chroot $mnt /bin/bash
      fi
      PLEASE, do not copy the script and say that it is yours! :)
      thanks!
      if you want better version, reply, and i'll develop it...

      Delete
    5. Thank you very much. BTW, I suspect this same method can be used to run Archie on an Asus TF201 using the framebuffer. But it would require a little fiddling with the X conf file. Anyone out there try this method on a Transformer Prime or a Xoom yet?

      I've been running chroot ARM Linux on my Prime but using VNC which is somewhat laggy. Would prefer to use the framebuffer for obvious reasons.

      Delete
    6. it's nearly the same for all devices... (tweak a bit the partition which you want to be mounted)
      this configuration works perfectly with my SGS2 (i9100) with a second partition on the external sdcard...
      if i have time, i'm going to develop it to much the needs of all
      (?) phones
      BTW: don't expect HUGE performance improvement if VNC is laggy!
      i run geogebra (java (!!!) based geometry tool) with XFCE! I love my SGS2 :)

      Delete
  16. This comment has been removed by the author.

    ReplyDelete
  17. are there any updates you can tell us on the status of this project, Thomas? Ive been watching since this got posted on XDA, i really want to see this go somewhere but it seems that its lost a bit of traction recently...

    ReplyDelete
  18. Hi I've tried this in an Asus TF201, already had a chroot working, I've downloaded your X11 configuration, I'm trying to setup XFCE4, but I'm stuck on this Xorg error:

    xf86OpenConsole: Cannot open /dev/tty0 (No such file or directory)

    This are the TTYs in /dev :

    /dev/tty /dev/ttyHS1 /dev/ttyHS3 /dev/ttyS0 /dev/ttyS2
    /dev/ttyHS0 /dev/ttyHS2 /dev/ttyHS4 /dev/ttyS1 /dev/ttyS3

    Tried some soft links, changing permissions, f.e. this:

    lrwxrwxrwx 1 root root 11 May 16 22:40 tty0 -> /dev/ttyHS0

    but no luck I've always get this other error:

    xf86OpenConsole: Cannot find a free VT: Invalid argument

    I really don't know what I'm doing, any help is greatly appreciated.

    ReplyDelete
    Replies
    1. I'll answer myself: Seems that stock kernel doesn't support virtual terminals, so now my best chance is (if I don't replace stock ROM voiding warranty) patch xorg so it won't need'em.

      Delete
    2. it's easier for you to patch xorg rather than flashing a ROM?? O_o WTF??
      anyway, congrats! and also could you enable virtual keyboard??

      Delete
    3. Not easier, but safer (for my tablet's warranty) :-) I own the dock so the keyboard/touchscreen isn't an issue for me, but maybe I'll try it. I'll post something if I suceed.

      Delete
    4. please, try it... i have sgs2 and I can't make touchscreen work as mouse (touchpad, or even better, touch screen)

      Delete
    5. MG, any luck so far? I stumbled on the same problem, have been searching the web for any info on this but no luck so far.. Can't get rid of this tty0 issue. On a galaxy S running ICS I had no problems at all and had everything running including working Bluetooth mouse and keyboard. Btw I'm using Ubuntu instead of arch.

      Delete
    6. I am also waiting for this for my transformer prime, but I thought I'd take the step and flash. The question is, would a kernel flash like SnB Ultimate v1.0 (http://forum.xda-developers.com/showthread.php?t=1593488) work? Or would i need a full ROM flash like cyanogen? Any idea anyone?

      Delete
    7. I reply to self,
      flashing the kernel to SnB Ultimate v1.0
      does not solve it (most likely because it is probably the stock kernel modified)

      Delete
    8. I could only guess it would be the difference between the modded cyanogen ICS and the stock ICS which comes with the TF201.

      My knowledge goes not that far, so have been trying to figure out how to get tty0 on the prime, but was unsuccessful. Also tried to figure out if I could redirect or make Xorg use tty or a different other virtual terminal, but again, unsuccessful.
      I have been fiddling with mknod and MAKEDEV, making a tty0. The tty0 was created, but it did not solve the problem. Same error.

      I see you have been flasing a kernel. So far I haven't flashed anything on the prime, as for the warranty, which I like to keep as well..So flasing a kernel or whole ICS mod is also no option for me unfortunately. Not until Asus changes its policy. - read NOT - :(

      Anyway, does anybody have a clue or more knowledge about getting around the tty0 problem for Xorg?? I am searching the web daily for info but just can't get to it.

      Delete
    9. Hi Rob,

      I've ended using a better VNC client, Real VNC Viewer, isn't the perfect solution (tablet interface is VERY COOL, but lacks some kind of direct input for the dock)... but anyhow it's quite useful, there's also an (in-progress?) native X Server in android market, but unfortunately by now it's just a toy, quite buggy, incomplete and slow... I've also tried the official Tegra 3 drivers but no luck, just the TTY issue again (2d acceleration at hand!), my xorg "patching" compiled but also didn't work... xorg NEEDS a dedicated terminal.. maybe with some more heavy patching but right now it's out of my bounds :-(

      Anyhow I'm quite happy with my chroot, already discovered how to grant non-root users network and sudo, so for now I'm considering buy a dedicated micro-sd card and move there my chroot sandbox...

      Delete
    10. Hi Prose Kit,

      you are right, you need a kernel with virtual terminals enabled, maybe Cyanogen 9 will do this for us (CM7 worked for OP)

      Delete
    11. Hi gents,i can recommend vnc program 'jump' as it is a bit faster and has right click moustbutton support in ubuntu,which other vnc's didnt have. MG, guess you are right about the kernel.. Well, so far it will be vnc for me then until there is another solution. I tried the x server but indeed very basic and unusable for me for now. Unfortunately myknowledge does not go much further yet than this.

      Delete
  19. I don't know if you could help with this. I have been using trimslice on the atrix as mentioned earlier. I fresh installed a couple of times but now after chroot'ing into my new environment every command other than exit or cd segfaults

    ReplyDelete
    Replies
    1. You may have the wrong version of Arch! Try to verify the cpu you have on your device is one of the supported architectures for the distro you downloaded.

      Delete
  20. Id be willing to help anyway I can. Complete noob. However there is a gentleman in the Mer community with some relevant patches to the kernel in regards to running linux on the nook minus android. His user name is WMarone i believe

    ReplyDelete
  21. For anyone interested I made a touchscreen "driver" to work in the chroot environment. Change the /dev/input/event* to the one for your device. Compile on your device or cross compile on your computer. Run like this:

    DISPLAY=:0 ./myTouch

    https://github.com/crondog/i9300-archlinux-touchscreen-driver

    ReplyDelete
  22. post it in aur!
    testing it right now! ;)

    ReplyDelete
  23. crondog, can you help me on how to use the i9300 initramfs?

    ReplyDelete
  24. ttouch,

    I have updated the readme for the initramfs.

    However you dont need that to get the touchscreen working.

    That is something else i am working on which isnt working right now

    ReplyDelete
    Replies
    1. yes, i know, but it would be so nice to dual boot arch and android...
      any ideas for GSM calling from inside arch?
      gcc throws an error when compiling about some unused vars...

      Delete
    2. Dual booting is what i am going for. However I am having a hard time trying to get it booting :(

      I havent actually looked into calling really so i cant help at the moment.

      To get rid of the warning get rid of the -Wall

      Delete
    3. ok, please keep us updated!
      i have beta-hungriness, so if you want to test anything, drop an email!
      however i have an i9100 (CM9) and i don't know if everything is going to work...
      thanks a trillion!!

      Delete
    4. Sure no problems :)

      It should probably work :)

      Delete
    5. Init
      touchs: myTouch.c:19: main: Assertion `display != ((void *)0)' failed.
      Aborted
      ideas?

      Delete
    6. woops forgot to mention you need to run like this

      DISPLAY=:0 ./myTouch

      Delete
  25. man i love you... :)
    left/right click? how? i double-tap and nothing happends...

    ReplyDelete
    Replies
    1. There is still a lot to do with it :) I haven't implemented it fully. And for some reason the menus dont receive the clicks properly. I will be adding right click soon. And also pinch to zoom etc. But for now it can only left click on a couple of things. Sorry

      Delete
    2. :( ok... can't you just make an "interface" so that touch screen shows as touchpad? (i don't know how and if is this possible)

      Delete
    3. My program is the interface. I just have to implement all of the functions which make it a "touchpad"

      Delete
    4. can't you reuse some functions from other drivers? (or even better, patch evdev?)
      i have no idea of C, so as i said i don't know if what i said actually makes any sense XD

      Delete
    5. Yeah i probably can. It is mostly a learning experience at the moment :)

      Im not actually sure why evdev doesnt work which is why i decided to write my own.

      It could also be a configuration thing with xorg.conf which could be why evdev doesnt work.

      Delete
    6. ok, good luck!
      PS: any idea on how to get mkbootimg on Mac?
      thank you for everything! :)

      Delete
    7. where can i get documentation about the ev[i].code? is it a class from Xlib.h?
      i try to find the double tap event in order to call mouseClick :)

      Delete
    8. Maybe check in the cyanogenmod sources ;)

      Delete
    9. no luck... :(
      i'll figure it out, it should be easy!

      Delete
  26. hi there

    i have some questions

    in my case.

    i just tried using VNC (ubuntu)

    so i use kernel image in (http://nexusonehacks.net/nexus-one-hacks/how-to-install-ubuntu-on-your-android/)

    and, i modify the booting script(just add mount -o bind /dev/ $mnt/dev )

    after chroot, i stopped zygote, media and kill bootanmation.

    and when i run xinit ( using Thomas Polasek`s
    xorg.conf) it didn`t work

    it just stop with no error (Xorg.0.log ,dmesg)

    nobody know what is my problem.?

    in fact, i dont care about input method, i just want X display through fb0(/dev/graphics/fb0)

    plz help me. thanks

    ReplyDelete
  27. Hello!

    I'm trying to do this on a Huawei U8650. Yeah, it's a bit weak, but I hope that it will swallow Arch Linux. What's actually bugging me are the following things:

    1. What's the optimal size of the ext partition?
    2. What goes on the FAT partition, and what on ext?
    3. What would be the best way to partition my SD card in your opinion?

    Sorry for asking stupid questions, but I couldn't find answer to these anywhere.

    Thanks in advance!

    ReplyDelete
    Replies
    1. Sorry for the late response but...

      1. I'd say a couple of gigs, maybe a bit more but it depends on how much software you're going to install under the chroot. Basically >= 2GB (Gigabytes, not Gibibytes :P).

      2. There's no need for the FAT partition as far as I know.

      3. Use Gparted and just resize and add the ext4 / ext2 partition as the second partition on the sdcard. When you need to mount it, it should be /dev/sd#2 under linux.

      And don't worry about asking stupid questions relating to linux. There is a whole subreddit on reddit dedicated to it :P (/r/linux4noobs).

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Thanks for responding. It wasn't late at all, it would be late if I gave up. Okay, then it would be way too late. Back on the topic.

      If I understood correctly, Arch Linux should be located on a 2+ GB ext2/4 partition in a folder called arch, right? Should the ext partition be primary or logical (I have a primary FAT partition on my SD card)? Lastly, will it change something if I use File Roller instead of untarring with tar?

      Delete
  28. Hi,
    Is it possible to work on LAMP(Linux Apache MySQL PHP) tools in this environment? Please confirm.

    Awaiting reply ...

    ReplyDelete
  29. I am trying this with a 16gb class 10 SD so I dont know if that is my issue or not. i cannot extract the arch to the fat partition (duh) that is made by my NC, but the NC won't mount a EXT4 partition. im not sure if i am just overlooking something small or not

    ReplyDelete
  30. create ext2 partition, not ext4, ext4 will kill your sd card

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I'm Just curious as to why you say that, when the author said to use ext4?

      also this did not solve the issue I am having

      Delete
    3. A bit late but...

      He's mentioning it because ext4 has journaling on by default, which would increase the number of read/writes on the sdcard, thereby shortening the lifespan of the sdcard.

      The filesystem type as far as I know doesn't make a difference towards whether the chroot works or not.

      Cheers

      Delete
    4. It doesn't matter what filesystem you pick. I chose ext4 because i figured it would have better performance.. though in retrospect, the journaling might cause ext4 to be slower than ext2.

      Delete
  31. This oughta be a polite bump :P

    ReplyDelete
  32. Hi I hope anybody will read this. I really try to get this work but after pacman -Syu I get this error output:
    "[root@localhost /]# pacman -Syu
    :: Synchronizing package databases...
    core 38.8 KiB 53.8K/s 00:01 [######################] 100%
    extra 428.5 KiB 286K/s 00:01 [######################] 100%
    community 421.6 KiB 450K/s 00:01 [######################] 100%
    alarm 6.0 KiB 5.20M/s 00:00 [######################] 100%
    aur 11.7 KiB 1964K/s 00:00 [######################] 100%
    :: The following packages should be upgraded first :
    pacman
    :: Do you want to cancel the current operation
    :: and upgrade these packages now? [Y/n] y

    resolving dependencies...
    looking for inter-conflicts...

    Targets (1): pacman-4.0.3-3

    Total Download Size: 1.00 MiB
    Total Installed Size: 3.38 MiB
    Net Upgrade Size: 0.00 MiB

    Proceed with installation? [Y/n] y
    :: Retrieving packages from core...
    pacman-4.0.3-3-armv7h 1019.7 KiB 262K/s 00:04 [######################] 100%
    (1/1) checking package integrity [######################] 100%
    (1/1) loading package files [######################] 100%
    (1/1) checking for file conflicts [######################] 100%
    warning: could not get filesystem information for /mnt/asec: No such file or directory
    warning: could not get filesystem information for /mnt/obb: No such file or directory
    warning: could not get filesystem information for /rom: No such file or directory
    warning: could not get filesystem information for /system: No such file or directory
    warning: could not get filesystem information for /data: No such file or directory
    warning: could not get filesystem information for /cache: No such file or directory
    warning: could not get filesystem information for /mnt/sdcard: No such file or directory
    warning: could not get filesystem information for /mnt/secure/asec: No such file or directory
    warning: could not get filesystem information for /mnt/sdcard/.android_secure: No such file or directory
    warning: could not get filesystem information for /mnt/emmc: No such file or directory
    warning: could not get filesystem information for /data/pengdroid: No such file or directory
    (1/1) checking available disk space [######################] 100%
    error: Partition / is mounted read only
    error: not enough free disk space
    error: failed to commit transaction (not enough free disk space)
    Errors occurred, no packages were upgraded."
    I think I unterstand the problem but how can I fix it.

    ReplyDelete
    Replies
    1. Before you chroot.. test that you have Read/Write access.

      Also, you could try using this command mount -o remount,rw /PATH_TO_DRIVE before you chroot.

      Delete
    2. Does change anything same problem. Can it maybe a problem that I format the sd card to ext2 and not ext4?

      Delete
  33. I'm thinking of trying this out as a low-cost/lightweight compute platform I can take while traveling. How is the battery-life of the Nook under Arch Linux, Thomas?

    ---ram---

    ReplyDelete
    Replies
    1. I can get a solid 5 hours with it running. Though I have absolutely no power settings, so I'm sure you can get quite a bit more life than that.

      Delete
  34. well, battery life won't be such a problem, unless you want GUI.

    ReplyDelete
  35. Hi:

    If I want to start xorg over HDMI (not on android screen),
    do I need /dev/graphics/fb1 device?

    Thank you~~~

    ReplyDelete
  36. I managed to make S-Pen work on galaxy note 10.1 wifi! it's device /dev/input/event6 and it works with evdev.
    The big problem is the touchscreen (event1). I've tried mutrack, multitouch and evdev drivers and nothing works... :( any help?

    ReplyDelete
  37. Any updates on the kernel archlinux image for nook color?

    ReplyDelete
  38. Thanks for this article. I'm having a problem on my Nexus 4, however. It segfaults upon touching the screen:

    Backtrace:
    Segmentation fault at address (nil)

    Caught signal 11 (Segmentation fault). Server aborting


    Any ideas?

    ReplyDelete
    Replies
    1. So the X server runs fine until you touch the screen? If you need to get a crash log then try running it in gdb and get a backtrace. Otherwise it's hard to identity what your issue might be.

      Delete
    2. i am having the same issue on my S2, anyone able tto post a working xorg.conf with touch.

      Delete
    3. Posting an xorg.conf that i copied from a post on the web. Makes my screen work as touchpad, annoyingly without right click, unless i am just missing something.

      Section "ServerLayout"
      Identifier "Layout0"
      Screen "Screen0"
      #InputDevice "Mouse0" "CorePointer"
      #InputDevice "Keyboard0" "CoreKeyboard"
      InputDevice "cyttsp-i2c" "CorePointer"
      EndSection

      #Section "InputDevice"
      #Identifier "Keyboard0"
      #Driver "evdev"
      #Option "Device" "/dev/input/event5"
      #Option "Protocol" "usb"
      #EndSection

      #Section "InputDevice"
      #Identifier "Mouse0"
      #Driver "evdev"
      #Option "Device" "/dev/input/event8"
      #Option "Protocol" "usb"
      #EndSection

      Section "InputDevice"
      Identifier "cyttsp-i2c"
      Driver "multitouch"
      ##Driver "evdev"
      option "Corepointer" "true"
      option "SendCoreEvents" "true"
      Option "Device" "/dev/input/event2"
      Option "protocol" "Auto"
      # mouse should move as fast as finger and not faster
      #Option "AccelerationScheme" "none"
      # evdev has it, multitouch doesn't so it behaves like touchpad
      Option "IgnoreRelativeAxes" "true"
      EndSection


      Section "Device"
      Identifier "Card0"
      Driver "fbdev"
      Option "fbdev" "/dev/graphics/fb0"
      VendorName "Unknown"
      BoardName "Unknown"
      EndSection

      Section "Screen"
      Identifier "Screen0"
      Device "Card0"
      DefaultDepth 24
      SubSection "Display"
      Depth 24
      Modes "800x480_60.00"
      EndSubSection
      EndSection



      Section "ServerFlags"
      Option "AutoAddDevices" "true"
      EndSection

      Delete
  39. Is there a forum discussion somewhere for this topic?

    There are some things i would like some help to get this working nicely.

    At the moment i need a computer at hand to startx after killing the android ui. I have a script that kills android but i have to make a connection via ssh first in order to give the startx command. Anyone know how to write a script that would kill android and then switch to the linux shell and give the startx command.

    It would also be nice to access a similar script inside linux environment that would restart the android services.

    I should add that i am not using chroot, i used debian-kit to install ubuntu.

    ReplyDelete
    Replies
    1. ive found a way to do this with one script...shutdown android boot linux>startx>X>Xorg
      i too have a sgs2. have you managed to get the touchscreen working?
      im pretty sure its to do with zygote..
      i run startx from a chroot bash and it loads under android ui and i can move the mouse and the framebuffer tracks it showing a few pixels around the mouse cursor.
      but if i shut down the android ui and startx it all loads fine except i cannot move the mouse.
      so far ive tried setprop ctl.stop zygote (no mouse move)
      ^ ^ ^ ^ ^ ^ ^ ^ surfaceflinger (same as zygote but skipped the bootanimation part)
      also tried servicemanager..
      gonna make a android logcat dump check for other possibility that can free framebuffer and not reload it.

      the xorg.conf is major for this chroot native method!
      if you have a working xorg.conf for sgs2 please share
      cheers
      col

      Delete
    2. found it to be
      setprop ctl.stop servicemanager
      sleep 4
      killall bootanimation

      cheers

      Delete
  40. i also have installed the "mtrack" driver which is a fork of the multitouch driver. for me this has got right click working with two finger tapping.

    apt-get install xserver-xorg-input-mtrack

    this will remove the multitouch driver, but as i said it is a fork, so it works the same. but with right click enabled.

    ReplyDelete
    Replies
    1. Hi Joe, could you please show us your xorg.conf file.
      I've tried to use xserver-xorg-input-mtrack, but it doesn't work and I don't know why.

      Simply the mouse doesn't move.

      Thanks

      Delete
  41. Hello again,

    I have come up with a way to boot to linux without needing a pc. Does anyone know how to start the android processes from within linux, I can of course reboot, would just be nice to be able to switch between the two.

    Thanks.

    ReplyDelete
    Replies
    1. create a daemon that will check every 30" if a file exists. run it from the android and if the daemon find that the file exist, delete it, killall X and start zygote & media

      Delete
    2. Hello ttouch, thanks fof the response. That sounds like a great solution. When you say deamon do you mean a script? And if this is the method you use could you share yours. Thanks.

      Delete
    3. A script that will run in background with a while true loop. I was thinking about it, but I have not done it yet.

      Delete
    4. Looking for a little help with my script. Let me just say I have close to no idea what I am doing, be gentle with me. Here is my script.

      #!/system/bin/sh
      start:
      if [ -f /storage/sdcard0/cheese.txt ];then
      rm /storage/sdcard0/cheese && setprop ctl.stop media && setprop ctl.start zygote
      fi
      sleep 30
      goto start;

      So I am trying to restart the android ui by placing the file cheese in the sdcard.

      Can anyone help please.

      Delete
    5. do not use goto, but while loop. Generally, goto is the worst way to do anything in nearly any language :P
      apart from that you should start media and not stop it. lol
      the problem is that it never ends (add && exit)

      Delete
    6. Lol, thanks for the hint about start! Well, i dont think i can work this one out, keep getting syntax errors using if and while, doesnt seem to like the [ brackets at all. This is where i am at.

      #!/system/bin/sh
      while (true) [ -f /storage/sdcard0/cheese.txt ]
      do
      rm /storage/sdcard0/cheese.txt && setprop ctl.start media && setprop ctl.start zygote
      echo cheese
      exit

      Just gets stuck at the first [ !

      Delete
    7. #!/system/bin/sh
      while [ true ]; do
      if [ -f /storage/sdcard0/cheese.txt ]; then
      rm /storage/sdcard0/cheese.txt
      setprop ctl.start media && setprop ctl.start zygote
      exit
      fi
      done

      Delete
    8. THANKYOU ttouch for taking the time to fix my script. Your script does indeed work perfectly, however it seems to keep the cpu very busy while in linux.

      Thanks again. I like your solution.

      Delete
    9. Fixed, added sleep.

      #!/system/bin/sh
      while [ true ]; do
      if [ -f /storage/sdcard0/cheese.txt ]; then
      rm /storage/sdcard0/cheese.txt
      killall X && setprop ctl.start media && setprop ctl.start zygote
      echo cheese destroyed
      exit
      fi
      sleep 30
      done

      Thanks again.

      Delete
  42. I created a script that has the start/stop graphical server capability. Check it out: https://gist.github.com/ttouch/5353913
    As of now it supports only new devices that chroot without image/partition, but directly from /data (tested on nexus 4 and galaxy note 10.1).
    In this devices the /data and internal sdcard storages are shared, so I have ~16GB available on /data. I created a folder with the chroot environment (/data/workbench/mnt) and I just chroot /data/workbench/mnt (ok, not exactly, I use a whole script, but it could be done)

    ReplyDelete
    Replies
    1. moved the file to my dotfiles repository: https://github.com/ttouch/dotfiles
      Take a look at my .bashrc and bin/linux (bin/vim is vim statically compiled for android devices)

      Delete
  43. This comment has been removed by the author.

    ReplyDelete
  44. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hmm, so you need image support huh? I'll fix it.
      Also I am writing a guide on my personal blog (dzervas.gr)

      Delete
  45. This comment has been removed by the author.

    ReplyDelete
  46. This comment has been removed by the author.

    ReplyDelete
  47. can anyone help me with getting my androids keyboard to show up whilst in Linux??
    do I need to edit the xorg.conf??
    cheers

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. what can I do then...this guy has
      http://www.youtube.com/watch?v=zxats9ejrG0

      Delete
    3. it's the gnome's virtual keyboard

      Delete
    4. ill install one thanks.
      what would you recommend for a ubuntu distro?
      do you know how to flip mouse axis? lol up goes left and right goes down???
      is it Option "InvertX" "true" ?? and same for Y??
      im so close i can taste it but she doesnt want me!!
      cheers

      Delete
    5. compiled florence-0.6.0 nice looking keyboard but im having dbus problems so was just wrong. keyboard works fine tested it in vnc, but when native wasnt responding?
      think adding gtk-3.0-dev mashed up my system because the desktops just blue....its got the panel and launcher lol?

      Delete
  48. This comment has been removed by the author.

    ReplyDelete
  49. This comment has been removed by the author.

    ReplyDelete
  50. if somebody has a xorg.conf with working touchscreen please share and ill share my script that mounts, chroots kills android and starts linux gui. i use a .img file looped on the /data partition.very simple to set up.

    make a folder (linux) on phones sdcard
    save img file there
    make a folder in data partition: /data/local/mnt/linux
    run my script...(incentive to share, maybe?) lol
    thanks

    ReplyDelete
  51. anyone know how to rotate the mouse axis? cant use xinput
    doesnt connect to xserver?
    tried modding xorg.conf no joy?
    ive got it in landscape with the mouse moving with touch except moving up = cursor right and moving left - cursor down?need to flip axes somehow? yes ive tried Option "SwapXY" "1" lol

    ReplyDelete
  52. (China android tablet) using ThomasP's xorgconf I managed to get my USB keyboard to work which is on event1 but the mouse wont work. Strangely there are two input event which are "mice" and "mouse0", i tried both and no cursor action. I might try touch but I know I need to use mouse eventually..
    @collin andrews , how did you get the mouse working?

    ReplyDelete
    Replies
    1. First try to cat /dev/event/mice, adn then move your mouse, if you see characters show up each time you move your mouse, you know that that problem is in your Xorg configuration and that the mouse is recognized and working correctly with the kernel.

      Then try that wth /dev/event/mouse0 as well.

      On my device I get output when I move my mouse on the /dev/event/mice file descriptor.

      Delete
    2. Sorry I meant /dev/input/mice and /dev/input/mouse0 ... I had the paths wrong from memory.

      Delete
    3. finally I got it to work(yeah its the Xorg config) but theres a catch...only one will work its either the mouse or the keyboard, I noticed too that this is depending which I plug in first in the usb hub before I boot up Archlinux(while in android) ,if i plug in my mouse first in the hub then the keyboard the mouse works and the keyboard wouldnt in Arch . I've tried plugging in before I turn on the device ,still no joy. And yeah my USB hub is powered.

      Delete
  53. One question, are you running Arch on the tablet itself, or are you connecting to a computer with Arch installed.

    Thanks indeed (and sorry for my ignorance)

    ReplyDelete
  54. My goal was simple, install a full linux os on my Nook Color tablet. ... tabletkeyboard.blogspot.com

    ReplyDelete
  55. My goal was simple, install a full linux os on my Nook Color tablet. ... tablettastatur.blogspot.de

    ReplyDelete