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

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.

Any chance to have the script to perform a full emmc/nand installation for being able to boot CE directly without sdcard?

I’ve tried to restore CE original with script and install again but now I have this notice:
Not enough space on Android data partition. Exiting!

How to install now again to eMMC?

Hi,being a bit of a Linux novice …used to do updates/configs via winscp in Windows…
Didn’t work for me this time.
Did it all in linux,burnt image using 9.02 Offical,then put nightly off the 22nd on .

SSH into coreelec, copy over and run scripts .rebooted …now have 32gb for Coreelec storage as that was the size of the SD. SD back into Linux ,deleted STORAGE…not needed. :+1:
Attached USB 3 HDD ,set up shares
Scanned in library…which is super fast.
Was able to scan ,download and install addons at the same time :crazy_face:. .not able to do that before!
Had the same issue when going back to normal resize. Not enough space on Android…reimaged box …took 20mins .

Its definitely worth doing ,very responsive and a lot more fluid .
Many thanks,very pleased …and I know alot more about Linux now :+1::nerd_face:

If you are talking about the test.sh I made from Emerson’s post the android partition is mounted at /tmp/data . You can either symlink it to storage or change MNTDIR="/tmp/data" to set where you want to mount to.

1 Like