I think we can reuse part of ceemmc infrastructure to use storage from emmc in little nicer way.
Use at your own risk ! Same applies to solution above.
mkdir -p /media/data
mount /dev/data /media/data
mkdir /media/data/coreelec_storage
systemctl stop kodi
rsync -ah --info=progress2 /storage/ /media/data/coreelec_storage/
umount /media/data
mf
nano /flash/config.ini
# add this line at the end of the file
coreelec='quiet toram disk=FOLDER=/dev/data'
# and reboot
# check everything was done correctly with command
mount
# before
# /dev/sda1 on /flash type vfat (ro,.....)
# /dev/sda2 on /storage type ext4 (rw,noatime)
# after
# /dev/sda1 on /flash type vfat (ro,,.....)
# /dev/data on /storage type ext4 (rw,noatime,resgid=1065)
# I also add this line in /storage/.config/autostart.sh
# to unmount storage partition from USB stick
mountpoint -q /media/STORAGE && umount /media/STORAGE
…
…
Looks like when booting from USB 2.0 port suspend/resume works better and stick is not remounted.
When booting from USB 3.0 port stick is remounted after resume with new name (sda1 → sdb1).
To get suspend/resume working extra script is needed /storage/.config/sleep.d/01-device-suspend.power
.
#!/bin/sh
# /storage/.config/sleep.d/01-device-suspend.power
if [ ! -f /dev/SYSTEM ] || ! mount | grep -q "/dev/data on /storage"; then
echo "squashfs SYSTEM file is not in ram (use toram bootloader parameter)"
echo "or eMMC partial install is not used"
exit 0
fi
case "$1" in
pre)
# unmount USB partitions
for usb_device in /dev/disk/by-id/usb-*; do
device=$(readlink -f $usb_device)
grep -wq "^$device" /proc/mounts && umount $device
done
;;
post)
finish=0
cnt=0
cnt_max=32
while [ $cnt -lt $cnt_max ]; do
if mountpoint -q /media/COREELEC; then
major_minor=$(mountpoint -d /media/COREELEC)
device=$(readlink -f /dev/block/$major_minor)
umount /media/COREELEC
mount -o ro $device /flash
finish=$((finish+1))
fi
if mountpoint -q /media/STORAGE; then
umount /media/STORAGE
finish=$((finish+1))
fi
if [ $finish -eq 2 ]; then
echo "all done in $cnt steps"
break
fi
sleep 0.25
cnt=$((cnt+1))
done
;;
esac
To keep USB power always on this HW modification can be applied (on your own risk):