[DEV][Tools] simg2img and make_ext4fs binaries for mac OS X - Galaxy Tab 3 10.1 Android Development

Not really a whole lot to describe here. simg2img and make_ext4fs are both linux binaries that are used to unpack / mount / repack system.img from a stock tar.md5 rom. Quite useful.
I get curious as to how much development stuff I can do with OS X from time to time, as, though they are not twins by any means, linux and darwin are definitely cousins. Obviously the simg2img and make_ext4fs binaries in their normal state won't work on any darwin system (os x), however, they ARE unix binaries, and darwin is well... unix
So I downloaded the source code and compiled natively on OS X using xcode / gcc. When compile is done (didn't take long) dropped in /bin and.. viola! Works perfectly.
For those who want a tutorial on how to use these binaries, check here.
To mount sys.raw:
install either macports or homebrew. Then:
Macports: $ sudo port install ext4fuse
Homebrew: $ brew install ext4fuse
After which, cd to the directory you created sys.raw using simg2img.
$ mkdir sys
then, mount with:
$ ext4fuse sys.raw sys
and viola! it's now mounted and you can do what you will with /system
Download links:
simg2img: download
make_ext4fs: download
Homebrew: OS X package manager

just added instructions for mounting sys.raw

To all who do anything development related on Mac OS X / Darwin; let me know if there's any other linux binaries you'd like ported, I feel like doing some more cross-compiling but I can't think of a project.

So awesome
This is awesome. Awesome, awesome, awesome. I just wish there was a better collection of tools because I tried everything (on my Mac), with every single other OS available, just to open a stock Galaxy Note 4 image.
Just one thing though ...
I mounted 'sys' and I don't know what happened but suddenly it unmounted and now the 'sys' folder has disappeared from view ... though I can still see it if I "ls" in its parent directory.
So I tried to 'mkdir sys' again, it says it can't. It also says that "'sys' is taken" if I try to recreate the folder ... I can create a different folder with a different name, but 'sys' is a weird hidden directory now that I can only see in the terminal/shell.
...
Guess I'll reboot.
Rebooting solved the problem and stopped whatever mounting process had been started. But it keeps happening and I can't figure out a way to kill the mount/unmount without restarting my whole Mac ... hmmm ...

Hi there,
great tool for us on OS X, however when I try to build the android image from mounted folder I get this:
can't set android permissions - built without android support
any solution?

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?

Mounting of ext4 formated sd card

This is a (relatively) simple method how to enable ext4 mounting on P5210 with stock, rooted ROM. It should work with any non-stock ROM as well, but it looks like stock is only available for now.
There are two options, fast & easy one and long one.
Fast & easy method
This method involves replacing vold binary with precompiled one. That's usually bad idea as I tested it only on my machines and althought it shouldn't cause any problems in theory, there is no guarantee it will not kill you while sleeping. But, it fast and should work.
So, what to do:
Do backup
Do another backup
Grab vold.ext4support.tar.gz and extract it somewhere
Copy extracted vold binary to device (you can use ADB - adb push vold /storage/sdcard0/)
Open adb shell and mount /system for writing. That's :
$ adb shell
$ su
# mount -o remount,rw none /system/
Create backup of your current vold binary - # cp /system/bin/vold /system/bin/vold.bak
Replace vold binary with one from tarball - # rm /system/bin/vold && cp /storage/sdcard0/vold /system/bin/vold
Make it executable - # chmod 755 /system/bin/vold
Reboot your device.
Now, if everything went fine, you should be able to insert ext4-formated sdcard and get it mounted normaly. Note that sdcardfs will be used to emulate "android-compatibile" filesystem, so user rights are going to be ignored. If you need filesystem with unix rights (for linux in chroot for example), ext4 is mounted to /mnt/obb/extsdcard
If you'r device fails to start (gets stuck on boot screen), just use adb shell to mount /system for writing once again and replace /system/bin/vold with backup you have created in step 6. Or use backups from steps 1-2.
Long method
... invoves compiling android from the source. For real. Because... Why not
Ok, this is for anyone who want's to know what is he putting on his machine or just doesn't believe in random binaries from random guy from internet (and that's actually good way of thinking)
Follow AOSP manual to download Android source code
Follow next part of AOSP manual to build source code, BUT:
Use full_x86 as target
Apply this patch to get vold with ext4 support compilled. Or port your own, from this Cyanogen mod changeset
Compile everything or just vold
Copy your own vold binary from out/target/product/generic_x86/system/bin using Fast method
You can debug everything important here using logcat| grep Vold from Android or, better, adb logcat|egrep "(Vold|DirectVolume|MountService)" from Linux.
Good luck and as usual, I'm not responsible for anything and good at hiding

What are different ways to make system level changes in android?

Requirements :
Need to change some system files
Install one application as system app
I know that above to requirements need rooted device, but device is not of well-known company so there is no support available from CWM, TWRP or any other.
Yet I've some how managed to get some tools and files to install android 5.1 from device manufacturer as below,
Intel's Platform Flash Tool
Also all necessary files such as recovery.img(stalk-read only permission), system.img etc.
Now what I've think of solution so far is to unpack and repack system.img and replace new system.img with existing one and install with Intel's Platform Flash Tool, XDA reference-1.
Unpack :
mkdir sys
./simg2img system.img sys.raw
sudo mount -t ext4 -o loop sys.raw sys/
Repack :
sudo ./make_ext4fs -s -l 512M -a system new.img sys/
sudo umount sys
rm -fr sys
also calculated size = "Block count" * "Block size", XDA reference-2
and after creating sucessully system.img and also installation is also complete with Intel's Platform Flash Tool, bur is not able to boot and stuck at loading screen.
Solutions that I can think of,
Is there something that I'm missing in above method of unpack/repack method of system.img?
I've Intel's Platform Flash Tool, so is there any way to put my changes during installation of android OS?
I've also recovery.img, is it possible to modify this and create custom recovery.img and give read and write permission to system files?
Are there any ohter solutions which meets my requirements?
Any help will be highly appreciated.

Manually Installing RemixOS-Marshmallow [NEW LZ4 System.sfs Extraction]

I'm used to install RemixOS manually on a HardDrive partition and using GRUB for multibooting with Ubuntu, Windows, etc. This time I found some trouble installing new Marshmallow based build. It seems like Jide started using Squashfs+lz4 compression on this build and shipped squashfs-tools with Ubuntu can't manage it.
For the ones who don't know what "manually installing" means:
1- Download RemixOS .zip
2- Extract .zip and mount ISO extracted
3- Copy all ISO contents to a new partition where RemixOS will be installed ~8GB or more
4- Uncompress system.sfs using unsquashfs tool (this will generate system.img)
5- Deleste system.sfs
6- Create "data" folder alongside the files extracted from ISO
7- Make new custom GRUB entry for RemixOS on the correct used partition
8- Boot RemixOS from multiboot GRUB
So the best and easy way to solve the unsquashing problem is to download squashfs-tools source and building it with lz4 support.
Here the steps:
1- We' are going to build squashfs with full support for every available compress method (lzo,lz4,lzma,gzip) so we need dev packages, just run:
Code:
sudo apt-get install liblzo2-dev liblzma-dev liblz4-dev
2- Create a working folder and download squashfs-tools source
3- Open terminal go to working folder and uncompress source:
Code:
tar -zxvf squashfs4.3.tar.gz
NOTE: if they release a new version you need to replace "4.3"
4- Go to source folder and open makefile for editing:
Code:
cd squashfs4.3/squashfs-tools
gedit Makefile
NOTE: if they release a new version you need to replace "4.3"
5- In te Makefile uncomment (erase "#") in the following lines:
#XZ_SUPPORT = 1
#LZO_SUPPORT = 1
#LZ4_SUPPORT = 1
#LZMA_XZ_SUPPORT = 1
6- Compile and Install:
Code:
make
sudo make install
If everything goes right you can now open a new terminal and unsquash every squashfs file you can find and of course new LZ4 compressed from RemixOS. I hope this result helpfull for anyone!
NOTE: If you are not interested in having some un/compress type you can avoid installing xxx-dev corresponding package and DO NOT comment corresponding line on Makefile.
what about on elementary Os?
lukss12 said:
I'm used to install RemixOS manually on a HardDrive partition and using GRUB for multibooting with Ubuntu, Windows, etc. This time I found some trouble installing new Marshmallow based build. It seems like Jide started using Squashfs+lz4 compression on this build and shipped squashfs-tools with Ubuntu can't manage it.
For the ones who don't know what "manually installing" means:
1- Download RemixOS .zip
2- Extract .zip and mount ISO extracted
3- Copy all ISO contents to a new partition where RemixOS will be installed ~8GB or more
4- Uncompress system.sfs using unsquashfs tool (this will generate system.img)
5- Deleste system.sfs
6- Create "data" folder alongside the files extracted from ISO
7- Make new custom GRUB entry for RemixOS on the correct used partition
8- Boot RemixOS from multiboot GRUB
So the best and easy way to solve the unsquashing problem is to download squashfs-tools source and building it with lz4 support.
Here the steps:
1- We' are going to build squashfs with full support for every available compress method (lzo,lz4,lzma,gzip) so we need dev packages, just run:
Code:
sudo apt-get install liblzo2-dev liblzma-dev liblz4-dev
2- Create a working folder and download squashfs-tools source
3- Open terminal go to working folder and uncompress source:
Code:
tar -zxvf squashfs4.3.tar.gz
NOTE: if they release a new version you need to replace "4.3"
4- Go to source folder and open makefile for editing:
Code:
cd squashfs4.3/squashfs-tools
gedit Makefile
NOTE: if they release a new version you need to replace "4.3"
5- In te Makefile uncomment (erase "#") in the following lines:
#XZ_SUPPORT = 1
#LZO_SUPPORT = 1
#LZ4_SUPPORT = 1
#LZMA_XZ_SUPPORT = 1
6- Compile and Install:
Code:
make
sudo make install
If everything goes right you can now open a new terminal and unsquash every squashfs file you can find and of course new LZ4 compressed from RemixOS. I hope this result helpfull for anyone!
NOTE: If you are not interested in having some un/compress type you can avoid installing xxx-dev corresponding package and DO NOT comment corresponding line on Makefile.
Click to expand...
Click to collapse
Could you upload the system.img?
kabelon said:
what about on elementary Os?
Click to expand...
Click to collapse
I have never used it, if you're asking if it will work to do the installation steps for RemixOS, well as it is Ubuntu based I think the answer probably is yes.
Orion116 said:
Could you upload the system.img?
Click to expand...
Click to collapse
I'm on a 1Mbit connection and system.img is 2,7GB so I'm not able to upload it. If you are on windows try to find squash-tools for windows with LZ4 support. If you're running Ubuntu do the steps I have mentioned it's easy an it takes no more than 15 minutes.
lukss12 said:
I'm on a 1Mbit connection and system.img is 2,7GB so I'm not able to upload it. If you are on windows try to find squash-tools for windows with LZ4 support. If you're running Ubuntu do the steps I have mentioned it's easy an it takes no more than 15 minutes.
Click to expand...
Click to collapse
The issue is I am on Manjaro, an arch based OS. I'll try something similar on manjaro
Orion116 said:
The issue is I am on Manjaro, an arch based OS. I'll try something similar on manjaro
Click to expand...
Click to collapse
Try the same thing I described but using pacman I think it will work. If you fail (but I doubt) I will upload the image for you. But please try to do it because it is a big effort for me to spend my poor connection a lot of hours uploading the image.
Edit: just focus on lz4 package
lukss12 said:
Try the same thing I described but using pacman I think it will work. If you fail (but I doubt) I will upload the image for you. But please try to do it because it is a big effort for me to spend my poor connection a lot of hours uploading the image.
Edit: just focus on lz4 package
Click to expand...
Click to collapse
Seems I didn't have to install the packages
---------- Post added at 11:22 PM ---------- Previous post was at 11:17 PM ----------
lukss12 said:
Try the same thing I described but using pacman I think it will work. If you fail (but I doubt) I will upload the image for you. But please try to do it because it is a big effort for me to spend my poor connection a lot of hours uploading the image.
Edit: just focus on lz4 package
Click to expand...
Click to collapse
I got a system.img :good: Now to remember how to set up the grub for it:cyclops:
Orion116 said:
Seems I didn't have to install the packages
---------- Post added at 11:22 PM ---------- Previous post was at 11:17 PM ----------
I got a system.img :good: Now to remember how to set up the grub for it:cyclops:
Click to expand...
Click to collapse
Great.
Add this to custom file in /etc/grub.d
Code:
menuentry "Remix-OS" {
set root='(hdx,y)'
linux kernel root=/dev/ram0 androidboot.hardware=remix_x86_64 androidboot.selinux=permissive quiet DATA=/data
initrd /android/initrd.img}
(hdx,y) makes reference to the partition where you are installing RemixOS, Generally it is (hd0,y) where 'y' is the number of the partition
This setup works if RemixOS files are on root folder of partition
Edit: I need to warn you that my PC hang on a black screen after Setup Wizard on first boot if you have this problem ask me for the workaround
I have it booting but no WiFi, rats. It worked in the last LP build.
lukss12 said:
I'm used to install RemixOS manually on a HardDrive partition and using GRUB for multibooting with Ubuntu, Windows, etc. This time I found some trouble installing new Marshmallow based build. It seems like Jide started using Squashfs+lz4 compression on this build and shipped squashfs-tools with Ubuntu can't manage it.
For the ones who don't know what "manually installing" means:
1- Download RemixOS .zip
2- Extract .zip and mount ISO extracted
3- Copy all ISO contents to a new partition where RemixOS will be installed ~8GB or more
4- Uncompress system.sfs using unsquashfs tool (this will generate system.img)
5- Deleste system.sfs
6- Create "data" folder alongside the files extracted from ISO
7- Make new custom GRUB entry for RemixOS on the correct used partition
8- Boot RemixOS from multiboot GRUB
Click to expand...
Click to collapse
You don't need to unpack the system.sfs if you want
to manually install this. i.e. you don't need #4 or #5; and can save ~1.5GB of space. On the other hand if you want system rw - then you need the ext4 .img [as well as modified initrd.img]; and they seem to have started using better grub configs by default; i.e. using search instead of setting root to a partition.
HypoTurtle said:
You don't need to unpack the system.sfs if you want
to manually install this. i.e. you don't need #4 or #5; and can save ~1.5GB of space. On the other hand if you want system rw - then you need the ext4 .img [as well as modified initrd.img]; and they seem to have started using better grub configs by default; i.e. using search instead of setting root to a partition.
Click to expand...
Click to collapse
I actual just copied the grub.cfg for resident mode from the iso proper and used grub customizer to add it to my triple booted laptop. To bad Boardcom wifi is shot though otherwise it is perfect.
And how to add it to GRUB menu?
gb_14 said:
And how to add it to GRUB menu?
Click to expand...
Click to collapse
You can copy grub.cfg from original ISO into your /boot directory like Orion16 did. Or just edit /etc/grub.d/custom file as I told him in a previous post and run "sudo update-grub"
HypoTurtle said:
You don't need to unpack the system.sfs if you want
to manually install this. i.e. you don't need #4 or #5; and can save ~1.5GB of space. On the other hand if you want system rw - then you need the ext4 .img [as well as modified initrd.img]; and they seem to have started using better grub configs by default; i.e. using search instead of setting root to a partition.
Click to expand...
Click to collapse
Yes androidx86 first test for system.sfs, then system.img and last for system folder. On androidx86 builds I was able to boot with system folder and it was so in first RemixOS builds but now it is not working anymore (RemixOS loops at boot). I think that having installed an OS means also having RW permission over system files but it's just an opinion.
About modified initrd.img you don't need to unpack system.sfs for this method. But currently there is no modified initrd.img for last RemixOS and I don't have the time to do it.
I NEED TO WARN EVERYONE: if you modify system files mounting system.img as RW future OTAs will refuse to install and you will need to replace your custom system with the original one if you want OTA update.
lukss12 said:
Yes androidx86 first test for system.sfs, then system.img and last for system folder. On androidx86 builds I was able to boot with system folder and it was so in first RemixOS builds but now it is not working anymore (RemixOS loops at boot). I think that having installed an OS means also having RW permission over system files but it's just an opinion.
About modified initrd.img you don't need to unpack system.sfs for this method. But currently there is no modified initrd.img for last RemixOS and I don't have the time to do it.
I NEED TO WARN EVERYONE: if you modify system files mounting system.img as RW future OTAs will refuse to install and you will need to replace your custom system with the original one if you want OTA update.
Click to expand...
Click to collapse
I have one posted here
But yea if you go the full way [if you're on ext4] and dump the system.img into a system folder; then you don't need to modify the initrd.img for rw.
I used #1 on Bash for Windows; [just wanted to check the uncompressed system file] so kudos for that
HypoTurtle said:
I have one posted here
But yea if you go the full way [if you're on ext4] and dump the system.img into a system folder; then you don't need to modify the initrd.img for rw.
I used #1 on Bash for Windows; [just wanted to check the uncompressed system file] so kudos for that
Click to expand...
Click to collapse
Good to have an initrd.img but is it RemixOS 3.x based?
About system dump on system folder, it was not working anymore with recent 2.x builds (I haven't tested it on 3.x).
Now RemixOS 3.x build comes with built in SU so I can remount RW system from Terminal or using ESFileExplorer (or similar one) and only need to have system.img for editing files within RemixOS. (I forgot I was using modified initrd.img to achieve this with system.img as you said you need to make system folder dump to edit files within RemixOS and without modified initrd.img)
But as I mentioned it will break OTA... So having an intrd.img is important.
Btw if you see anyone having trouble with new Jide Setup Wizard in 3.x, the fix is to delete /priv-app/JideSetupWizard from system.img or RemixOS will not pass welcome screen
(So no OTA for me until Jide fix this up for my PC)
lukss12 said:
Good to have an initrd.img but is it RemixOS 3.x based?
About system dump on system folder, it was not working anymore with recent 2.x builds (I haven't tested it on 3.x).
Now RemixOS 3.x build comes with built in SU so I can remount RW system from Terminal or using ESFileExplorer (or similar one) and only need to have system.img for editing files within RemixOS. But as I mentioned it will break OTA... So having an intrd.img is important.
Btw if you see anyone having trouble with new Jide Setup Wizard in 3.x, the fix is to delete /priv-app/JideSetupWizard from system.img or RemixOS will not pass welcome screen
(So no OTA for me until Jide fix this up for my PC)
Click to expand...
Click to collapse
Yea, that one is 3.x based. I have a simple script somewhere so that you could make your own [its a simple unpack; search for ro; replace with rw and repack].
And JSW - I just disabled the app [with pm disable com.jide.setupwizard] instead of removing it.
Still not sure how you are getting rw without a rw initrd.img; with RemixOS just because you have su doesn't mean you can remount rw afaik.
Code from stock initrd.img:
Code:
check_root()
{
local r
if [ "`dirname $1`" = "/dev" ]; then
[ -e $1 ] || return 1
blk=`basename $1`
[ ! -e /dev/block/$blk ] && ln $1 /dev/block
dev=/dev/block/$blk
r=$(ls /sys/block/$blk/removable /sys/block/*/$blk/../removable 2>/dev/null)
[ -n "$r" ] && r=$(cat $r) || r=0
else
dev=$1
fi
try_mount ro $dev /mnt || return 1
if [ -n "$iso" -a -e /mnt/$iso ]; then
mount --move /mnt /iso
mkdir /mnt/iso
mount -o loop /iso/$iso /mnt/iso
SRC=iso
elif [ ! -e /mnt/$SRC/ramdisk.img ]; then
return 1
fi
removable=$r
zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
[ -n "$SYSTEM" ] && blk=`basename $SYSTEM` || blk=
if [ -b "/dev/$blk" ]; then
[ ! -e /dev/block/$blk ] && ln /dev/$blk /dev/block
mount -o ro /dev/block/$blk system
elif [ -e /mnt/$SRC/system.sfs ]; then
mount -o loop /mnt/$SRC/system.sfs /sfs
mount -o loop,ro /sfs/system.img system
mount_system_dev_img_if_necessary
elif [ -e /mnt/$SRC/system.img ]; then
mount -o loop,ro /mnt/$SRC/system.img system
elif [ -d /mnt/$SRC/system ]; then
mount --bind /mnt/$SRC/system system
else
rm -rf *
return 1
fi
mkdir mnt
if [ -n "$DEBUG" ]; then
echo " found at $1"
fi
rm /sbin/mke2fs
hash -r
}
HypoTurtle said:
Yea, that one is 3.x based. I have a simple script somewhere so that you could make your own [its a simple unpack; search for ro; replace with rw and repack].
And JSW - I just disabled the app [with pm disable com.jide.setupwizard] instead of removing it.
Still not sure how you are getting rw without a rw initrd.img; with RemixOS just because you have su doesn't mean you can remount rw afaik.
Code from stock initrd.img:
Click to expand...
Click to collapse
You are right!!! I was using a modified initrd for having rw on 2.x and I didn't remember . Will try pm disable thanks :good:
lukss12 said:
You can copy grub.cfg from original ISO into your /boot directory like Orion16 did. Or just edit /etc/grub.d/custom file as I told him in a previous post and run "sudo update-grub"
Click to expand...
Click to collapse
Thanks

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