Creating chroot for arm on Ubuntu with rootstock
Some of you may or may not be familiar with chroot, for those who are familiar with chroot good job and for those that aren’t shame on you. Just kidding please read this for some more info about chroot.
Now that we all know what chroot is, maybe it could be fun to create an chroot environment, and to make it more exciting we are not creating an x86 but an arm processor environment
There are tons of ways of doing this but this is how I am doing it. You can use this method on any ubuntu from 9.04 and higher, but keep in mind I am using 10.04 so if you get error’s try to blame it on that instead off me. So first thing we need to do is prep our own ubuntu machine to be able to build a chroot environment. To do so we install rootstock, and we do it like this:
sudo aptitude install rootstock
Now we can create a chroot with rootstock, this is an simple example of no nonsense chroot:
sudo rootstock -f localhost --login ubuntu --password ubuntu --imagesize 1G --notarball
If you wish to know what this all means I recommend you to do:
man rootstock
To be able to access this chroot environment we need to mount it like this:
sudo mount -o loop IMG-FILE_NAME /mnt sudo mount -t proc proc /mnt/proc
Now we can enter our chroot:
chroot /mnt /bin/bash
Or exit it and umount it like this:
sudo umount proc sudo umount /mnt
So here you go small simple way of creating a chroot environment. Is that all you may ask your self, no it’s not, what we actually have created here above is a empty non fun chroot environment. So instead of that let’s try to make something more fun and exciting like have access to internet, have ssh server running, have an vncserver running. Here are the steps in how to do this.
Step 1, Create the image containing ssh tightvncserver lxde
sudo rootstock -f localhost --login ubuntu --password ubuntu --imagesize 1G --notarball --dist lucid --seed ssh,tightvncserver,lxde,expect
Step 2, Start the chroot environment. You can use my script from here or do this:
sudo mount -o loop imgNAME /mnt sudo mount -t proc proc /mnt/proc sudo mount -t devpts devpts /mnt/dev/pts sudo su -c 'chroot /mnt /bin/bash'
To be able to use SSH or VNC you need to configure some things. I have created an script that can do this for you, you can download it from here.
Step 3, Configure:
Open an new terminal and then:
sudo cp config.sh /mnt
Go back to your chroot and then:
chmod +x config.sh ./config.sh
Step 4, If you want to use SSH or VNC you will need to start those every time you login to your chroot. You can do this by running these command’s
vncserver -geometry 800x600 /etc/init.d/ssh restart
OPTIONAL: You can also add these commands to your bashrc script so that they will be executed for you. You can do this by running this, if you haven’t run step 3 yet you can also uncoment these two lines from my config.sh script.
sed -i '1i vncserver -geometry 800x600' /root/.bashrc sed -i '1i /etc/init.d/ssh restart' /root/.bashrc
Step 5, To quit the chroot just do the following or use my script from here:
exit sudo umount /mnt/dev/pts sudo umount /mnt/proc sudo umount /mnt
You all are set now, you have an arm ubuntu image and you have configured it all that is left to do is use it.
As always there are people I would like to give credits to, and this time it’s Nexus One Hacks.
UPDATE For those who don’t like to do all this here is an img I created: Download
I am never able to make The ubuntu image. Can you upload your image here?
Thanks
I keep on failing at step 2
@Aditya Talpade
Will see what I can do.
EDIT: I have added an dowload link to an img.
Thanks for the image.
Please reupload link!!
@yousef
Why the download link seems to work?
I’m trying to, but failing to understand fully the steps that you describe here… I was wondering if it was possible to build an Ubuntu image for the Jolicloud OS? I think that or the Ubuntu Netbook edition may be more suitable for the Galaxy’s small screen.
thnx, works great, amazing! Any way of resizing the image after created?
(1G turned out to be a bit small) Also on my phone, i don’t have resize2fs.
found it (case anyone is interested): uec-resize-image !
Maybe you like this idea: the galaxy has no physical keyboard. But how about opening a full screen virtual keyboard (xvkbd) on top of all other windows and making the keyboard transparent. I tried this using transset-df but apparently vnc isn’t able to display transparency (keyboard stays opaque) Any ideas?
Hi, great stuff here. Does your image already include the config.sh and/or modified .bashrc file?
I was trying to mount it on my 10.04 laptop but when I get to the chroot commands, I get errors about not finding /bin/bash.
Thanks!
@jos
Thank’s for the tip for resizing. You can also create your own image and copy the files there.
Sorry can’t help you with keyboard.
@PRScott
No the bashrc is not edited on my img and it does not contain the config.sh
You can download it from http://files.coralic.nl/ArmChrootUbuntu/config.sh
Some tips for usability:
Controlling the mouse in androidvnc is quite difficult. Check out the *pocketcloud* app. This is also a vnc client for android. It has kind of a virtual mouse built in which allows accurate control of the mouse pointer despite the drawbacks of a capacative screen. It also provides a quick way to pop up a keyboard for entering text into an application, without an intermediate text box appearing as in androidvnc, and it has ctrl/alt/tab/arrow keys.
Another app I use is the dingul hangul keyboard, which has most special symbols that are nice to have in a terminal (as | / *etc) available *without cycling* trough alternate keyboards. The alternate symbols are accessed by pressing a key and sliding left/right/top/down to select. (Drawback: the app is available only in korean, but there is a qwerty keyboard).
josvanr
Q: any way to mount my /sdcard from within the ubuntu image?
(case anyone wants to know) A:
create directory /phone within your ubuntu image
then from outside your ubuntu image:
busybox mount -o bind /sdcard /data/local/mnt/phone
I was unable to mount the entire phone (mount -o / /data/local/mnt/phone) for some reason..
josvanr
[: not found
test: not found
mkdir failed for /data/local/mnt, File exists
ioctl LOOP_SET_FD failed: Device or resource busy
mount: Device or resource busy
mount: Device or resource busy
chroot: not found
Help please!!!
sudo mount -o loop IMG-FILE_NAME /mnt ….I have some problems here..it sais that there’s no such file or directory.What should I do…what is the image file name.Thanks in advance!
@Alex
the replace the IMG-FILE_NAME with your own img name. If I remember corectly it should be something like qemu-armel-TIMESTAMP.img
The img is in the folder that you run the rootstock command in.
My lxterminal is loading without promt! Cant write nothing on it! Any idea what is going on?
Thanks
hello
thanks …
I have one problem with ssh . how login to the chroot envaroment?
after mount and chroot , I send (/#ssh root@localhost) and empty password but can`t login to chroot envaroment. I read 100 webpage about ssh but can`t use it!!!
excuse me for bad english.agan Thanks for your good sit.
Hello,
everything gone well, but almost at the end of creating the image, I receive an error which says a java certificate needed. do i need a specific version of java sdk, etc, or the error belongs to something else.
thanks.
What’s the root password that you set in the image ?