[Q] USB networking. I want to VNC over usb from Ubuntu 12.04,[ working over wifi] - Android Q&A, Help & Troubleshooting

Well the script should be working, it is 'ettin.sh' now. To get VNC to work on separate device just change 'eth0' to 'wlan0' or whatever other interface you know how to configure, like usb maybe, in the 'init.sh' script that resides in ~/ on the images you can download from http://linuxonandroid.org/downloads/. Cool. If anyone can help with the usb configuring that would be cool.
Also on the different roms your storage might be different so just change that to what suites your environment,
BAD NEWS, After my first launch and exiting the VNC on my laptop (Ubuntu) My phones home button and a few other functions stopped working, a reboot remounts the root and system partitions and it goes back to normal essentially, I haven't noticed any adverse affects after the reboot.
Good luck.
EDIT: If you can't help me, you probably shouldn't attempt any of this.
I want to connect to backtrack over usb from Ubuntu on my laptop instead of from my phone. Is there a good way of doing this?
The thing is, I didn't chroot, I mounted the image, copied the contents of '/etc/*' and '/sbin/*' to the '*/etc' '*/sbin' dirs of the mounted image. and then mounted it's (the image's) contents to Androids rootfs '/' then I set up a little script to set up the environment and execute '/bin/bash -i init.sh' and again reset PATH to include /system/*.
Then in the init.sh script I want to set up a way to 'vnc' through' usb to backt4acks desktop. How would I do this?
EDIT: I started this script blelow, its not complete, feel free to use it however you like.
If anyone is good with bash I need help with loops in Bash or shell, ksh, or ash. So if you change it at all share those changes here. I haven't tested any of the loops, I wrote this here and need to do some reading on shell scripting, peace out.
Just NOTE that I would not execute this script yet, it is NOT YET COMPLETE.
I will be making minor changes as I learn and test things out, Also this was inspired by the autobootscrip (sp?) that the Linux on Android Installer app uses.

mintberrycrunch revision
I need a little help with the mounting part, "is there anybody out there?"
EDIT: Maybe escape '\' characters...
Maybe this will work? 'if [ ! -d "/$d" -a "$d" \!= "dev" -o "$d \!= "mnt" ]; then ' I want it to test whether the directory does not already exists in / and if it is not named dev or named mnt then mount it. Do you think this is a decent way to do it? Any suggestions?
Sorry, I still haven't tested this script yet, so if you brave and see any changes that will make it work I am not resposible. But it is getting close to when I will run it for the first time. The difference between this and the one I wrote for Kali is this should be a one stop shop so to speak for getting into a non chroot enviroment where you can access Bt's tools from Android directly. Apperently about a year ago someone was trying something similar called "debian installer" or something, I haven't tried it out so maybe that actually works, idk, I am happy with this.

LOL
LMFAO!
I just realized I don't think I needed to worry about testing if the variable $d was named 'dev' or 'mnt' because they should get skipped by already being mounted. If not I guess if it works as is, may be extra precaution.

Done! Almost ;{)-
Uhmm.... hope you can see the screenshot...
its over wifi though, I had to edit the init.sh script just eth0 to wlan0 in 2 lines, duh! where is eth0 on phone?

Check out the filesystem
Bada bing, bada doom, dare ya goes`a for ya.

V-0.021
This should support args, if your using different image or location such as external sdcard or want to mount to a different location
Notes: 'ettin.sh' [/IMAGE/LOCATION] [IMAGENAME] [MOUNT/POINT]'
1) Don't add a trailing forward slash for image location, the first argument. Doing so may conflict with the script.
2) Don't add suffix to image name ( second argument), the script uses a wild card period wild card syntax to account for .iso, .raw, or .img aswell as version numbers, so if its backtrack-v-r5.img all you need is 'backtrack'.
3) Default mount is "/data/local/mnt"
for example:
Code:
ettin.sh /storage/extSdCard/ubuntufolder ubuntu /mnt/myLinux
That ^^^ will use a ubuntu image on the external sdcard and mount it to a folder called "myLinux" within the "/mnt" directory.
The script below...
Code:
#!/system/bin/sh
# ettin.sh v-0.021, "Two heads are better than one."
# Written by 'Edge-Case' @ 'forum.xda-developers.com'
# This version is attempting to use symbolic linking to correct some issues.
## The purpose of ettin.sh is to merge a Linux system with Android
## hopefully allowing both systems to run in synch with each other.
## It is probably best to be ran on devices with multi-core processors.
##"""Notes on Backtrack and Kali Linux Distributions:
##"""1) Postgresql needs to be configured in order for metasploit to connect to
##""" the database. This might be possible within the script. Perhaps
##""" it is simply a matter of configuring SSH? I don't know.
##"""2) The Kernel needs to be patched to allow for packet injection and
##""" monitor mode for an external 'wi-fi' card as the factory hardware
##""" does not support monitor mode, at least on Samsung Galaxy SIII.
#########
# Prep ##
#########
mount -wo remount systemfs /system
mount -wo remount rootfs /
imloc=${1:-"/storage/sdcard0/backtrack"}
imname=${2:-"backtrack"}
subset=${3:-"/data/local/mnt"}
#Check for root!
if [ ! -d "$subset" ]; then mkdir "$subset"; fi
busybox mount -wo loop ${imloc}*/${imname}*.* ${subset}
check_mnt="`echo $?`"
if [ ${check_mnt} != 0 ]; then echo "Something is wrong with mounting, check the situation!" && exit; fi
##################################################
# Copy contents of special directories to image ##
##################################################
if [ ! -f "${imloc}/success.txt" ] ; then cp -ai /sbin/* ${subset}/sbin && echo "Files have been copied on `date`." > ${imloc}/success.txt; fi
if [ -e "/root/*" ]; then cp ai /root/* ${subset}/root; fi
######################################################
# Make directories needed and mount the file-system ##
######################################################
cd ${subset}
for d in `ls` ; do if [ ! -d "/${d}" ] ; then mkdir /${d} && busybox mount --rbind ${subset}/${d} /${d} ; fi ; done
busybox mount --rbind ${subset}/root /root
busybox mount --rbind ${subset}/sbin /sbin
busybox cp -rspi ${subset}/etc/* /etc # We'll try making symbolic links from the image to Android's /etc instead.
# Add any directories as needed.
###############################
# be safe before we continue ##
###############################
mount -ro remount systemfs /system
mount -ro remount rootfs /
######################################
# continue building the environment ##
######################################
export PATH="/system/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/system/xbin:/usr/games"
export TERM=linux
export HOME="/root"
#################################
# further down the rabbit hole ##
#################################
/bin/bash -i ~/init.sh

Pretty happy with it now, so far. Touch FIXED
Well, I am tethered from my phone to my laptop, running ubuntu, this is how I am on the internet, so my phone is doing that...
I ran 'ettin.sh /storage/sdcard0/ubuntu ubuntu' using V-0.022 and only had two files that needed overwriting.
The touch is working....check
adb is working...check
Everything is mounted ...check
Apps like browser and dsploit are working on the phone as usual...check
'apt-get update && apt-get upgrade'....check (over adb, no chroot, as [email protected] using bin/bash)
'which nmap' .....check ("
[email protected]:~# which nmap
/usr/bin/nmap
")
Well **** ya'll looks like this might work... I am now going to consider modifying a stock rom to support users and login that meshes with debian and its "shadow" file etc etc, also I need to work out permissions and enviroment variables...
I'm happy...
Also for pentesting distro's "modifying Android kernel" tutorials would be nice, anybody able to point me to one?

Related

[HOW-TO] Boot Debian with X11 and wifi from SD card. (Not chroot!)

Booting Debian with X11 on the Google NexusOne
This howto can also be found on my blog.
http://www.irregular-expression.com/?p=30
Screenshots here
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
This is a method to boot into Debian via fastboot on the nexus one from
your SD-card. This is NOT a chroot Debian image, it is honest to goodness
Debian running directly on the hardware. This is completely non destructive to
the android OS. Connectivity to the device can be provided by adbd, ssh, or
serial console. Wifi works perfectly. I have not tested bluetooth. Touchscreen
works, but needs tweaking. X11 works in framebuffer using the Debian
testing branch (squeeze). In order to get a full fledged X driver with
3D acceleration we'll need the driver from
https://www.codeaurora.org/index.php?xwinp which I haven't been able to get
to build. This doesn't mean it's broken. It just means I suck
at cross compiling .
Todo:
-Tweak settings to make X more usable.
-Find out how to use the soft keys.
-Get the CodeAurora MSM/QSD X driver working.
-Find decent method to input text.
-Test bluetooth
-Look into using the GSM radio.
-Audio
-Figure out how to configure adbd.
-Get someone who knows C and wants to hack on the recovery image to enable booting debian from there.
This how-to pulls heavily from the debian-arm install guide.
http://www.debian.org/releases/stable/arm/index.html.en
Requirements:
adb (android-sdk)
fastboot
chroot (on your phone)
sdcard with room for Debian - 2gigs seems to be sufficient for Debian + xfce.
I Had about a gig leftover. For this guide, I'm starting fresh with a 4GB sdcard
that I'm devoting completely to Debian. According to the Debian install guide,
you need at least 32MB of memory and 500MB of hard disk space. The guide
recommends at least 5GB of storage for a comfortable install. But since I'm
using the lighter XFCE4 desktop I haven't had any space issues.
http://www.debian.org/releases/stable/arm/ch03s04.html.en
1. Re size the SD card
(don't forget to backup your data before you go messing with partition tables!!)
(optional) Instead of using a partition on your main SD card, you could
simply use another sdcard and dedicate the entire thing to Debian.
Note: android didn't like me very much when I did this. I put in a
tiny (30MB) vfat partition right at the beginning of the blank sdcard
I mounted the sdcard on my Ubuntu system and used gparted to break
off 2 gigs to use for Debian. Make sure you keep the normal android
sdcard partition as the first partition otherwise android
will not be able to find it.
If you're using apps to SD or anything else like that. Debian should
probably have the last partition. I'm not 100% sure on this since I
don't use my sdcard for anything else.
2. Format the new partition.
ext2 is probably best. (least abusive on the sdcard. ext3 & 4 have
journaling which may be bad for the life of your sdcard)
I used Gparted for this part as well.
3. If you are installing from an Ubuntu or Debian desktop, install debootstrap
Code:
$ sudo apt-get install debootstrap
Users of other distros may be able to get debootstrap but I'm not sure.
4. Mount the sdcard on your desktop.
anywhere will do just remember where you put it
ex.
Code:
$ mount /dev/sde2 /mnt/android
5. debootstrap
run debootstrap
you can change to a mirror closer to you if you don't want to use the
US mirror - http://www.debian.org/misc/README.mirrors
I'm using the Debian testing release (squeeze). I had issues getting
X11 running in lenny, and have not tested sid.
(lenny is stable, squeeze is testing, and sid is unstable)
http://www.debian.org/releases/
debootstrap --arch armel --foreign <release> </path/to/debian> <mirror>
ex:
Code:
# debootstrap --arch armel --foreign squeeze /mnt/android http://ftp.us.debian.org/debian
6. debootstrap(part2)
Unmount the sdcard from your desktop.
Reboot the phone here since you've been mucking with the sdcard
file system. Android didn't like my sdcard until I did.
Code:
$ adb shell
mount the sdcard somewhere on the android file system.
look in /dev/block for the sdcard.
Typically mmcblk0p# where # is the partition number.
*note* the directory I use to mount mine does not exist under normal android.
If this is your first time you will need to create the directory.
Code:
mkdir -p /data/local/mnt
ex.
Code:
# mount -t ext2 /dev/block/mmcblk0p2 /data/local/mnt
chroot/debootstrap
Code:
# export PATH=/usr/bin:/usr/sbin:/bin:$PATH
# chroot /data/local/mnt/ /debootstrap/debootstrap --second-stage
this will take a while especially if you have a slower sdcard.
6. While that's working, now is a good time to get to work on your kernel
I used the open source android kernel 2.6.29
http://android.git.kernel.org/
Started with mahimahi_defconfig and starting customizing from there.
Things to note.
- file systems - don't forget to add support for whatever file systems
you need. Your root file system support cannot be built as a module.
- wireless driver config - You may want to change the location the
kernel looks for your wifi firmware (this is different from the
kernel module).
I stuck mine in /etc/firmware, default is /system/etc/firmware.
If you don't change this, you will have to put the firmware
in /system/etc/firmware
- wireless - Add in support for standard wifi extensions.
- networking - standard tcp/ip stuff... iptables if you want ect...
- I wasn't able to get the kernel to boot into Debian until I turned
off initramfs support.
(note. this was before I discovered the 'noinitrd' kernel
kernel cmdline option. So disabling initrd may not be required)
- If for some reason you are using ext4, it will fail to mount unless
you add in large devices and files support
- Default kernel command string - has no effect.
This gets overwritten when you boot with fastboot or make a boot.img
- Drivers - I left all the normal android drivers in.
-Changed the firmware path for wifi.
-Added in support for virtual terminal under character devices
-Enabled MSM serial support (if you don't have a serial cable
this is useless to you)
-You can build the wifi driver into the kernel if you want.
Link to the kernel config I used. Use at your own risk.
It works for me but I can't promise it's perfect or even good.
http://irregular-expression.com/tmp/config
I would love input on building a better kernel config.
If you don't want to build your own kernel, feel free to use mine http://irregular-expression.com/tmp/zImage
7. Chroot and configure Debian.
There are still some things that need configuring before we reboot into
Debian. Since fbconsole does not appear to be working, if you don't
have a serial cable you will be flying blind until Debian is fully
booted and you can connect with ssh. Since there are still things to do
before we reboot, we're going to chroot into Debian just like if we are
using a Debian chroot image.
For more information and examples of config files.
http://www.debian.org/releases/stable/arm/apds03.html.en
It's probably best to use wifi for your data on the phone for this.
If you're on Linux and connected to the same router as the phone, copy
over your resolv.conf
Code:
$ adb push /etc/resolv.conf /data/local/mnt/etc/resolv.conf
If you are not in Linux or are not connected to wifi you will need to
set up resolv.conf with something sane.
ex. from jay freeman's original Debian chroot.
Code:
$ echo 'nameserver 4.2.2.2' > /data/local/mnt/etc/resolv.conf
push wifi driver to the device
First we need to create a couple directories. Log into the phone with adb shell
Code:
$ adb shell
# mkdir -p /data/local/mnt/etc/firmware
# mkdir -p /data/local/mnt/lib/modules/2.6.29-droid-debian/kernel/drivers/bcm4329
# exit
Upload wifi kernel module and firmware. If you're using my prebuilt kernel, grab this one. http://irregular-expression.com/tmp/bcm4329.ko
Code:
$ adb push <kernelroot>/drivers/net/wireless/bcm4329/bcm4329.ko /data/local/mnt/lib/modules/2.6.29-droid-debian/kernel/drivers/bcm4329/
copy /system/etc/firmware/fw_bcm4329.bin to wherever you
specified in the kernel config.
Code:
# cp /system/etc/firmware/fw_bcm4329.bin /data/local/mnt/etc/firmware/
Setup environment variables, copy over adbd, and other stuff needed to
make things work. This should all be run from within an adb shell
Code:
# cp /sbin/adbd /data/local/mnt/sbin/adbd
# sysctl -w net.ipv4.ip_forward=1
# export PATH=/usr/bin:/usr/sbin:/bin:$PATH
# export TERM=linux
# export HOME=/root
Next chroot and setup mount points
Code:
# chroot /data/local/mnt /bin/bash
# mount -t devpts devpts /dev/pts
# mount -t proc proc /proc
# mount -t sysfs sysfs /sys
Welcome to Debian chroot that we all know and love.
Lets finish configuring this thing.
Configure adbd to run on boot and create a symlink so adbd can find bash.
Edit /etc/rc.local. Add adbd before exit 0
#add this to /etc/rc.local
Code:
/sbin/adbd &
Code:
# mkdir -p /system/bin/
# ln -s /bin/bash /system/bin/sh
Now we need to be able to install packages
don't forget if you are not using squeeze to change it here
Code:
# echo 'deb [url]http://ftp.us.debian.org/debian[/url] squeeze main' >> /etc/apt/sources.list
# apt-get update
You should see aptitude updating it's package list.
Install some needed packages
Code:
# apt-get install wpasupplicant wireless-tools udev ssh
Other packages
All up to your choice. Things like text editors, X, ect...
some suggested packages
Code:
# apt-get install locales vi
Wifi driver
When you try to load the wifi module, Linux will complain about not
being able to parse modprobe.d. To fix this run depmod. If it complains
a directory doesn't exist then create it.
Code:
# depmod -a
Edit /etc/modules and add the bcm4329 module
Code:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
bcm4329
Setup fstab - critical: don't forget to configure the root file system
or your system won't boot. If you like, mount your vfat sdcard partition
here too. Don't forget to mkdir for the mount point.
*note* after boot the memory card is located at /dev/mmcblk0p#.
Here is my /etc/fstab
Code:
# /etc/fstab: static file system information.
#
# file system mount point type options dump pass
/dev/mmcblk0p2 / ext2 defaults 1 1
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /media/sdcard vfat defaults 0 0
configure network
These two files will be tuned to what you need.
Here are a couple examples.
/etc/network/interfaces
Code:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
/etc/wpa_supplicant.conf
Code:
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="myOpenNetwork"
scan_ssid=1
key_mgmt=NONE
}
network={
ssid="MyHomeNetwork"
scan_ssid=1
key_mgmt=WPA-PSK
psk="MyWifiPassword"
}
network={
ssid="MyFriendsWifi"
scan_ssid=1
key_mgmt=WPA-PSK
psk="MyFriendsWifiPassword"
}
SSH
If you want ssh to start on boot run this command.
*note* You will probably want to set a static IP address if you plan on accessing debian through ssh.
Code:
# update-rc.d ssh defaults
inittab
no need for getty so comment it out in /etc/inittab
if you have a serial cable, configure it here. something like this.
Code:
T0:23:respawn:/sbin/getty -L ttyMSM0 115200 linux
hostname
configure your system's hostname - you can set this to whatever you like
Code:
# echo DebianHostName > /etc/hostname
Set root password
Code:
# passwd
# useradd -m -G audio,dialout,floppy,video,staff username
Add user account
Code:
# useradd -m -G audio,dialout,floppy,video,staff yourusername -s /bin/bash
# passwd yourusername
8. Almost there!
Double check your configs and have your kernel handy.
The next step is to boot into Debian.
9. Boot Debian
put the device into fastboot mode
Code:
$ adb reboot bootloader
the '-c' flag specifies arguments to pass to the kernel for boot.
This is probably the bare minimum.
Format is "fastboot -c 'kernelcmdline' boot zImage"
Code:
$ fastboot -c 'root=/dev/mmcblk0p2 rw rootfs=ext2 init=/sbin/init rootwait noinitrd' boot zImage
Wait just a few minutes. DHCP is probably the longest part of this.
10. Connect via ADB.
If everything went well you should be able to log into the
phone via adb. adb push and pull work as well.
Code:
$ adb shell
11. Install X11
For a basic X11 install. This is probably not what you want.
Code:
# apt-get install xserver-xorg
You can install whatever window manager/desktop environment you like,
I used XFCE. Most window managers likely depend on xserver-xorg so it
will get pulled in when you install.
Code:
# apt-get install xfce4
After I installed xfce4 I was able to get X on the main display by
simply running startxfce4
Code:
# startxfce4
By default Debian is configured to only allow root to startx.
If you want to be able to run X as a user edit /etc/X11/Xwrapper.config
*note* even with this I haven't been able to run X as a normal user.
Only root.
Change
Code:
allowed_users=console
to
Code:
allowed_users=anybody
Currently touchscreen is a little weird. It feels almost like using a
laptop touchpad. The mouse moves much faster then your finger and tapping for
click isn't enabled by default but two finger tap will right click. You can
also move the mouse with the trackball. Clicking the trackball registers a
click. But you have to wiggle the trackball just a tiny bit after you click to
make it register. I am going to work on tweaking the fdi policy files to
make things a little more usable.
Text entry is a bit of a pain point currently. There are several on screen
keyboards out there. One interesting one I found is called cellwriter.
The touchscreen will need to be tweaked before it will work well with
onscreen keyboards.
For other ideas on window managers and other software check out this link
http://wiki.openmoko.org/wiki/Debian
@jairuncaloth
I was just reading about how you got debian + x11 working on your nexus. I think thats awsome how you got a fully oprerational linux OS on your phone. I just had a few questions on how everything worked.
You were saying it doesn't mess with the default android OS, is there like a duel boot option to chose what OS i want to boot into. I was reading on how you have to start an ssh session to get into debian, and was just currious on some more info. I would be intrested in trying this out some time after i did a little more reading to get a better understanding of how everything was working.
If this wasn't working out after i installed, is it a pain to remove.
Thanks,
Justin
Nice post, appreciate the thoroughness.
I'm going to pour through this when I get some free time. Whenever that is
Thanks!
~enom~
jjkwasnik said:
@jairuncaloth
I was just reading about how you got debian + x11 working on your nexus. I think thats awsome how you got a fully oprerational linux OS on your phone. I just had a few questions on how everything worked.
You were saying it doesn't mess with the default android OS, is there like a duel boot option to chose what OS i want to boot into. I was reading on how you have to start an ssh session to get into debian, and was just currious on some more info. I would be intrested in trying this out some time after i did a little more reading to get a better understanding of how everything was working.
If this wasn't working out after i installed, is it a pain to remove.
Thanks,
Justin
Click to expand...
Click to collapse
Hey Justin. The reason it doesn't mess with the default android OS is when you boot, you're booting with a kernel image living on your desktop/laptop's hard disk. fastboot allows you to boot images without acctually flashing them to your phone. Debian lives on the SDcard so no flashing required.
You can also use adb to connect to debian now. It's as simple as copying over the binary from android.
Removing is as simple as rebooting. When you reboot it will be like debian was never there.
enomther said:
Nice post, appreciate the thoroughness.
I'm going to pour through this when I get some free time. Whenever that is
Thanks!
~enom~
Click to expand...
Click to collapse
I would love to hear ideas for improvements you may have
This is still pretty raw.
now my question is can those devs good with the linux kernel use this to hack into the android OS and unlock the security on the device without bricking the phone?
-Charlie
@jairuncaloth
I understand what you mean, i have used fast boot a few times. I know how to use it, just haven't used it a lot. So with using fast boot, once Debian is booted can you disconnect the usb cable. Is the kernel copied in RAM, or does it still need to talk to the kernel that resides on the PC?
I like where you are going with this, i am experienced with Linux. Not super advanced, but i know more then i think i do sometimes. I would like to try this out sometime to, but i'm very busy with work and the little free time i have gets spent before i know it. So knowing a little about it before i get my feet wet, always helps.
Thanks!!
Great news guys! Glad to see progress is being made. Can't wait to see where this goes from here!
Cheers
this is so cool, i was trying to get the chroot version to run on my nexus one the other day like i had it on my g1 but it was giving me trouble so i gave up. if proper support for the radio and the touchscreen/keyboard is created this would truly be monumental.
kudos for you man awesome job!
jjkwasnik said:
@jairuncaloth
I understand what you mean, i have used fast boot a few times. I know how to use it, just haven't used it a lot. So with using fast boot, once Debian is booted can you disconnect the usb cable. Is the kernel copied in RAM, or does it still need to talk to the kernel that resides on the PC?
I like where you are going with this, i am experienced with Linux. Not super advanced, but i know more then i think i do sometimes. I would like to try this out sometime to, but i'm very busy with work and the little free time i have gets spent before i know it. So knowing a little about it before i get my feet wet, always helps.
Thanks!!
Click to expand...
Click to collapse
Should look something like this after you run the fastboot boot command
creating boot image...
creating boot image - 2240512 bytes
downloading 'boot.img'... OKAY
booting... OKAY
At this point it's safe to pull the usb cable. If you are using adb to connect, you'll still want it though
I got the code aurora X driver to build last night. I ended up building it in debian on the phone. I couldn't get it to build against AOSP kernel headers, but it does build with the code aurora kernel headers. X won't start when you tell it to use the driver. I suspect this is because I built the driver against a different kernel then the one the system is booting on. I have not been able to get the code aurora kernel to boot yet, but I'm working on it to see if X will start with this driver and the CA kernel.
Also, I've uploaded the kernel I've been using to my blog. In case someone wants to play with this, but doesn't want to build a kernel.
http://irregular-expression.com/tmp/zImage
Can anyone post any vids for this?
Would love to have a look at this and then maybe i'll have a try at it afterwards
No videos yet.. I've got some snapshots of X running though.
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
jairuncaloth said:
No videos yet.. I've got some snapshots of X running though.
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
Click to expand...
Click to collapse
Thank you for the pictures, it really feels good to see this kind of progress being made. I can not wait to try this out!
looks interesting, but scary to a new guy like me..im sure i will try it though..continue the work on streamlining the process !
so how is this running? by that i mean is everything running smooth/snappy?
looks good by the way, i may try this out
JHaste said:
so how is this running? by that i mean is everything running smooth/snappy?
looks good by the way, i may try this out
Click to expand...
Click to collapse
It's fast enough for you old man!
Really though, it runs pretty smoothly. Once we work out the kinks it could even be pretty nice.
One thing you could do, if you don't mind nuking the recovery partition, is flash your debian boot image to recovery -- then you can reboot into debian with "reboot recovery" from an android root shell, or by entering the bootloader and selecting recovery.
it will be great if it is more simple.
@jairuncaloth
I love the pics man!!!
I just came up with another question with running Debian, is there any software to still make phone calls through your cell provider? Or do you just have to reboot back into android?

[DEV] Reworked process for running Ubuntu on Nexus One (Device busy error eliminated)

Few months ago, there was a post on XDA:
http://forum.xda-developers.com/showthread.php?t=718952
and a link to:
http://nexusonehacks.net/nexus-one-hacks/how-to-install-ubuntu-on-your-nexus-oneandroid/
They explain how to install and run Ubuntu on Nexus One.
But a lot of people got problems when running script bootubuntu and ubuntu.sh, and I was one of them.
After Cyanogen Mod 6.0 was released, I could successfully run Ubuntu according to given instructions, but later I discovered the two scripts (ubuntu.sh and bootubuntu) don't always work, and I found them very complex and unnecessary statements can be removed.
Since few months ago I've been refining the two scripts to make them able to boot Ubuntu with less likelihood to get error. I thought I would like to share my findings to everyone interested.
Here are some reasons why it's useful to have Ubuntu on Nexus One
1. Fully functional web browser Firefox
2. Fully functional office suite OpenOffice
3. Fully functional Linux terminal with lots of ultilities
4. Fully functional image manipulation tool Gimp
5. Ability to run lots of useful native Linux programs
6. Python, gcc, g++..
I'll talk about my findings in next few posts.
Post #2: simplify ubuntu.sh, remove unnecessary script files
Post #3: simplify bootubuntu, forcibly umount
Post #4: how to shutdown Ubuntu properly if terminal application was closed by Android
Post #5: a little script which should be run before exiting from Ubuntu
Post #6: how to start GNOME desktop (instead of LXDE) and get correct keyboard mapping
Post #7: a possible solution to loop device's "resource or device busy" error
About my Nexus One:
bought on 2nd March
Cyanogen Mod 6.0
IntersectRaven HAVS CM CFS 1020 kernel
Busybox 1.17
Radio 5.0.8
Gapps hdpi 20101020.1
Please don't hesitate to tell me if I made any mistake, I'm a Linux beginner because I taught myself Linux, my University will teach Unix next semester.
Attachment: ubuntu_scripts.zip
contains all modified scripts.
Finding #1:
In original Zip package, there are five scripts, but only two of them are actually used to install and boot up Ubuntu.
fsrw, mountonly, unionfs are not necessary to install and boot ubuntu, thus their reference can be removed from ubuntu.sh
Here is my simplified version of ubuntu.sh
#-------------------------------
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
rm -f /system/bin/bootubuntu
rm -r -f /data/local/ubuntu
cp -f bootubuntu /system/bin
cd /
echo "Type 'bootubuntu' to boot Ubuntu"
#-------------------------------
Simplified ubuntu.sh removed unnecessary statements to reduce risk of error.
Also I discovered:
Files in /sdcard/ubuntu can not be chmod, and it's unnecessary to chmod 4777 to them.
chmod 4777 /system/bin/* will cause some Android softwares to malfunction (e.g. Orbot), also it *possibly* cause some roms to fail to boot up next time (CM6.0)
Finding #2:
Here's my simplified bootubuntu script, there are minor changes to script flow and removed all unnecessary statements:
#-------------------------------
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
echo "SETTING VARIABLES"
export bin=/system/bin
export mnt=/data/local/ubuntu
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
if [ ! -d /data/local/ubuntu ]
then
mkdir /data/local/ubuntu
fi
echo "SETTING UP LOOP DEVICE"
losetup /dev/block/loop1 /sdcard/ubuntu/ubuntu.img
echo "MOUNTING"
mount -t ext2 /dev/block/loop1 /data/local/ubuntu
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
echo "SETTING UP NETWORK"
sysctl -w net.ipv4.ip_forward=1
echo "nameserver 208.67.222.222" > $mnt/etc/resolv.conf
echo "nameserver 208.67.220.220" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "Brought to you by NexusOneHacks.net and the open source community! "
chroot $mnt /bin/bash
echo "UMOUNTING"
umount -lfr $mnt/dev/pts
umount -lfr $mnt/proc
umount -lfr $mnt/sys
umount -lfr $mnt
losetup -d /dev/block/loop1
#-------------------------------
and it forcibly,lazily,read-only-if-failed umount $mnt, thus losetup -d will less likely to fail and eliminate the problem when booting ubuntu second time.
Finding #3:
If terminal application is terminated automatically by Android system, in this situation, the Ubuntu is not properly umounted.
Thus we change ubuntu.sh into:
#------------------------------
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
rm -f /system/bin/bootubuntu
rm -f /system/bin/exitu
rm -r -f /data/local/ubuntu
cp -f bootubuntu /system/bin
cp -f exitu /system/bin
cd /
echo "Type 'bootubuntu' to boot Ubuntu"
#------------------------------
and we create a new script named "exitu" in sdcard/ubuntu directory:
#------------------------------
export mnt=/data/local/ubuntu
echo "UMOUNTING"
umount -lfr $mnt/dev/pts
umount -lfr $mnt/proc
umount -lfr $mnt/sys
umount -lfr $mnt
losetup -d /dev/block/loop1
#------------------------------
remember to run "sh ./ubuntu.sh" to copy new exitu script into /system/bin.
Then whenever you went back to terminal, found Ubuntu terminal is gone, simply type exitu (remember to be su first) to exit ubuntu, then bootubuntu again to enter ubuntu terminal. It's harmless to execute exitu multiple times to ensure $mnt is umounted successfully.
Sometimes exitu still can not successfully remove loop1 assignment with /sdcard/ubuntu/ubuntu.img, but seems like it doesn't really matter, ubuntu still can boot up successful even loop1 was not unassigned successfully
Finding #4:
To reduce likelihood of getting "device or resource busy" error when removing loop device assignment, it's good to have this script in your Ubuntu, and run the script before exiting from Ubuntu:
#-------------------
export USER=root
vncserver -kill :1
vncserver -kill :2
sudo reboot
sudo halt
#-------------------
(remember, the script should be in your Ubuntu's file system, not your android's file system!)
run the script before you exiting from Ubuntu, this will greatly reduce likelihood of getting device or resource busy error when exiting.
Finding #5:
For those of you who prefer to enter GNOME desktop manually (no automatically start-up), this script may help, also this script should be able to fix androidVNC keyboard mapping problem:
(this script should be in Ubuntu)
#--------------------
cd /
rm -r -f tmp
mkdir tmp
cd /
export USER=root
export XKL_XMODMAP_DISABLE=1
vncserver -geometry 800x600
#--------------------
regarding the guide:
http://nexusonehacks.net/nexus-one-hacks/how-to-install-ubuntu-on-your-nexus-oneandroid/
if you would like to enter gnome and not to autostart desktop environment, please don't follow its instruction on making change to /root/.vnc/xstartup and /root/.bashrc
instead, create a script as I mentioned above, and run the script to bring up VNC server, and you will get GNOME desktop in VNC with correct keyboard mapping
Finding #6
If you're constantly getting "device or resource busy" error when mounting loop1 to /data/local/ubuntu, the reason might be caused by Android App2SD (Froyo version), if you have any software installed on SD card, it may cause all loop devices to be busy all the time (even newly created loop device!) And busy loop device can not be mounted, thus generates "device or resource busy" error message.
Most people had the same problem few months ago, when they execute bootubuntu, they get an error saying loop device is busy, and even changing loop device wouldn't help.
Now I think the reason is determined. After uninstalled all applications which are on SD card (or move all of them from SD card to internal storage), the Ubuntu can boot successfully without getting "device or resource busy" error when mounting loop device.
Edit 2010-11-04:
If bootubuntu gets executed before Android loads all app2sd applications, it is possible solves the loop device busy error even with App2SD applications installed. It requires a very perfect timing, today after few experiments on my phone, I worked out a process which can always boot up Ubuntu on my phone:
1. Reboot phone
2. as soon as you enter lock screen, unlock screen
3. quickly go to terminal emulator
4. become su by typing su and enter
5. type bootubuntu and wait (type it fast... practice )
-------------
1-5 must be done before SD "Checking for errors" notification disappears, if you fail to do so.. reboot and try again
------------
6. as soon as SD "Checking for errors" notification disappears, hit enter IMMEDIATELY
Now you should be able to enter Ubuntu terminal.
Do NOT exit from your Android terminal (don't press back or home button), wait 1-2 minutes for Android to load applications on SD card.
Once you reboot your phone, you'll need to repeat the above procedure again to enter Ubuntu successfully.
Also chmod 4777 is horrible from a security point of view. It makes all the system bin files writable by anyone and run with root privileges (setuid root).
Sent from my Nexus One using XDA App
houzuoguo said:
Finding #6
If you're constantly getting "device or resource busy" error when mounting loop1 to /data/local/ubuntu, the reason might be caused by Android App2SD (Froyo version), if you have any software installed on SD card, it may cause all loop devices to be busy all the time, thus loop device can not be mounted to /data/local/ubuntu anymore.
Most people had the same problem few months ago, when they execute bootubuntu, they get an error saying loop device is busy, and even changing loop device wouldn't help.
Now I think the reason is determined. After uninstalled all applications which are on SD card (or move all of them from SD card to internal storage), the Ubuntu can boot successfully without getting "device or resource busy" error when mounting loop device.
Click to expand...
Click to collapse
This is because with Froyo apps to SD android creates an encrypted loopback device for each app on the SD card, so depending on the number of apps on your SD card loop0-7 may be in use. I solve this by using a high loop number with losetup - loop99.
Sent from my Nexus One using XDA App
Use a higher loop device, the best option
It worked for me on loop7, but to be on the safe side, decided to use a higher loop number as suggested, but it requires to create the loop device as it doesn't exists, use mknod:
Code:
echo "SETTING UP LOOP DEVICE"
mknod /dev/block/loop99 b 7 99
losetup /dev/block/loop99 /sdcard/ubuntu/ubuntu.img
Now is working on loop99 too!. The clean up section for both bootubuntu and exitu scripts:
Code:
echo "UMOUNTING"
umount -f $mnt/dev/pts
umount -f $mnt/proc
umount -f $mnt/sys
umount -f $mnt
losetup -d /dev/block/loop99
rm /dev/block/loop99
I'm not sure about how I am cleaning up the new node, rm erases it... but is this the best method? rebooting the phone will erase the node anyway so maybe an if clause to test for the node loop99 before creating it will be better.
fralacos said:
It worked for me on loop7, but to be on the safe side, decided to use a higher loop number as suggested, but it requires to create the loop device as it doesn't exists, use mknod:
Code:
echo "SETTING UP LOOP DEVICE"
mknod /dev/block/loop99 b 7 99
losetup /dev/block/loop99 /sdcard/ubuntu/ubuntu.img
Now is working on loop99 too!. The clean up section for both bootubuntu and exitu scripts:
Code:
echo "UMOUNTING"
umount -f $mnt/dev/pts
umount -f $mnt/proc
umount -f $mnt/sys
umount -f $mnt
losetup -d /dev/block/loop99
rm /dev/block/loop99
I'm not sure about how I am cleaning up the new node, rm erases it... but is this the best method? rebooting the phone will erase the node anyway so maybe an if clause to test for the node loop99 before creating it will be better.
Click to expand...
Click to collapse
thanks a lot
I tried this idea already but it seems doesn't work under CM6.0...
and the problem was, every newly created loop device will always be busy, if app2sd is used. (Don't know why)
I'm going to try a different approach, I try to mount loop device to /data/local/ubuntu before Android mounts all app2sd applications
mathrock said:
This is because with Froyo apps to SD android creates an encrypted loopback device for each app on the SD card, so depending on the number of apps on your SD card loop0-7 may be in use. I solve this by using a high loop number with losetup - loop99.
Sent from my Nexus One using XDA App
Click to expand...
Click to collapse
thanks.
my finding is, Android froyo app2sd uses dm-xx loop devices for sd applications, for example, now I have three games on sd card, by entering mount in terminal, i read that
/dev/block/dm-0,dm-1,dm-2 are used.
After I removed all SD applications and reboot system, all of those dm-xxx devices are not mounted anymore.
Also the only difference between mount result with app2sd and mount result without app2sd is usage of dm-xx devices.
Finally I've found solution to the "device or resource busy" error
but it seems like people are now less interested in running Ubuntu on Nexus One
the original post got more than 35k hits and more than 200 replies
Hi houzuoguo!!
I'm trying to type bootubuntu when enter in system, but i think i'm not fast enough or that not work for me. Everytime i get:
# bootubuntu
SETTING VARIABLES
SETTING UP LOOP DEVICE
losetup: /dev/block/loop1
MOUNTING
mount: mounting /dev/block/loop1 on /data/local/ubuntu failed: Device or resource busy
mount: mounting devpts on /data/local/ubuntu/dev/pts failed: No such file or directory
mount: mounting proc on /data/local/ubuntu/proc failed: No such file or directory
mount: mounting sysfs on /data/local/ubuntu/sys failed: No such file or directory
SETTING UP NETWORK
net.ipv4.ip_forward = 1
bootubuntu: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
bootubuntu: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
bootubuntu: cannot create /data/local/ubuntu/etc/hosts: directory nonexistent
Brought to you by NexusOneHacks.net and the open source community!
chroot: can't execute '/bin/bash': No such file or directory
UMOUNTING
umount: can't forcibly umount /data/local/ubuntu/dev/pts: No such file or directory
umount: can't forcibly umount /data/local/ubuntu/proc: No such file or directory
umount: can't forcibly umount /data/local/ubuntu/sys: No such file or directory
umount: can't forcibly umount /data/local/ubuntu: Invalid argument
losetup: /dev/block/loop1: Device or resource busy
#
Whats the problem then?¿?
Thanks in advance.
devex said:
Hi houzuoguo!!
I'm trying to type bootubuntu when enter in system, but i think i'm not fast enough or that not work for me. Everytime i get:
# bootubuntu
SETTING VARIABLES
SETTING UP LOOP DEVICE
losetup: /dev/block/loop1
MOUNTING
mount: mounting /dev/block/loop1 on /data/local/ubuntu failed: Device or resource busy
mount: mounting devpts on /data/local/ubuntu/dev/pts failed: No such file or directory
mount: mounting proc on /data/local/ubuntu/proc failed: No such file or directory
mount: mounting sysfs on /data/local/ubuntu/sys failed: No such file or directory
SETTING UP NETWORK
net.ipv4.ip_forward = 1
bootubuntu: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
bootubuntu: cannot create /data/local/ubuntu/etc/resolv.conf: directory nonexistent
bootubuntu: cannot create /data/local/ubuntu/etc/hosts: directory nonexistent
Brought to you by NexusOneHacks.net and the open source community!
chroot: can't execute '/bin/bash': No such file or directory
UMOUNTING
umount: can't forcibly umount /data/local/ubuntu/dev/pts: No such file or directory
umount: can't forcibly umount /data/local/ubuntu/proc: No such file or directory
umount: can't forcibly umount /data/local/ubuntu/sys: No such file or directory
umount: can't forcibly umount /data/local/ubuntu: Invalid argument
losetup: /dev/block/loop1: Device or resource busy
#
Whats the problem then?¿?
Thanks in advance.
Click to expand...
Click to collapse
I worked on that problem for few weeks and finally I discovered, once I moved all SD applications back to Internal storage, loop1 no longer be busy.
Are you using Froyo app2sd?
houzuoguo said:
thanks a lot
I tried this idea already but it seems doesn't work under CM6.0...
and the problem was, every newly created loop device will always be busy, if app2sd is used. (Don't know why)
I'm going to try a different approach, I try to mount loop device to /data/local/ubuntu before Android mounts all app2sd applications
Click to expand...
Click to collapse
Some of us are still interested in this info but ubuntu runs pretty slow on the nexus. I say it would be nice to have the newest ubuntu (10.10) installed on the nexus one. Possibly the netbook remix version.
Lou2serious said:
Some of us are still interested in this info but ubuntu runs pretty slow on the nexus. I say it would be nice to have the newest ubuntu (10.10) installed on the nexus one. Possibly the netbook remix version.
Click to expand...
Click to collapse
thanks haha, good to hear that I'm not the only one still interested in running Ubuntu on Nexus One.
I'm thinking, if Nexus Two can be overclocked to 1.4Ghz, together with top class SD card, the speed will be enough to run Ubuntu fluently.
Hi! Thanx for ur work! It helped me.....
Now i´m having another issue....i´m triying either to resize the ubuntu.img to make it bigger so i can install the stuff i want ( clean install has 100 mb left) or (preffered option) mounting my sdcard so i can install the native programs from there...any ideas?¿
I think the simple way is just to create another file bigger.
funkatiko said:
Hi! Thanx for ur work! It helped me.....
Now i´m having another issue....i´m triying either to resize the ubuntu.img to make it bigger so i can install the stuff i want ( clean install has 100 mb left) or (preffered option) mounting my sdcard so i can install the native programs from there...any ideas?¿
Click to expand...
Click to collapse
You might want to build your own rootfs - check this site out - it worked great for me.
https://wiki.ubuntu.com/ARM/RootfsFromScratch

[WIP] [DEV] [HOWTO] Ubuntu on Nook Color! UPDATE 1/5/11

DISCLAIMER: You know the risks, bricking, breaking etc. I'm not, nor is anyone else responsible if something goes wrong with your device, especially should it turn into a cave troll and bludgeon someone to death.
You will have to be rooted for this to work.
Update 1/5/11
Changed the install and loader scripts re-compressed and uploaded, new download link. Stream lined the installation process (removed 5 steps)
Update 1/4/11
reflect changes to ubuntu.sh and bootubuntu scripts and streamlining the process. Added screenshots
_________________________
I was over at nexusonehacks.net and looking at the ubuntu on nexus one hack and was thinking that this could be ported to the nook color. The idea is to run ubuntu from an img on the sd card.
The following is a modified version of the "how to" orginally posted here
http://nexusonehacks.net/nexus-one-hacks/how-to-install-ubuntu-on-your-nexus-oneandroid/
Credits
The guys at NexusOneHacks
xda user munday who has modified the scripts to work for the nook color
Devs at XDA Developer for the Ubuntu ARM image for HTC HD2
Saurik (Jay Freeman) for the Debian G1 script, which was hacked for Ubuntu on Nexus One! and then re-hacked for the Nook Color by munday
Here we go:
1) Go download the ubuntu file here: http://www.megaupload.com/?d=67BU4Y3T
2) Extract the contents using 7zip http://www.7-zip.org/download.html
3) Copy the extracted folder "ubuntu" to the root of your SD card
4) Unmount the nook from your pc, go into the app NookColor Tools (if you don't have it download it here courtesy of Ben 74 and click All Settings->Development then uncheck Auto Mount. This will prevent the SD card from being mounted automatically when plugged into the PC
5) Plug the Nook back into your pc and open a command line then navigate to your android sdk folder ie C:\android-sdk or wherever you have it and type
Code:
adb devices
Hit enter and make sure that the nook color comes up (should be the SN of your Nook)
Note: This can also be done from terminal emulator instead of adb...but it is kind of a pain
6) Now we want to go into the command line on the nook so type
Code:
adb shell
Hit enter and this should bring up a "#" sign.
7) Type
Code:
su
hit enter (I do this just as a force of habit)
8) Now we navigate to the ubuntu folder we just copied to our sd card by entering
Code:
cd /sdcard/ubuntu
hit enter. To confirm you are where you want to be you can type
Code:
ls
and it should list the contents of the ubuntu folder.
9) Run the setup script ubuntu.sh by entering the following:
Code:
sh ./ubuntu.sh
hit enter
10) Now type
Code:
bootubuntu
and hit enter
11) So now we have ubuntu command line up and running which should look like:
Code:
[email protected]:/#
We will need to get some packages to run a gui and then connect to it via VNC client. So we need to update a few things first. Type:
Code:
apt-get update
then
Code:
apt-get install tightvncserver
now we need the gui elements so enter this:
Code:
apt-get install lxde
12) Type the following:
Code:
export USER=root
vncserver -geometry 1024×600
this sets the resolution...you can change it to play around, but the native resolution for the nook is 1024x600. This is also where you will set the password for your vnc server...make sure to remember it
13) Next, we are going to add the following to /root/.vnc/xstartup file using cat command: (hit enter after each line and ignore the fact that it looks like it does it twice)
Code:
cat > /root/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
icewm &
lxsession
After hitting enter after the last line press "Ctrl+D" twice then press enter
14) We need the vnc server to start every time we start ubuntu, type this:
Code:
cat > front
export USER=root
cd /
rm -r -f tmp
mkdir tmp
cd /
vncserver -geometry 1024×600
Same as before, hit enter after each line then after hitting enter for the last line press "Ctrl+D" twice then press enter.
15) Enter this
Code:
cat front /root/.bashrc > temp
Then
Code:
cp temp /root/.bashrc
16) Now on the nook open up your vnc viewer app (android vnc viewer or PocketCloud...or whatever you use)
Use the following settings:
Host Address: 127.0.0.1 (some don't require this)
Password: the password you set up in step 16
Port: 5901
Save and then click connect and you should be up and running on ubuntu! To leave ubuntu type exit from adb. This should kill ubuntu. Exit adb and then you can disconnect the nook from your pc.
To start ubuntu from the nook open up a terminal emulater and type:
Code:
bootubuntu
Hit enter, this should bring up the [email protected], hhen press "Home" key and open up your vnc app. Now you are ready to rock your Linux tablet!
You could also use gscript lite to automate the process of starting ubuntu so you don't have to type it in the terminal everytime. You can get gscript lite from the market or download the file I have attached.
It does seem a little laggy..just a little...for now anyway
To exit ubuntu: Disconnect the vnc client then hold the "Home" key (I use button savior which brings up a nice little task manager) and click the Terminal emulator when it pops up under running tasks. Once you are back in the terminal you can type:
Code:
exit
to shut down ubuntu.
Enjoy and make sure you thank munday and the guys at nexusonehacks and all the devs who helped make it possible.
-devastator
EDIT:
I noticed that after rebooting the nook would hang at the "Future of reading" screen....if this happens turn the device off remove the sd card the turn the nook back on. It should boot fine. After it's finished you can return the sd card and mount it. This is strange and I'm looking into it. I'm not sure if this is limited to me or if it is universal to all nooks. It also still fails at shutting ubuntu down for some reason. I'm still looking into this.g into this.
I got it going, just needed a few "busybox"-es here and there . It needs some work, right now to get X you have to use VNC.
It's sluggish but a bit more work might just yield something a bit more usable. I'll play more tomorrow night.
Here's my scripts:
ubuntu.sh
Code:
mount -o remount,rw /dev/block/mmcblk0p5 /system
busybox modprobe ext2
rm -f /data/local/bin/fsrw
rm -f /data/local/bin/bootubuntu
rm -f /data/local/bin/unionfs
rm -f /data/local/bin/installer.sh
rm -f /data/local/bin/mountonly
mkdir /data/local/mnt
#busybox clear
rm /system/bin/fsrw
rm /system/bin/bootubuntu
rm /system/bin/unionfs
rm -/system/bin/mountonly
busybox cp -f fsrw /system/bin
busybox cp -f bootubuntu /system/bin
busybox cp -f unionfs /system/bin
busybox cp -f mountonly /system/bin
cd /sdcard/ubuntu
busybox chmod 4777 *
cd /system/bin/
busybox chmod 4777 *
cd /
#busybox clear
echo " "
echo "Ubuntu Chroot Bootloader v0.1"
echo "Ubuntu Bootloader is now installed!"
echo "This process does NOT damage Android OS!"
echo " "
echo "Original Installer by Charan Singh"
echo "Modified for Ubuntu Chroot by Max Lee at NexusOneHacks.net"
echo " "
echo "To enter the Debian Linux console just type 'bootubuntu'"
bootubuntu
Code:
mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
export mnt=/data/local/mnt
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
busybox mknod /dev/loop2 b 7 0
mount -o loop,noatime -t ext2 $kit/ubuntu.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "Setting localhost on /etc/hosts "
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "READY TO ROCK AND ROLL BABY! "
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo " "
busybox chroot $mnt /bin/bash
#After exit command is executed clear it all up
echo " "
echo "Shutting down Ubuntu"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
Then just followed the instructions at nexusonehacks.
note: to run bootubuntu i had to use sh and the use the full path:
Code:
# sh /system/bin/bootubuntu
other note: I was using adb not a term app on the nook.
Obligatory video
I can't post links yet so check: youtube.com/watch?v=TnXfZ6aagn8 for a really boring video
EDIT: switched the names, DOH!
I also had to use sh and the full path also. Thanks for the update on the script...gonna try it in the morning (it's 2am here) will also see if I can help to get it running smoother. What class SD card are you using? I imagine a class 4 or higher would yeild better results as far as responsiveness goes.
The sd is a class 2 that came in one of my dev phones. I'll pick up a faster one tomorrow after work and test it out.
It's just about 3am here now, we must be in the same time zone.
I'm going to bed now, but first here's a modded version of the script you had originally posted that also works now.
bootubuntu
Code:
#!/bin/sh
mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
busybox [ ! -d /data/local/ubuntu ] && mkdir /data/local/ubuntu
export mnt=/data/local/ubuntu
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
busybox mknod /dev/loop1 b 7 0
busybox losetup /dev/block/loop1 /sdcard/ubuntu/ubuntu.img
mount -t ext2 /dev/block/loop1 /data/local/ubuntu
#mount -o loop,noatime -t ext2 $kit/ubuntu.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "Setting localhost on /etc/hosts "
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "READY TO ROCK AND ROLL BABY! "
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo " "
busybox chroot $mnt /bin/bash
#After exit command is executed clear it all up
echo " "
echo "Shutting down Ubuntu"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
busybox losetup -d /dev/loop1
#unregistering the loopback device just seems to die. need to fix or remove.
I'll look at the N1 formus tomorrow too and see if they have made progress in getting X to run fast or without need for VNC.
Nice work, I am addicted in seeing the crazy crap people are doing everyday.
Couldn't sleep so I'm messing around with it now...I'm using a class 4 and have it up and running. It does seem to be a little laggy, but I don't have a class 2 to compare it to. Let me know what you find out, I'll keep playing with it also to see if I can get it to be more responsive...but we are definately on our way to having a great little linux tablet in addition to android. You should also be able to use this for other builds of linux also by just changing out the .img file to a flavor of your choosing. I'm excited
I have also updated the OP with the how to and credits. Really appreciate your help munday.
I noticed that after rebooting the nook would hang at the "Future of reading" screen....if this happens turn the device off remove the sd card the turn the nook back on. It should boot fine. After it's finished you can return the sd card and mount it. This is strange and I'm looking into it. I'm not sure if this is limited to me or if it is universal to all nooks.
Edit:
Running into some strange occurrences...it appears that when you type exit from the terminal to kill ubuntu, I believe ubuntu stays running...anyway, I'm going to bed and will work on it more tomorrow.
devastatorx said:
You should also be able to use this for other builds of linux also by just changing out the .img file to a flavor of your choosing. I'm excited
Click to expand...
Click to collapse
Are there any increased risks with changing the version you use?
Well, you will want to make sure that the build supports ARM based devices.
munday said:
Then just followed the instructions at nexusonehacks.
note: to run bootubuntu i had to use sh and the use the full path:
Code:
# sh /system/bin/bootubuntu
Click to expand...
Click to collapse
I fixed this, the scripts were backwards, I have updated the OP to reflect the changes and bootubuntu now works
devastatorx said:
I fixed this, the scripts were backwards, I have updated the OP to reflect the changes and bootubuntu now works
Click to expand...
Click to collapse
sweet, i can't wait to get home to play more!!!
I've tried running ubuntu.sh from the terminal emulator (With su) and from ADB, and have not had success with either.
The readout is:
Code:
': File existste '/system/bin
': File existste '/system/bin
': File existste '/system/bin
: not found
: not found
cd: can't cd to /sdcard/ubuntu
: not found
: No such file or directory
: not found
cd: can't cd to /system/bin
: not found
: No such file or directory
: not found
cd: can't cd to /
: not found
: not found
Ubuntu Chroot Bootloader v0.1
Ubuntu Bootloader is now installed!
etc., etc.
Is there a problem with how I copied the script? I assume the first part about the file existing is due to this being the third or fourth time I've tried running the script (Unsuccessfully), but I've no idea how to interpret the rest.
Thanks
munday said:
sweet, i can't wait to get home to play more!!!
Click to expand...
Click to collapse
I sent you a message
Link3737 said:
I've tried running ubuntu.sh from the terminal emulator (With su) and from ADB, and have not had success with either.
The readout is:
Code:
': File existste '/system/bin
': File existste '/system/bin
': File existste '/system/bin
: not found
: not found
cd: can't cd to /sdcard/ubuntu
: not found
: No such file or directory
: not found
cd: can't cd to /system/bin
: not found
: No such file or directory
: not found
cd: can't cd to /
: not found
: not found
Ubuntu Chroot Bootloader v0.1
Ubuntu Bootloader is now installed!
etc., etc.
Is there a problem with how I copied the script? I assume the first part about the file existing is due to this being the third or fourth time I've tried running the script (Unsuccessfully), but I've no idea how to interpret the rest.
Thanks
Click to expand...
Click to collapse
Try using these, just unrar and then copy them in your ubuntu folder, if it asks to overwrite just click yes...also you have autmounting of the sd card turnned off in nook color tools settings right?
Yeah, it must have been an error on my end. Using the updated scripts you posted worked like a charm.
Thanks!
Link3737 said:
Yeah, it must have been an error on my end. Using the updated scripts you posted worked like a charm.
Thanks!
Click to expand...
Click to collapse
Good to hear!
I'm currently working on making this a port to the SD card so that with the sd card in it boots into ubuntu from power off, and with the sd card out it boots to android then you replace the sd and use it for storage like normal. It will also run a lot snappier....well that's the idea anyway.
devastatorx said:
Good to hear!
I'm currently working on making this a port to the SD card so that with the sd card in it boots into android from power off, and with the sd card out it boots to android then you replace the sd and use it for storage like normal. It will also run a lot snappier....well that's the idea anyway.
Click to expand...
Click to collapse
Booting from SD in the same fashion as Nookie Froyo? That sounds like it would give a huge performance boost over the current method, I can't wait to see what you come up with.
This should be acheivable using the method mentioned in this topic:
http://forum.xda-developers.com/showthread.php?t=873243 thanks to clockworx.
Currently looking into this
devastatorx said:
This should be acheivable using the method mentioned in this topic:
http://forum.xda-developers.com/showthread.php?t=873243 thanks to clockworx.
Currently looking into this
Click to expand...
Click to collapse
I was thinking the exact same thing, the nook seems to like booting from sd, so we should be able to set up the partitions like the foryo sd and edit the init.rc and env.txt to boot ubuntu instead of android. Just a theory though. It's my plan for tonight anyway.
munday said:
I was thinking the exact same thing, the nook seems to like booting from sd, so we should be able to set up the partitions like the foryo sd and edit the init.rc and env.txt to boot ubuntu instead of android. Just a theory though. It's my plan for tonight anyway.
Click to expand...
Click to collapse
I also stumbled across this: http://androix.org/ Which talks about a native android xserver which does a way with the vnc aspect altogether. I downloaded and attempted to install but I get the error "There is a problem parsing the package" and I haven't had any luck plus there isn't much documentation.
Let me know how it goes munday, I'll be working on the same thing later (have to take the fiance out for dinner)
question
I was just curious, after installing ubuntu can we install flash as we would had we booted linux from netbook?

[Q] VEGAn Boot Sequence

With VEGAn 5.11 and Pershoot kernel. I want to do a few things when it boots up. I don't see the usual /etc/init.d kind of structure.
I did find init.rc and even found a link that describes its peculiar syntax. But editing that file (after remounting) doesn't "take" -- I assume it is on initfs and gets copied to a RAM disk on boot.
Is there anywhere easily user writeable where you can stick something in the boot sequence? Seems like that would be a common enough thing to need to do.
Thanks!
The init.rc is in the ramdisk, and the ramdisk is in the boot.img (found in all the stock and modded ROMs).
Here's a good guide on how unpack / repack that file: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
(obviously it's a bit technical) What I can tell you is that you don't need any cmdline options for the boot.img
Here's a real quick breakdown of what I do (Ubuntu user):
Code:
./unpack-bootimg.pl boot.img
go to the extracted ramdisk folder, make my changes and then:
Code:
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
cd ..
mkbootimg --kernel boot.img-kernel.gz --ramdisk newramdisk.cpio.gz -o newboot.img
"newboot.img" being my new boot.img. That's how the boot.img in all my mods are created.
Thank you and yeah I figured that was it. Technical is not an issue as I sling unix/linux for ages. Salute to you for all your work on this platform.
Well I cheated a little. Here's what I did:
I noticed that you had added to the bottom of /init.rc a one shot service for /system/etc/shuttle_ins.sh.
So I just remounted rw for /system and added the following to the TOP of /system/etc/shuttle_ins.sh:
# added by aaw
if [ -f /system/etc/rc.local ]; then
sh /system/etc/rc.local &
fi
# end aaw
So now I can put what I want in rc.local -- start up sshd or whatever. In this case here's what I actually wanted:
#!/bin/sh
# this is run at the end of the init.rc sequence if it exists
until mount | grep -m1 sdcard2 ; do sleep 5 ; done # wait for sdcard2 mount
mkdir /mnt/sdcard/sdcard2 # make mount point (might fail, but who cares?)
mount -o bind /mnt/sdcard2 /mnt/sdcard/sdcard2
Of course, this assumes I will always have sdcard2 or it spins. Could put a timeout in I guess, but for me this is always the case. Now things like players that only look in /sdcard can find stuff on sdcard2 as well.
A bit of a hack. I wonder if the release DEVs would consider adding an rc.local in user land in a nicer way? Maybe have a system rc.0 that does the -f test for rc.local and that way if you wanted to add an rc.local you could but if you didn't no harm or foul.
Or did I miss a smarter way to do this?
Thanks for the help (and the great releases, of course!).
I found this in the market: https://market.android.com/details?id=os.tools.scriptmanager
Lets you run scripts at boot time. Haven't tried it for that though, but it could work instead of my rc.local fix. A little different since I assume it runs late (after Android is up) unlike the rc.local which runs before Android, unless I'm mistaken.

Rooting Android OS on a Samsung Chromebook Plus?

I've had the Samsung Chromebook Plus for about 2 weeks now, and I love it! Chrome OS is pretty good at handling itself for notetaking with the stylus, and the gorgeous screen is great for high res stuff (although Chrome OS is in desperate need of DPI scaling). It even runs Android apps out of the box! So far, I only have 2 major gripes about Chrome OS:
-It cannot do multitasking on anything (Android or Chrome app) when in tablet mode (buttons disappear, window drags are disabled) even on the beta branch
-Android cannot be rooted on the Chrome OS (so I think).
That second one is the one I'd like help with. Can you root the Android OS installed on the Chromebook? I'd love to know; I have a game called War Robots I want to play on it, but I can't manually turn down the graphical fidelity without using GLTools.
Any help is appreciated!
Nilithium said:
Can you root the Android OS installed on the Chromebook? I'd love to know; I have a game called War Robots I want to play on it, but I can't manually turn down the graphical fidelity without using GLTools.
Any help is appreciated!
Click to expand...
Click to collapse
Yes, certainly you can root Android on Chrome OS. The rootfs of the Android container is read-only by default, so the method I've been using involves making a writeable copy of the Android rootfs .img in /usr/local, adding SuperSU (adding its binaries to /system/xbin, the SuperSU apk to /system/priv-app, and modifying init.rc to autoload daemonsu), then replacing the original Android rootfs .img file path with a symlink to the rooted one. In addition, a couple of flags (mount-as-read-only and font sharing) need to be changed in one or two of the /etc/init/arc* files (CrOS version dependent), and also the SElinux policy file needs to be patched.
I have written a script to automate the above procedure, if you would like to try it out you can do so by entering the following into the Chrome OS shell (then rebooting).
Code:
curl -Ls https://raw.githubusercontent.com/nolirium/aroc/onescript/RootandSEpatch.sh | sudo sh
You need to be in Dev mode to get into the shell (Ctrl+Alt+T; type 'shell'), and rootfs verification needs to be switched off to modify system files (the script will give you the command to do this, if you haven't already done it).
It would be prudent to make sure any important files are backed up prior to making any changes to the rootfs.
Edit: If any errors occur, or problems are are experienced after using the script, such as Android (apps) failing to load, it's usually not necessary to powerwash. The script makes a backup of the original Android system.raw.img, which can be restored with the following command:
Code:
sudo mv /opt/google/containers/android/system.raw.img.bk /opt/google/containers/android/system.raw.img
Nolirum said:
Yes, certainly you can root Android on Chrome OS. The rootfs of the Android container is read-only by default, so the method I've been using involves making a writeable copy of the Android rootfs .img in /usr/local, adding SuperSU (adding its binaries to /system/xbin, the SuperSU apk to /system/priv-app, and modifying init.rc to autoload daemonsu), then replacing the original Android rootfs .img file path with a symlink to the rooted one. In addition, a couple of flags (mount-as-read-only and font sharing) need to be changed in one or two of the /etc/init/arc* files (CrOS version dependent), and also the SElinux policy file needs to be patched.
I have written a script to automate the above procedure, if you would like to try it out you can do so by entering the following into the Chrome OS shell (then rebooting).
Code:
curl -Ls https://raw.githubusercontent.com/nolirium/aroc/onescript/RootandSEpatch.sh | sudo sh
You need to be in Dev mode to get into the shell (Ctrl+Alt+T; type 'shell'), and rootfs verification needs to be switched off to modify system files (the script will give you the command to do this, if you haven't already done it).
It would be prudent to make sure any important files are backed up prior to making any changes to the rootfs.
Click to expand...
Click to collapse
On a general basis, running scripts from random strangers on the Internet is a bad thing. But I'll take it!
I've encountered an ID10T error though: I set the debugging password during setup, and I THOUGHT that was the sudo password to run your script. Problem is, that's not true, and I've no idea what it is.
Tried Google Account password, no dice.
Tried Chromebook PIN, no dice.
Tried Debug Pass set in Setup, no dice.
Tried password, no dice.
Tried null password (no input), no dice.
What is the sudo password? Did I miss something?
Nilithium said:
What is the sudo password? Did I miss something?
Click to expand...
Click to collapse
Yeah, this seems to be quite a common issue. Perhaps it would be more user-friendly if more information was available during the initial OOB setup, such as a link describing the 'debugging features' feature's features in a bit more depth.
Anyway, if you go into a VT with e.g. Ctrl+Alt+F2, you should be able to log in there as the user 'root' with your debugging password, and then you can run the command chromeos-setdevpasswd to set a sudo password for chronos.
Nolirum said:
Yeah, this seems to be quite a common issue. Perhaps it would be more user-friendly if more information was available during the initial OOB setup, such as a link describing the 'debugging features' feature's features in a bit more depth.
Anyway, if you go into a VT with e.g. Ctrl+Alt+F2, you should be able to log in there as the user 'root' with your debugging password, and then you can run the command chromeos-setdevpasswd to set a sudo password for chronos.
Click to expand...
Click to collapse
DELETE
Worked for me on Samsung Chromebook 3.
Manually downloaded and extracted SuperSU.zip to downloads.
Manually downloaded busybox using curl in shell. Moved it manually to /usr/local/bin/ believe thats correct.
Then re-ran script and it worked.
Anyone tried it on Pixelbook?
Nolirum said:
Yes, certainly you can root Android on Chrome OS. The rootfs of the Android container is read-only by default, so the method I've been using involves making a writeable copy of the Android rootfs .img in /usr/local, adding SuperSU (adding its binaries to /system/xbin, the SuperSU apk to /system/priv-app, and modifying init.rc to autoload daemonsu), then replacing the original Android rootfs .img file path with a symlink to the rooted one. In addition, a couple of flags (mount-as-read-only and font sharing) need to be changed in one or two of the /etc/init/arc* files (CrOS version dependent), and also the SElinux policy file needs to be patched.
I have written a script to automate the above procedure, if you would like to try it out you can do so by entering the following into the Chrome OS shell (then rebooting).
Code:
curl -Ls https://raw.githubusercontent.com/nolirium/aroc/onescript/RootandSEpatch.sh | sudo sh
You need to be in Dev mode to get into the shell (Ctrl+Alt+T; type 'shell'), and rootfs verification needs to be switched off to modify system files (the script will give you the command to do this, if you haven't already done it).
It would be prudent to make sure any important files are backed up prior to making any changes to the rootfs.
Click to expand...
Click to collapse
holy cow, script works flawlessly! (Samsung Chromebook Plus)
Anyone know why my Tivo app and Sirius XM don't work on my new Samsung Chromebook Plus V2? They install and than don't open and crash any other workable apks that anyone knows about? Sirius I can do online Tivo won't play all my recorded shows online just some and I really bought this Chromebook to use the Tivo app to watch shows when not at home or sitting outside. I know this thread is about rooting but I thought someone here may be able to help me. I also posted in the Tivo Community Forum also and am waiting for a response. Thanks!
MsWadera said:
Anyone tried it on Pixelbook?
Click to expand...
Click to collapse
This is the question I'm interested in also as I will be receiving my first PixelBook in a couple of days. Having root access in the Android container along with a Linux install would rapidly move this to my daily driver.
Can anyone confirm this?
phonefreedom said:
This is the question I'm interested in also as I will be receiving my first PixelBook in a couple of days. Having root access in the Android container along with a Linux install would rapidly move this to my daily driver.
Can anyone confirm this?
Click to expand...
Click to collapse
Well, I gave this a try and can say this is a no go for the Pixelbook. It did make Android unusable though causing me to powerwash and reload.
phonefreedom said:
Well, I gave this a try and can say this is a no go for the Pixelbook. It did make Android unusable though causing me to powerwash and reload.
Click to expand...
Click to collapse
When you say it was unusable, did Android (apps) appear to fail to load up completely, just the icon spinning? Or something else?
Did you happen to notice if any errors were shown on the script's output at all?
For example, there was this issue reported on github when the Pixelbook was first released, in which the Android rootfs container created by the script turned out to be a bit smaller than required, and so errors occurred when copying files to the new rooted /system. The user was able to successfully continue after manually editing the script so it created a container that was slightly bigger.
The script has been updated since then to reflect the increased space requirements, so that particular problem should no longer occur. Other potential sources of error might include if there could have been a problem downloading the required files (SuperSU, BusyBox), a problem patching SE Linux (in which case there is a separate script to do this part) , or maybe something else, possibly due to Chrome OS changes/updates.
In the case of the script rendering Android unusable, it's usually not necessary to powerwash. The script makes a backup of the original Android system.raw.img, which can be restored with the following command:
Code:
sudo mv /opt/google/containers/android/system.raw.img.bk /opt/google/containers/android/system.raw.img
Entering the above will restore the original read-only squashfs unrooted rootfs, which, after a reboot, should then load up as normal.
I think I'll edit my earlier post in this thread to add the command to restore from backup. Apologies for failing to mention it here initially. I might add an explicit message in the script itself regarding this, as well.
Flashing zips
Hey first time poster here. This may seem like a newbie question, but how do I flash zips without a custom recovery?
Is there a way to sideload to the container? I tried several apps like Flashfire (used an unofficial build since I could not disable the time bomb on Chrome Os) and Flash Gordon, but it did not seem to work.
Thanks
do-tim said:
Hey first time poster here. This may seem like a newbie question, but how do I flash zips without a custom recovery?
Is there a way to sideload to the container? I tried several apps like Flashfire (used an unofficial build since I could not disable the time bomb on Chrome Os) and Flash Gordon, but it did not seem to work.
Thanks
Click to expand...
Click to collapse
Depends what you want to flash, probably.
You might be able to rewrite the relevant edify commands in the update-binary that you want to flash into an equivalent shell script for the Chrome OS shell.
However, by default the Android rootfs container is in a read-only squashfs format, so normally cannot be modified directly. One way to modify it is to make a writable copy of the container in /usr/local, then replace the original file pathname with a symbolic link to the R/W copy. This works fine for the most part (but does takes up extra disk space, and needs to be re-done after an OS update).
For instance, here is part of the rooting script mentioned upthread, which makes a writable copy of the Android container, copies the files from the original container therein, renames the original to .bk, replaces the original file pathname with a symlink to the copy and, at the end, changes a couple of relevant envs in CrOS's /etc/init/arc-setup-env file.
Code:
#!/bin/sh
# Detect CPU architecture
case "$ARCH" in
x86 | i?86) ANDROID_ARCH="x86";;
x86_64 | amd64) ANDROID_ARCH="x86";;
armel) ANDROID_ARCH="armel";;
arm64 | aarch64) ANDROID_ARCH="armv7";;
arm*) ANDROID_ARCH="armv7";;
*) error 2 "Invalid architecture '$ARCH'.";;
esac
# Make some working dirs
mkdir -p /usr/local/Android_Images
mkdir -p /usr/local/Android_Images/Mounted
mkdir -p /usr/local/Android_Images/Original
# Create container image file. Intel devices need a slightly larger file.
if [ $ANDROID_ARCH=armv7 ]; then
cd /usr/local/Android_Images
fallocate -l 1.7G /usr/local/Android_Images/system.raw.expanded.img
else
if [ $ANDROID_ARCH=x86 ]; then
cd /usr/local/Android_Images
fallocate -l 2.2G /usr/local/Android_Images/system.raw.expanded.img
# Format the .img file.
mkfs ext4 -F /usr/local/Android_Images/system.raw.expanded.img 2>/dev/null
# Set SELinux to permissive.
setenforce 0
# Check that the stock Android container exists and is not already a symlink.
# If this is the case, mount it in order to copy files.
if [ ! -L /opt/google/containers/android/system.raw.img ]; then
if [ -e /opt/google/containers/android/system.raw.img ]; then
umount -l /usr/local/Android_Images/Original 2>/dev/null
mount -o loop,rw,sync /opt/google/containers/android/system.raw.img /usr/local/Android_Images/Original 2>/dev/null
else
# If the stock container's missing, check if there is a backup.
if [ -e /opt/google/containers/android/system.raw.img.bk ]; then
umount -l /usr/local/Android_Images/Original 2>/dev/null
mount -o loop,rw,sync /opt/google/containers/android/system.raw.img.bk /usr/local/Android_Images/Original 2>/dev/null
else
# If there's no backup in the expected location, check in ~/Downloads, too.
# NOTE: We can also use a container from a different device/other OS versions by putting it in ~/Downloads.
# To use a different container, we just need to rename any existing containers in /opt/google/containers/android/
# e.g. rename /opt/google/containers/android/system.raw.img.bk to /opt/google/containers/android/system.raw.img.bk.bk
# Containers from different devices/OS versions are unlikely to boot, however.
if [ -e /home/chronos/user/Downloads/system.raw.img ]; then
echo "Mounting /home/chronos/user/Downloads/system.raw.img and copying files"
umount -l /usr/local/Android_Images/Original 2>/dev/null
mount -o loop,rw,sync /home/chronos/user/Downloads/system.raw.img /usr/local/Android_Images/Original 2>/dev/null
else
echo
echo "Error!"
echo "System.raw.img not found"
echo
exit 1
fi
fi
fi
fi
ANDROID_ROOTFS=/usr/local/Android_Images/Original
# Mount the new .img.
mount -o loop,rw,sync /usr/local/Android_Images/system.raw.expanded.img /usr/local/Android_Images/Mounted
# Copy the files.
cp -a -r $ANDROID_ROOTFS/. /usr/local/Android_Images/Mounted
# Rename the original container to .bk.
if [ -e /opt/google/containers/android/system.raw.img ]; then
if [ ! -L /opt/google/containers/android/system.raw.img ]; then
echo "Moving original Android rootfs image to /opt/google/containers/android/system.raw.img.bk"
mv /opt/google/containers/android/system.raw.img /opt/google/containers/android/system.raw.img.bk
# Make the symlink from the original pathname to our writeable rootfs image.
echo "Replacing original Android rootfs image path with symlink to /usr/local/Android_Images/system.raw.expanded.img"
ln -s /usr/local/Android_Images/system.raw.expanded.img /opt/google/containers/android/system.raw.img
fi
else
if [ -e /usr/local/Android_Images/system.raw.expanded.img ]; then
echo "Creating symlink to /usr/local/Android_Images/system.raw.expanded.img at original Android rootfs image file path"
ln -s /usr/local/Android_Images/system.raw.expanded.img /opt/google/containers/android/system.raw.img
fi
fi
# Change the envs for writeable mount and debuggable in CrOS's /etc/init.
sed -i 's/export WRITABLE_MOUNT=0/export WRITABLE_MOUNT=1/g' /etc/init/arc-setup-env 2>/dev/null
sed -i 's/export ANDROID_DEBUGGABLE=0/export ANDROID_DEBUGGABLE=1/g' /etc/init/arc-setup-env 2>/dev/null
The rooting script is basically just the above, with the addition of a couple of other bits, including the relevant commands from the update-binary script in the SuperSU zip, slightly rearranged from Edify to regular shell script for the CrOS shell. That part of the script can be seen here.
So you could maybe do a similar script, with the files you want to flash. Also, once you have a R/W Android rootfs, it may be possible to update files from directly within Android, although, as mentioned in the last few posts in this thread, on some recent CrOS builds, some people have been running into an issue with the rootfs still getting mounted RO within Android, even with a writable container. This does not occur on all devices though, and should be just a temporary issue.
It would probably also be possible to set up a sort of overlay configuration, somewhat similar to Magisk in effect, but due to the somewhat convoluted mount configuration of the container based system, and the almost constant changes/updates (to the container, its config, and so on) that have been occurring with each update to Chrome OS, this would likely require quite a bit of work to implement and maintain.
Corrective measures to run the script...
Spoke too quickly - all installed but no root detected in SuperSU...
Yes, thanks, it seems to work.
I wonder why the script cannot handle downloading SuperSU & busybox on its own, some corrections are needed.
justqt said:
Worked for me on Samsung Chromebook 3.
Manually downloaded and extracted SuperSU.zip to downloads.
Manually downloaded busybox using curl in shell. Moved it manually to /usr/local/bin/ believe thats correct.
Then re-ran script and it worked.
Click to expand...
Click to collapse
Is it possible that I don't have write access to /system of the Android container or am I doing something wrong?
Davestar2000 said:
Is it possible that I don't have write access to /system of the Android container or am I doing something wrong?
Click to expand...
Click to collapse
Yes, depending on the Chrome OS version you're on, it's possible that the container's still being mounted read-only. They keep changing around some bits and pieces related to the container mount config with (almost) every new version release of the OS. There was a change that they made to config.json (which could be worked around by editing the file) a while back which broke the RW mount, but this was reverted quite quickly. Some other related changes have been made recently though, causing the issue to crop up again.
I've been reluctant to add something in to the script to deal with this read-only mount issue as yet, since the need for it has been CrOS version-dependent. The following fix should work on v69 and 70 (enter it in a Chrome OS root shell):
Code:
sed -i 's|mount rootfs rootfs / remount bind ro|mount rootfs rootfs / remount bind rw|g' /opt/google/containers/android/rootfs/root/init.rc
After a reboot (or just rebooting Android), the container should mount as R/W as expected. Let me know if this doesn't work.
Nolirum said:
Yes, certainly you can root Android on Chrome OS. The rootfs of the Android container is read-only by default, so the method I've been using involves making a writeable copy of the Android rootfs .img in /usr/local, adding SuperSU (adding its binaries to /system/xbin, the SuperSU apk to /system/priv-app, and modifying init.rc to autoload daemonsu), then replacing the original Android rootfs .img file path with a symlink to the rooted one. In addition, a couple of flags (mount-as-read-only and font sharing) need to be changed in one or two of the /etc/init/arc* files (CrOS version dependent), and also the SElinux policy file needs to be patched.
I have written a script to automate the above procedure, if you would like to try it out you can do so by entering the following into the Chrome OS shell (then rebooting).
Code:
curl -Ls https://raw.githubusercontent.com/nolirium/aroc/onescript/RootandSEpatch.sh | sudo sh
You need to be in Dev mode to get into the shell (Ctrl+Alt+T; type 'shell'), and rootfs verification needs to be switched off to modify system files (the script will give you the command to do this, if you haven't already done it).
It would be prudent to make sure any important files are backed up prior to making any changes to the rootfs.
Edit: If any errors occur, or problems are are experienced after using the script, such as Android (apps) failing to load, it's usually not necessary to powerwash. The script makes a backup of the original Android system.raw.img, which can be restored with the following command:
Code:
sudo mv /opt/google/containers/android/system.raw.img.bk /opt/google/containers/android/system.raw.img
Click to expand...
Click to collapse
If it says no android system detected, I downloaded it in 2 parts from here: ( github(dot)com/nolirium/aroc ), followed the instructions, and then it worked for me.
Nolirum said:
Yes, depending on the Chrome OS version you're on, it's possible that the container's still being mounted read-only. They keep changing around some bits and pieces related to the container mount config with (almost) every new version release of the OS. There was a change that they made to config.json (which could be worked around by editing the file) a while back which broke the RW mount, but this was reverted quite quickly. Some other related changes have been made recently though, causing the issue to crop up again.
I've been reluctant to add something in to the script to deal with this read-only mount issue as yet, since the need for it has been CrOS version-dependent. The following fix should work on v69 and 70 (enter it in a Chrome OS root shell):
Code:
sed -i 's|mount rootfs rootfs / remount bind ro|mount rootfs rootfs / remount bind rw|g' /opt/google/containers/android/rootfs/root/init.rc
After a reboot (or just rebooting Android), the container should mount as R/W as expected. Let me know if this doesn't work.
Click to expand...
Click to collapse
thanks for all the help. I have chromebook plus v1,I am on chrome osversion 74. I tried to follow the instruction
but my android apps did not start after restarting. I tried doing it manually but i got stuck at remounting file system as read only. Please help if possible. Thanks again.
Hi,
I'm having problems with this. I have an HP Chromebook with an Intel cpu, Chrome OS Version 75.0.3770.144 (Official Build) (64-bit). When I run the scripts this is the output:
Setting 'ANDROID_DEBUGGABLE: true' and 'WRITABLE_MOUNT: true' in /usr/share/arc-setup/config.json
The file at /opt/google/containers/android/system.raw.img is already a symlink!
Removing symlink
Using /opt/google/containers/android/system.raw.img.bk
Creating new Android system image at /usr/local/Android_Images/system.raw.expanded.img
1814633472 bytes (1.8 GB, 1.7 GiB) copied, 13 s, 140 MB/s
1800000+0 records in
1800000+0 records out
1843200000 bytes (1.8 GB, 1.7 GiB) copied, 25.2601 s, 73.0 MB/s
Formatting system.raw.expanded.img as ext4 filesystem
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 450000 4k blocks and 112672 inodes
Filesystem UUID: fe69179d-f136-475f-84de-007de70ff729
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
Converting system.raw.expanded.img to sparse image
Mounting system.raw.expanded.img
SELinux successfully set to 'Permissive' temporarily
Copying Android system files
Formatting system.raw.expanded.img as ext4 filesystem
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 450000 4k blocks and 112672 inodes
Filesystem UUID: fe69179d-f136-475f-84de-007de70ff729
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
Converting system.raw.expanded.img to sparse image
Mounting system.raw.expanded.img
SELinux successfully set to 'Permissive' temporarily
Copying Android system files
Creating symlink to /usr/local/Android_Images/system.raw.expanded.img
SuperSU files not found in ~/Downloads! Attempting to download BusyBox and SuperSU now...
Downloading SuperSU-v2.82-SR3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5810 100 5810 0 0 5624 0 0:00:01 0:00:01 --:--:-- 9078
Unexpected file size. Trying again...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
50 6756k 50 3407k 0 0 305k 0 0:00:22 0:00:11 0:00:11 311k
Unzipping SuperSU zip, and copying required directories to ~/Downloads.
/usr/local/bin/busybox: 1: /usr/local/bin/busybox: Syntax error: word unexpected (expecting ")")
cp: cannot stat 'common': No such file or directory
cp: cannot stat 'armv7': No such file or directory
Downloading SuperSU-v2.82-SR3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6756k 100 6756k 0 0 328k 0 0:00:20 0:00:20 --:--:-- 351k
chgrp: cannot access '/usr/local/Android_Images/Mounted/system/lib/libsupol.so': No such file or directory
chcon: cannot access '/usr/local/Android_Images/Mounted/system/lib/libsupol.so': No such file or directory
Copying sh from system/bin/sh to system/xbin/sugote-mksh and setting permissions and contexts
Adding extra files system/etc/.installed_su_daemon and system/etc/install-recovery.sh
cp: cannot stat '/home/chronos/user/Downloads/common/install-recovery.sh': No such file or directory
chmod: cannot access '/usr/local/Android_Images/Mounted/system/etc/install-recovery.sh': No such file or directory
chown: cannot access '/usr/local/Android_Images/Mounted/system/etc/install-recovery.sh': No such file or directory
chgrp: cannot access '/usr/local/Android_Images/Mounted/system/etc/install-recovery.sh': No such file or directory
chcon: cannot access '/usr/local/Android_Images/Mounted/system/etc/install-recovery.sh': No such file or directory
Symlinking system/bin/install-recovery.sh to system/etc/install-recovery.sh
Adding system/bin/daemonsu-service.sh
cp: cannot stat '/home/chronos/user/Downloads/common/install-recovery.sh': No such file or directory
chmod: cannot access '/usr/local/Android_Images/Mounted/system/bin/daemonsu-service.sh': No such file or directory
chown: cannot access '/usr/local/Android_Images/Mounted/system/bin/daemonsu-service.sh': No such file or directory
chgrp: cannot access '/usr/local/Android_Images/Mounted/system/bin/daemonsu-service.sh': No such file or directory
chcon: cannot access '/usr/local/Android_Images/Mounted/system/bin/daemonsu-service.sh': No such file or directory
Creating file init.super.rc in Android rootfs
Adding daemonsu service to init.super.rc
Adding 'import /init.super.rc' to existing init.rc
Substituting '|mount rootfs rootfs / remount bind rw' for '|mount rootfs rootfs / remount bind ro' in existing init.rc
A backup of init.rc will be stored as init.rc.old
sed: can't read /../init.rc: No such file or directory
Removing temporary files
Done!
Please check the output of this script for any errors.
Please reboot now, then run script 02SEPatch.sh.
[email protected] / $
Any help would be very much appreciated. I've done a good bit of searching and so far have been unable to figure what the problem is. Thanks alot, guys.
JR

Categories

Resources