Merge pull request #2486 from fewtarius/dev

Merged storage changes
This commit is contained in:
fewtarius 2023-12-04 05:59:07 -05:00 committed by GitHub
commit d6c14f3b38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 166 additions and 58 deletions

View file

View file

View file

View file

View file

0
packages/hardware/quirks/platforms/RK3399/040-affinity Normal file → Executable file
View file

View file

@ -0,0 +1,23 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
### Restore previous governors before going to sleep
. /etc/profile
### Grab the old governors.
OLD_CPU_FREQ=$(get_setting "sleep.cpugovernor")
if [ ! -n "${OLD_CPU_FREQ}" ]; then
OLD_CPU_FREQ="schedutil"
fi
OLD_GPU_FREQ=$(get_setting "sleep.gpugovernor")
if [ ! -n "${OLD_GPU_FREQ}" ]; then
OLD_GPU_FREQ="simple_ondemand"
fi
# Restore old governors.
set_cpu_gov "${OLD_CPU_FREQ}"
set_dmc_gov "${OLD_CPU_FREQ}"
set_gpu_gov "${OLD_GPU_FREQ}"

View file

@ -0,0 +1,19 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# Store current freq governors and set governors to powersave.
. /etc/profile
### Get the current cpu and gpu governor, save for when the device wakes from sleep.
CUR_CPU_FREQ="$(cat ${CPU_FREQ}/scaling_governor)"
CUR_GPU_FREQ="$(cat ${GPU_FREQ}/governor)"
set_setting sleep.cpugovernor "${CUR_CPU_FREQ}"
set_setting sleep.gpugovernor "${CUR_GPU_FREQ}"
### Set all governors to powersave
set_cpu_gov powersave
set_dmc_gov powersave
set_gpu_gov powersave

View file

@ -4,6 +4,7 @@
# Minimal OS variable loading for performance # Minimal OS variable loading for performance
. /etc/profile.d/001-functions . /etc/profile.d/001-functions
. /etc/profile.d/030-powerfunctions
. /etc/profile.d/099-freqfunctions . /etc/profile.d/099-freqfunctions
tocon "Setting performance mode..." tocon "Setting performance mode..."

View file

@ -176,6 +176,7 @@ system.hostname=@DEVICENAME@
system.language=en_US system.language=en_US
system.loglevel=none system.loglevel=none
system.power.audio=1 system.power.audio=1
system.merged.storage=0
system.power.cpu=1 system.power.cpu=1
system.power.pcie=0 system.power.pcie=0
system.power.rtpm=0 system.power.rtpm=0

View file

