How to run CoreElec on internal memory eMMC on NG boxes (S905X2, S922X) having full operating Android system too

This is the mod of the original CE 9.2.0 which runs on rootfs ext4 file system.

You can test it after few steps of an easy installation process. The procedure takes only a few minutes - depending on the size of your used storage folder.

The install script will

  • gather data of eMMC
  • count the appropriate partition address and size parameters and store them in local envs
  • check the free space original Android file system and resize the data partition
  • create new ext4 partition exclusively for CE
  • copy all the necessary files from storage to the new ext4 partition

This workaround will let both systems run from eMMC’s appropriate partition which are the halves of the original data partition. The installed and used CE system data will be copied to the new storage by the installer script.
The system will start from SD/USB as before but it is only for load and run the kernel from that.

The new system will not allow to update as usual.

Installation steps:

  • to install this mod you have to start CE from SD/USB as always.
  • download and copy the install-script and the modified kernel image to the Backup share of CE
  • login via SSH and type this 3 lines

cd backup
chmod +x install_ng_ext4.sh
./install_ng_ext4.sh

The whole procedure will run automatically and no user interaction need, after reboot the system will run on the ext4 partition.

More details on the Hungarian Prohardver forum (only Hungarian language pls)

Link for download is here.

9 Likes

If I understand script correctly you still need SD card to boot from?

Also what happen when you update Android? Does it even update?

It reads the SD card for a few seconds and umount the system
Android OTA update working

System boot wery fast 9 sec on X96Max box.

CoreELEC (official): 9.2.0 (Amlogic-ng.arm)
root@CoreELEC:~# systemd-analyze
Startup finished in 2.284s (kernel) + 3.280s (userspace) = 5.564s
kodi.target reached after 3.280s in userspace

1 Like

Seems your emmc is faster then mine :frowning:
This is from Khadas VIM3 with CE installed to emmc with ceemc tool.

vim3:~ # systemd-analyze
Startup finished in 2.500s (kernel) + 8.956s (userspace) = 11.456s
kodi.target reached after 8.955s in userspace

This is what I measured at the eMMC.

root@CoreELEC:~# flash-bench
Creating test file flash-bench.tmp of size 512MB.
Benchmark: Sequential read Limits: Total size: 512MB Duration: 60s
512.0MB processed in 3.52s (145.46MB/s), CPU: user 0.07%, sys 5.60%
Benchmark: Sequential write Limits: Total size: 512MB Duration: 60s
512.0MB processed in 6.98s (73.35MB/s), CPU: user 0.11%, sys 4.35%
Benchmark: Random read Limits: Total size: 512MB Duration: 60s
512.0MB processed in 20.26s (25.27MB/s), CPU: user 0.09%, sys 3.27%
Benchmark: Random write Limits: Total size: 512MB Duration: 60s
512.0MB processed in 8.26s (61.96MB/s), CPU: user 0.09%, sys 5.57%

It would be nice to expose the Android file system in coreelec and symlink it to something like storage/emmc. That way the internal emmc could be used to store the databases and/or thumbnails and/or backups simply by symlinking the appropriate directories to storage/emmc. It would not even need to be the whole android filesystem a sub-directory could be created called .coreelec and that could be symlinked to storage/emmc.

Tested on Magicsee N5 MAX S905X2 box, very fast boot time, fast response in Kodi without any issue.
This procedure turns the box to a real standalone mp without the feeling of starting a computer.

This script mount android data partition on /tmp/data folder and create .coreelec folder.
Run script autostart.sh or create systemd service.
Only for NG box!

#!/bin/sh

