mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-04-16 11:27:23 +02:00
Merge pull request #50 from OpenVoiceOS/feature/zram
Next step is the r/w filesystem overlay system
This commit is contained in:
commit
1b7514a51c
@ -1 +1 @@
|
|||||||
dwc_otg.lpm_enable=0 root=PARTUUID=c0932a41-44cf-463b-8152-d43188553ed4 rootfstype=ext4 elevator=deadline fsck.repair=yes console=ttyAMA0,115200 consoleblank=0 loglevel=0 vt.global_cursor_default=0 logo.nologo systemd.show_status=0 rootwait quiet splash
|
dwc_otg.lpm_enable=0 root=PARTUUID=c0932a41-44cf-463b-8152-d43188553ed4 rootfstype=ext4 elevator=deadline fsck.repair=yes zram.enabled=1 zram.num_devices=4 console=ttyAMA0,115200 consoleblank=0 loglevel=0 vt.global_cursor_default=0 logo.nologo systemd.show_status=0 rootwait quiet splash
|
||||||
|
@ -10,7 +10,7 @@ image boot.vfat {
|
|||||||
"Image"
|
"Image"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size = 32M
|
size = 96M
|
||||||
}
|
}
|
||||||
|
|
||||||
image sdcard.img {
|
image sdcard.img {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
CONFIG_SND_SOC_WM8960=m
|
CONFIG_SND_SOC_WM8960=m
|
||||||
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
|
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
|
||||||
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
|
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
|
||||||
|
|
||||||
|
CONFIG_ZRAM=y
|
||||||
|
CONFIG_ZSMALLOC=y
|
||||||
|
@ -451,6 +451,8 @@ BR2_PACKAGE_SUDO=y
|
|||||||
BR2_PACKAGE_TIME=y
|
BR2_PACKAGE_TIME=y
|
||||||
BR2_PACKAGE_WHICH=y
|
BR2_PACKAGE_WHICH=y
|
||||||
BR2_PACKAGE_HTOP=y
|
BR2_PACKAGE_HTOP=y
|
||||||
|
BR2_PACKAGE_SYSTEMD_ANALYZE=y
|
||||||
|
BR2_PACKAGE_SYSTEMD_BACKLIGHT=y
|
||||||
BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y
|
BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y
|
||||||
BR2_PACKAGE_SYSTEMD_HIBERNATE=y
|
BR2_PACKAGE_SYSTEMD_HIBERNATE=y
|
||||||
BR2_PACKAGE_SYSTEMD_LOCALED=y
|
BR2_PACKAGE_SYSTEMD_LOCALED=y
|
||||||
@ -460,18 +462,20 @@ BR2_PACKAGE_SYSTEMD_POLKIT=y
|
|||||||
BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
|
BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
|
||||||
BR2_PACKAGE_SYSTEMD_REPART=y
|
BR2_PACKAGE_SYSTEMD_REPART=y
|
||||||
# BR2_PACKAGE_SYSTEMD_RESOLVED is not set
|
# BR2_PACKAGE_SYSTEMD_RESOLVED is not set
|
||||||
|
BR2_PACKAGE_SYSTEMD_BOOTCHART=y
|
||||||
BR2_PACKAGE_TAR=y
|
BR2_PACKAGE_TAR=y
|
||||||
BR2_PACKAGE_UTIL_LINUX_BINARIES=y
|
BR2_PACKAGE_UTIL_LINUX_BINARIES=y
|
||||||
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
|
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
|
||||||
BR2_PACKAGE_UTIL_LINUX_KILL=y
|
BR2_PACKAGE_UTIL_LINUX_KILL=y
|
||||||
BR2_PACKAGE_UTIL_LINUX_MORE=y
|
BR2_PACKAGE_UTIL_LINUX_MORE=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
|
||||||
BR2_PACKAGE_NANO=y
|
BR2_PACKAGE_NANO=y
|
||||||
BR2_PACKAGE_VIM=y
|
BR2_PACKAGE_VIM=y
|
||||||
# BR2_PACKAGE_VIM_RUNTIME is not set
|
# BR2_PACKAGE_VIM_RUNTIME is not set
|
||||||
BR2_TARGET_ROOTFS_EXT2=y
|
BR2_TARGET_ROOTFS_EXT2=y
|
||||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||||
BR2_TARGET_ROOTFS_EXT2_LABEL="rootfs1"
|
BR2_TARGET_ROOTFS_EXT2_LABEL="rootfs1"
|
||||||
BR2_TARGET_ROOTFS_EXT2_SIZE="2527M"
|
BR2_TARGET_ROOTFS_EXT2_SIZE="4000M"
|
||||||
BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS="-O 64bit -U c0932a41-44cf-463b-8152-d43188553ed4"
|
BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS="-O 64bit -U c0932a41-44cf-463b-8152-d43188553ed4"
|
||||||
# BR2_TARGET_ROOTFS_TAR is not set
|
# BR2_TARGET_ROOTFS_TAR is not set
|
||||||
BR2_PACKAGE_HOST_CMAKE=y
|
BR2_PACKAGE_HOST_CMAKE=y
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Growdisk service to auto expand the rootfs partition
|
Description=Growdisk service to auto expand the rootfs partition
|
||||||
DefaultDependencies=no
|
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
After=systemd-remount-fs.service
|
After=local-fs.target
|
||||||
Before=sysinit.target shutdown.target
|
Wants=local-fs.target
|
||||||
|
Before=shutdown.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
# <file system> <mount pt> <type> <options> <dump> <pass>
|
# <file system> <mount pt> <type> <options> <dump> <pass>
|
||||||
PARTUUID=9262aee5-2d23-4e09-baac-280591e2e834 /boot vfat defaults,noatime 0 0
|
PARTUUID=9262aee5-2d23-4e09-baac-280591e2e834 /boot vfat defaults,noatime 0 0
|
||||||
PARTUUID=c0932a41-44cf-463b-8152-d43188553ed4 / ext4 defaults,noatime 0 1
|
PARTUUID=c0932a41-44cf-463b-8152-d43188553ed4 / ext4 defaults,noatime 0 1
|
||||||
proc /proc proc defaults 0 0
|
|
||||||
devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0
|
|
||||||
tmpfs /dev/shm tmpfs mode=0777 0 0
|
|
||||||
tmpfs /tmp tmpfs mode=1777 0 0
|
|
||||||
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
|
||||||
sysfs /sys sysfs defaults 0 0
|
|
||||||
#tmpfs /var/log tmpfs defaults 0 0
|
|
||||||
tmpfs /var/tmp tmpfs defaults 0 0
|
|
||||||
tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0
|
|
||||||
|
1
buildroot-external/rootfs-overlay/etc/sysctl.conf
Normal file
1
buildroot-external/rootfs-overlay/etc/sysctl.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
vm.swappiness = 30
|
@ -1,2 +1,3 @@
|
|||||||
d /var/log/mycroft 700 mycroft mycroft
|
d /var/log/mycroft 700 mycroft mycroft
|
||||||
Z /opt/mycroft - mycroft mycroft
|
Z /opt/mycroft - mycroft mycroft
|
||||||
|
d /ramdisk 700 mycroft mycroft
|
||||||
|
0
buildroot-external/rootfs-overlay/mnt/data/.empty
Normal file
0
buildroot-external/rootfs-overlay/mnt/data/.empty
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM swap
|
||||||
|
Requires=zram-swap.service
|
||||||
|
After=zram-swap.service
|
||||||
|
|
||||||
|
[Swap]
|
||||||
|
What=/dev/zram0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=swap.target
|
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS zram targets
|
||||||
|
Documentation=man:systemd.target(5)
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM ramdisk
|
||||||
|
DefaultDependencies=no
|
||||||
|
Requires=zram-ramdisk.service
|
||||||
|
After=zram-ramdisk.service
|
||||||
|
Before=umount.target
|
||||||
|
Conflicts=umount.target
|
||||||
|
|
||||||
|
[Mount]
|
||||||
|
What=/dev/zram1
|
||||||
|
Where=/ramdisk
|
||||||
|
Type=ext4
|
||||||
|
Options=rw,nobarrier,strictatime,nosuid,nodev
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=local-fs.target
|
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM var
|
||||||
|
DefaultDependencies=no
|
||||||
|
Requires=zram-var.service
|
||||||
|
After=zram-var.service
|
||||||
|
Before=umount.target
|
||||||
|
Conflicts=umount.target
|
||||||
|
|
||||||
|
[Mount]
|
||||||
|
What=/dev/zram2
|
||||||
|
Where=/var
|
||||||
|
Type=ext4
|
||||||
|
Options=nobarrier
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=local-fs.target
|
@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM ramdisk
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=ramdisk.mount
|
||||||
|
RefuseManualStart=true
|
||||||
|
RefuseManualStop=true
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/libexec/ovos-zram -t fs -m ramdisk -s 20M
|
||||||
|
RemainAfterExit=true
|
||||||
|
StandardOutput=null
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=ovos-zram.target
|
@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM swap
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=dev-zram0.swap
|
||||||
|
RefuseManualStart=true
|
||||||
|
RefuseManualStop=true
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/libexec/ovos-zram -t swap
|
||||||
|
RemainAfterExit=true
|
||||||
|
StandardOutput=null
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=ovos-zram.target
|
@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=OVOS ZRAM var
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=var.mount
|
||||||
|
RefuseManualStart=true
|
||||||
|
RefuseManualStop=true
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/libexec/ovos-zram -t fs -m var -s 32M
|
||||||
|
RemainAfterExit=true
|
||||||
|
StandardOutput=null
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=ovos-zram.target
|
83
buildroot-external/rootfs-overlay/usr/libexec/ovos-zram
Executable file
83
buildroot-external/rootfs-overlay/usr/libexec/ovos-zram
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Credits go to: https://github.com/home-assistant/operating-system/
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#### Options ####
|
||||||
|
|
||||||
|
TYPE=""
|
||||||
|
MOUNT=""
|
||||||
|
DEVICE=""
|
||||||
|
SIZE=0
|
||||||
|
|
||||||
|
#### Parse arguments ####
|
||||||
|
|
||||||
|
while [ "$1" != "" ]; do
|
||||||
|
key=$1
|
||||||
|
case $key in
|
||||||
|
-t|--type)
|
||||||
|
TYPE=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-s|--size)
|
||||||
|
SIZE=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-m|--mount)
|
||||||
|
MOUNT=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "[Error] $0 : Argument '$1' unknown"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Valide Type
|
||||||
|
if [ "$TYPE" != "swap" ] && [ "$TYPE" != "fs" ]; then
|
||||||
|
echo "[Error] Type unknown!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Lookup device
|
||||||
|
if [ "$TYPE" = "swap" ]; then
|
||||||
|
DEVICE="/dev/zram0"
|
||||||
|
elif [ "$MOUNT" = "ramdisk" ]; then
|
||||||
|
DEVICE="/dev/zram1"
|
||||||
|
elif [ "$MOUNT" = "var" ]; then
|
||||||
|
DEVICE="/dev/zram2"
|
||||||
|
#elif [ "$MOUNT" = "tmp" ]; then
|
||||||
|
# DEVICE="/dev/zram3"
|
||||||
|
else
|
||||||
|
echo "[Error] No device for lookup!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Calc 20% of memory for ZRAM swap partition
|
||||||
|
if [ "$TYPE" = "swap" ] && [ "$SIZE" -eq "0" ]; then
|
||||||
|
SIZE="$(awk '/MemTotal/{ print $2 * 0.20 }' /proc/meminfo)K"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Init device
|
||||||
|
zramctl "$DEVICE" -s "$SIZE" -a lz4
|
||||||
|
|
||||||
|
# Swap
|
||||||
|
if [ "$TYPE" = "swap" ]; then
|
||||||
|
mkswap -L "ovos-zramswap" "$DEVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# FileSystem
|
||||||
|
if [ "$TYPE" = "fs" ]; then
|
||||||
|
mkfs.ext4 -L "ovos-$MOUNT" -O ^has_journal "$DEVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy persistent file structures into zram device
|
||||||
|
if [ "$MOUNT" = "var" ]; then
|
||||||
|
# Check if this is a first run
|
||||||
|
if [ ! -d /mnt/data/var ]; then
|
||||||
|
mkdir -p /mnt/data/var
|
||||||
|
cp -af /var/* /mnt/data/var/
|
||||||
|
fi
|
||||||
|
cp -af /mnt/data/var/* "$DEVICE"
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user