@ -69,7 +69,6 @@ EOF
cp ${PKG_DIR}/sources/scripts/* ${INSTALL}/usr/bin cp ${PKG_DIR}/sources/scripts/* ${INSTALL}/usr/bin
chmod 0755 ${INSTALL}/usr/bin/* 2>/dev/null ||: chmod 0755 ${INSTALL}/usr/bin/* 2>/dev/null ||:
enable_service jelos-automount.service
### Fix and migrate to autostart package ### Fix and migrate to autostart package
enable_service jelos-autostart.service enable_service jelos-autostart.service

View file

@ -73,8 +73,12 @@ sed -i 's~"pulse"~"alsathread"~g' /storage/.config/retroarch/retroarch.cfg
### 20231114 - Update hosts.conf ### 20231114 - Update hosts.conf
grep "127.0.0.1" /storage/.config/hosts.conf >/dev/null 2>&1 || cp /usr/config/hosts.conf /storage/.config/ grep "127.0.0.1" /storage/.config/hosts.conf >/dev/null 2>&1 || cp /usr/config/hosts.conf /storage/.config/
### 20231127 - Migrate games to overlayfs ### 20231127 - Migrate games to overlayfs (updated 20231203)
systemctl stop storage-roms.mount NULL=$(cat /proc/mounts | grep -v -e "/storage/roms" 2>/dev/null | grep ${1})
if [ ! "$?" = 0 ]
then
umount /storage/roms
fi
GAMECOUNT=$(find /storage/roms -type f | wc -l) GAMECOUNT=$(find /storage/roms -type f | wc -l)
if [ "${GAMECOUNT}" -gt 20 ] && \ if [ "${GAMECOUNT}" -gt 20 ] && \
[ ! -e "/storage/.migrated_games" ] [ ! -e "/storage/.migrated_games" ]
@ -91,7 +95,17 @@ then
else else
echo "Game weight too low (${GAMECOUNT}) or content already migrated." >>${LOG} echo "Game weight too low (${GAMECOUNT}) or content already migrated." >>${LOG}
fi fi
systemctl start storage-roms.mount
### Migration part 2
for GAMES in /storage/games-internal /storage/games-external
do
if [ ! -d "${GAMES}/roms" ]
then
mkdir -p "${GAMES}/roms"
mv "${GAMES}/"* "${GAMES}/roms/"
fi
done
systemctl restart jelos-automount
### 20231129 - Don't default to performance. ### 20231129 - Don't default to performance.
EPP=$(get_setting system.power.epp) EPP=$(get_setting system.power.epp)
@ -111,6 +125,13 @@ do
rm -rf ${FILE} 2>/dev/null rm -rf ${FILE} 2>/dev/null
done done
### 20231203 - Disable merged storage by default.
MERGED_STORAGE=$(get_setting system.merged.storage)
if [ -z "${MERGED_STORAGE}" ]
then
set_setting system.merged.storage 0
fi
### Items below this line should not be removed. ### Items below this line should not be removed.
tocon "Update complete, rebooting..." tocon "Update complete, rebooting..."
reboot reboot

View file

@ -5,29 +5,56 @@
. /etc/profile . /etc/profile
. /etc/os-release . /etc/os-release
### Vars
UPDATE_ROOT="/storage/.update" UPDATE_ROOT="/storage/.update"
MOUNT_GAMES=$(get_setting system.automount) MOUNT_GAMES=$(get_setting system.automount)
GAMES_DEVICE=$(get_setting system.gamesdevice) GAMES_DEVICE=$(get_setting system.gamesdevice)
MOUNT_PATH="/storage/games-external" MS_ENABLED=$(get_setting system.merged.storage)
OVERLAY_PATH="/storage/roms" MS_DEVICE=$(get_setting system.merged.device)
start_overlay() { ### Default to the external storage device.
if [ -e "/storage/.overlay_unsupported" ] MOUNT_PATH="/storage/games-external"
MS_PATH="/storage/roms"
function unmount() {
log $0 "Unmount ${1}."
umount -f "${1}" 2>/dev/null ||:
}
function start_ms() {
### Entrypoint will be either games card found (external), or not found (internal).
MOUNT_PATH="/storage/games-${1}"
### Determine if internal or external is the primary target by configuration.
case ${MS_DEVICE} in
internal)
LOWER="internal"
UPPER="external"
;;
*)
LOWER="external"
UPPER="internal"
;;
esac
if [ -e "/storage/.ms_unsupported" ] || \
[ "${MS_ENABLED}" = 0 ]
then then
# If we're not using the overlay, bind mount the external storage path log $0 "Executing bind mount of ${MOUNT_PATH} to ${MS_PATH}"
# so we don't need to change any configs. mount --bind ${MOUNT_PATH}/roms ${MS_PATH}
grep ${MOUNT_PATH} /proc/mounts >/dev/null 2>&1
if [ ! $? = 0 ]
then
MOUNT_PATH="/storage/games-internal"
fi
log $0 "Executing bind mount of ${MOUNT_PATH} to ${OVERLAY_PATH}"
mount --bind ${MOUNT_PATH} ${OVERLAY_PATH}
exit 0 exit 0
else else
log $0 "Enabling overlay." log $0 "Enabling merged storage of /storage/games-${LOWER} and /storage/games-${UPPER} to ${MS_PATH}."
systemctl enable storage-roms.mount >/dev/null 2>&1
systemctl start storage-roms.mount >/dev/null 2>&1 for DIR in /storage/games-${UPPER}/.tmp/games-workdir /storage/games-${LOWER}/roms /storage/games-${UPPER}/roms
do
if [ ! -d "${DIR}" ]
then
mkdir -p "${DIR}"
fi
done
mount overlay -t overlay -o lowerdir=/storage/games-${LOWER}/roms,upperdir=/storage/games-${UPPER}/roms,workdir=/storage/games-${UPPER}/.tmp/games-workdir ${MS_PATH}
fi fi
} }
@ -36,41 +63,45 @@ then
set_setting system.automount 1 set_setting system.automount 1
elif [[ "${MOUNT_GAMES}" == "0" ]] elif [[ "${MOUNT_GAMES}" == "0" ]]
then then
start_overlay start_ms internal
exit 0 exit 0
fi fi
function create_game_dirs() {
systemd-tmpfiles --create /usr/lib/tmpfiles.d/JELOS-system-dirs.conf >/dev/null 2>&1 ||:
}
function load_modules() { function load_modules() {
for MODULE in exfat vfat for MODULE in exfat vfat
do do
lsmod | grep ${MODULE} 2>/dev/null lsmod | grep ${MODULE} >/dev/null 2>&1
if [ ! $? = 0 ] if [ ! $? = 0 ]
then then
log $0 "Loading ${MODULE}." log $0 "Loading ${MODULE}."
modprobe ${MODULE} 2>/dev/null modprobe ${MODULE} >/dev/null 2>&1
fi fi
done done
} }
function mount_games() { function mount_games() {
local MOUNT_PATH="/storage/games-external"
FSTYPE=$(blkid -o export ${1} | awk 'BEGIN {FS="="} /TYPE/ {print $2}') FSTYPE=$(blkid -o export ${1} | awk 'BEGIN {FS="="} /TYPE/ {print $2}')
case ${FSTYPE} in case ${FSTYPE} in
ext4) ext4)
log $0 "Found supported partition for overlayfs." log $0 "Found supported partition for overlayfs."
if [ -e "/storage/.overlay_unsupported" ] if [ -e "/storage/.ms_unsupported" ]
then then
rm -f /storage/.overlay_unsupported rm -f /storage/.ms_unsupported
fi fi
touch /storage/.overlay_supported touch /storage/.ms_supported
set_setting system.merged.storage 1
;; ;;
*) *)
log $0 "Partition does not support overlayfs, disabling." log $0 "Partition does not support overlayfs, disabling."
if [ -e "/storage/.overlay_supported" ] if [ -e "/storage/.ms_supported" ]
then then
rm -f /storage/.overlay_supported rm -f /storage/.ms_supported
fi fi
touch /storage/.overlay_unsupported touch /storage/.ms_unsupported
;; ;;
esac esac
@ -85,21 +116,28 @@ function mount_games() {
[ -e "${1}" ] && \ [ -e "${1}" ] && \
[ ! -e "/storage/.please_resize_me" ] [ ! -e "/storage/.please_resize_me" ]
then then
### Udevil shouldn't mount it this early, but just in-case. ### Udevil shouldn't mount it this early, but just in-case.
umount /var/media/* 2>/dev/null umount /var/media/* 2>/dev/null
log $0 "Checking filesystem ${1}." log $0 "Checking filesystem ${1}."
fsck -Mly ${1} >/dev/null 2>&1 fsck -Mly ${1} >/dev/null 2>&1
log $0 "Mounting ${1} on ${MOUNT_PATH}" log $0 "Mounting ${1} on ${MOUNT_PATH}"
/usr/bin/busybox mount ${1} ${MOUNT_PATH} >/dev/null 2>&1 /usr/bin/busybox mount ${1} ${MOUNT_PATH} >/dev/null 2>&1
fi fi
start_overlay start_ms external
create_game_dirs
exit 0
} }
find_games() { function find_games() {
if /usr/bin/busybox mountpoint -q /storage ; then if /usr/bin/busybox mountpoint -q /storage
then
for DEV in $(for dev in mmcblk[0-9] sd[a-z] nvme[0-9]; do blkid | grep ${dev} | awk 'BEGIN {FS=":"}; /ext4/ || /fat/ {print $1}' | sort -r; done) for DEV in $(for dev in mmcblk[0-9] sd[a-z] nvme[0-9]; do blkid | grep ${dev} | awk 'BEGIN {FS=":"}; /ext4/ || /fat/ {print $1}' | sort -r; done)
do do
ROOTDEV=$(echo ${DEV} | sed -e "s#^/.*/##g" -e "s#p[0-9].*\$##g") ROOTDEV=$(echo ${DEV} | sed -e "s#^/.*/##g" -e "s#p[0-9].*\$##g")
log $0 "Inspecting ${DEV}."
SIZE=$(awk '/'${ROOTDEV}'$/ {print $3}' /proc/partitions) SIZE=$(awk '/'${ROOTDEV}'$/ {print $3}' /proc/partitions)
if (( ${SIZE} <= 8388608 )) if (( ${SIZE} <= 8388608 ))
then then
@ -113,25 +151,31 @@ find_games() {
# Assume this is an android boot device and ignore it. # Assume this is an android boot device and ignore it.
continue continue
fi fi
# Udevil might mount it, and we shouldn't care if it does. if [ -e "${DEV}" ] && \
NULL=$(cat /proc/mounts | grep -v -e "/var/media" 2>/dev/null | grep ${DEV})
if [ ! "$?" = "0" ] && \
[ -e "${DEV}" ] && \
[ ! -e "/storage/.please_resize_me" ] [ ! -e "/storage/.please_resize_me" ]
then then
GAMES_DEVICE=${DEV} GAMES_DEVICE=${DEV}
log $0 "Found ${DEV} available to mount." log $0 "Found ${DEV} available to mount."
mount_games "${DEV}" mount_games "${DEV}"
break else
log $0 "${DEV} not available."
fi fi
done done
# If we're here there is no external storage to use, but we want to start the overlay anyway. log $0 "Could not find external card to mount, assume internal."
start_overlay start_ms internal
create_game_dirs
exit 0
fi fi
} }
## Main..
load_modules load_modules
### Unmount any existing storage before beginning operations.
unmount /storage/games-external
unmount /storage/roms
if [ -e "${GAMES_DEVICE}" ] if [ -e "${GAMES_DEVICE}" ]
then then
mount_games ${GAMES_DEVICE} mount_games ${GAMES_DEVICE}