DATAOFFSET=$(dmesg | grep mmcblk | grep ’ data’ | awk ‘{ print $7}’| sed “s/.$//g” | head -n 1)
OFFSET=$(printf “%d\n” $DATAOFFSET)
EMMCDEV="/dev/mmcblk0"
LOOPDEV="/dev/loop1"
MNTDIR="/tmp/data"
CEDIR="$MNTDIR/.coreelec"

if [ ! -d $MNTDIR ] ; then
 mkdir "$MNTDIR"
fi
losetup -f -o "$OFFSET" "$EMMCDEV"
mount -o noatime,nodiratime "$LOOPDEV" "$MNTDIR"
if [ ! -d $CEDIR ] ; then
 mkdir $CEDIR
fi

root@CoreELEC:~# df -h | grep /tmp/data
/dev/loop1 12.2G 913.3M 11.3G 7% /tmp/data

root@CoreELEC:~# mount | grep /tmp/data
/dev/loop1 on /tmp/data type ext4 (rw,noatime,nodiratime,resgid=1065,data=ordered)

root@CoreELEC:~# ls -la /tmp/data
total 176
drwxrwx–x 40 1000 1000 4096 Oct 23 11:18 .
drwxrwxrwt 10 root root 240 Oct 23 11:36 …
drwxr-xr-x 2 root root 4096 Oct 23 11:18 .coreelec
-rw------- 1 root root 2 Oct 22 20:36 .layout_version
drwx------ 2 root root 4096 Oct 22 20:41 adb
drwxrwxr-x 2 1000 1000 4096 Oct 22 20:36 anr
drwxrwx–x 6 1000 1000 4096 Oct 22 20:41 app
drwx------ 2 root root 4096 Oct 22 20:41 app-asec
drwxrwx–x 2 1000 1000 4096 Oct 22 20:41 app-ephemeral
drwxrwx–x 2 1000 1000 4096 Oct 22 20:36 app-lib
drwxrwx–x 2 1000 1000 4096 Oct 22 20:36 app-private
drwx------ 6 1000 1000 4096 Oct 22 20:41 backup
drwxr-xr-x 2 2000 2000 4096 Oct 22 20:36 bootchart
drwxrwx— 5 1000 2001 4096 Oct 22 20:36 cache
drwxrwx–x 3 root root 4096 Oct 22 20:36 dalvik-cache
drwxrwx–x 81 1000 1000 4096 Oct 22 20:41 data
drwxrwx— 3 1019 1019 4096 Oct 22 20:37 drm
drwxrwx–x 2 1000 1000 4096 Oct 22 20:41 droidota
drwxr-x–x 4 root root 4096 Oct 22 20:41 local
drwxrwx–x 3 1007 1007 4096 Oct 22 20:36 log
drwxrwx— 2 root root 16384 Oct 22 20:36 lost+found
drwxrwx— 4 1023 1023 4096 Oct 22 20:37 media
drwxrwx— 2 1031 1031 4096 Oct 22 20:36 mediadrm
drwxrwx–t 42 1000 9998 4096 Oct 22 20:41 misc
drwxrwx–t 3 1000 9998 4096 Oct 22 20:41 misc_ce
drwxrwx–t 3 1000 9998 4096 Oct 22 20:41 misc_de
drwxrwx— 3 1027 1027 4096 Oct 22 20:36 nfc
drwxrwx–x 2 root root 4096 Oct 22 20:41 ota
drwxrwx— 2 1000 2001 4096 Oct 22 20:41 ota_package
drwx------ 2 root root 4096 Oct 22 20:38 property
drwxrwx–x 2 1000 1000 4096 Oct 22 20:36 resource-cache
drwx------ 2 1000 1000 4096 Oct 22 20:41 ss
drwxrwxr-x 18 1000 1000 4096 Oct 22 20:41 system
drwxrwx— 3 1000 1000 4096 Oct 22 20:41 system_ce
drwxrwx— 3 1000 1000 4096 Oct 22 20:36 system_de
drwxrwx–x 2 1000 1000 4096 Oct 22 20:36 tombstones
drwx–x--x 2 1000 1000 4096 Oct 22 20:36 user
drwx–x--x 3 1000 1000 4096 Oct 22 20:36 user_de
drwxrwx–x 6 root root 4096 Oct 22 20:36 vendor
drwxrwx–x 3 root root 4096 Oct 22 20:37 vendor_ce
drwxrwx–x 3 root root 4096 Oct 22 20:36 vendor_de

1 Like

Tested on “X96 Max”, installation working without any issue. I can confirm the previous comment. The boot time & Kodi responses are really very fast.

LibreELEC:~ # systemd-analyze
Startup finished in 2.382s (kernel) + 4.477s (userspace) = 6.860s
kodi.target reached after 4.477s in userspace

I suggest to use this solution/script for others.

Emerson: Thanks for sharing this excellent script!

1 Like

I modified the initramfs. 1000 lines shorter init script. Ext4 rootfs is also faster than the compressed squash file system.

1 Like

Thanks for script!
It will work with nightly? And how to update CE later if you said :

?

Majk: if I good understand, this solution works for stable 9.2.0 version only. If you want other version (nightly builds), you need to patch the corresponding kernel image (so, it means auto update function doesn’t works)
Emerson: could you please provide description (source code) how to patch the original CE kernel?

1 Like

Only stable releases are supported.
In the next release I will make the kernel.img file.
The root file system can be updated with rsync. How to later.

#!/bin/bash

DATAOFFSET=$(dmesg | grep mmcblk | grep '  data' | awk '{ print $7}'| sed "s/.$//g" | head -n 1)
OFFSET=$(printf "%d\n" $DATAOFFSET)
EMMCDEV="/dev/mmcblk0"
LOOPDEV="/dev/loop1"
MNTDIR="/tmp/data"
CEDIR="$MNTDIR/.coreelec"
#echo $DATAOFFSET
#echo $OFFSET
#echo $EMMCDEV
#echo $LOOPDEV
#echo $MNTDIR
#echo $CEDIR
if [ ! -d $MNTDIR ] ; then
 mkdir "$MNTDIR"
fi
losetup -f -o "$OFFSET" "$EMMCDEV"
mount -o noatime,nodiratime "$LOOPDEV" "$MNTDIR"
if [ ! -d $CEDIR ] ; then
 mkdir $CEDIR
fi

OK it works I had to tidy up the quotes as the website seemed to mess it up.

test.sh (498 Bytes)

Thanks so perfect.

thanks.Did anyone tryied on Vorke Z6/Tanix TX92?

This version does not work on S912 SOC.
Use this version.
Copy the files to the backup share and run the commands.

Login via SSH and type this 3 lines

cd backup
chmod +x install_ext4.sh
./install_ext4.sh

I tested it on Vorke Z6+ perfect!

Which script does what and why ? I’m interested but I also want to be able to update CE.

Emerson, can you post

dmesg | pastebinit

thanks,
can you explain how to get access to android internal storage after use that second script? Nothing changed in here after run that test.sh script.