View file

@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
for STORAGE in /storage/games-internal /storage/games-external
do
find ${STORAGE} -type d -empty -delete
done
reboot

0
packages/jelos/sources/scripts/led_flash Normal file → Executable file
View file

0
packages/jelos/sources/scripts/runemu.sh Normal file → Executable file
View file

0
packages/jelos/sources/scripts/volume Normal file → Executable file
View file

View file

@ -8,7 +8,6 @@ Type=oneshot
Environment=HOME=/storage Environment=HOME=/storage
EnvironmentFile=/etc/profile EnvironmentFile=/etc/profile
ExecStart=/usr/bin/automount ExecStart=/usr/bin/automount
ExecStartPost=systemd-tmpfiles --create /usr/lib/tmpfiles.d/JELOS-system-dirs.conf
RemainAfterExit=yes RemainAfterExit=yes
[Install] [Install]

View file

@ -4,7 +4,7 @@
PKG_NAME="linux" PKG_NAME="linux"
PKG_LICENSE="GPL" PKG_LICENSE="GPL"
PKG_VERSION="6.6.3" PKG_VERSION="6.6.4"
PKG_URL="https://www.kernel.org/pub/linux/kernel/v6.x/${PKG_NAME}-${PKG_VERSION}.tar.xz" PKG_URL="https://www.kernel.org/pub/linux/kernel/v6.x/${PKG_NAME}-${PKG_VERSION}.tar.xz"
PKG_SITE="http://www.kernel.org" PKG_SITE="http://www.kernel.org"
PKG_DEPENDS_HOST="ccache:host rsync:host openssl:host rdfind:host" PKG_DEPENDS_HOST="ccache:host rsync:host openssl:host rdfind:host"

View file

@ -43,6 +43,9 @@ then
done done
fi fi
### Start the automount service
systemctl start jelos-automount
### Run common start scripts ### Run common start scripts
for script in /usr/lib/autostart/common/* for script in /usr/lib/autostart/common/*
do do

View file

@ -3,7 +3,7 @@
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) # Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
PKG_NAME="emulationstation" PKG_NAME="emulationstation"
PKG_VERSION="ac666f2" PKG_VERSION="adc7cb5"
PKG_GIT_CLONE_BRANCH="main" PKG_GIT_CLONE_BRANCH="main"
PKG_REV="1" PKG_REV="1"
PKG_ARCH="any" PKG_ARCH="any"

View file

@ -1,13 +0,0 @@
[Unit]
Description=Overlays directory
After=systemd-tmpfiles-setup.service
DefaultDependencies=no
[Mount]
What=none
Where=/storage/roms
Type=overlay
Options=lowerdir=/storage/games-external,upperdir=/storage/games-internal,workdir=/storage/.tmp/games-workdir
[Install]
WantedBy=jelos.target

View file

@ -14,7 +14,7 @@ GOTO="exit"
# mount or umount for hdds # mount or umount for hdds
LABEL="harddisk" LABEL="harddisk"
ACTION=="add", PROGRAM="/usr/bin/sh -c '/usr/bin/grep -E ^/dev/%k\ /proc/mounts || true'", RESULT=="", RUN+="/usr/bin/systemctl stop storage-roms.mount", RUN+="/usr/bin/systemctl restart jelos-automount.service" ACTION=="add", PROGRAM="/usr/bin/sh -c '/usr/bin/grep -E ^/dev/%k\ /proc/mounts || true'", RESULT=="", RUN+="/usr/bin/systemctl restart jelos-automount.service"
GOTO="exit" GOTO="exit"
# Exit # Exit