diff --git a/README.md b/README.md index 567ae57..e32ad25 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,9 @@ Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands --- #### Advanced system features: +##### `ENABLE_SYSTEMDSWAP`=false +Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled. + ##### `ENABLE_MINBASE`=false Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB. diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index c91b0ef..9b56478 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -415,7 +415,10 @@ if [ "$BUILD_KERNEL" = true ] ; then else # BUILD_KERNEL=false # echo Install precompiled kernel... # echo error: not implemented - if [ "$KERNEL_ARCH" = arm64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then + if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then + if [ "$KERNEL_ZSWAP" = true ] ; then + RPI3_64_KERNEL_URL=RPI3_64_BIS_KERNEL_URL + fi # Create temporary directory for dl temp_dir=$(as_nobody mktemp -d) @@ -437,6 +440,27 @@ else # BUILD_KERNEL=false #Create cmdline.txt for 15-rpi-config.sh touch "${BOOT_DIR}/cmdline.txt" fi + + # INstall Kernel from hypriot comptabile with all Raspberry PI + if [ "$SET_ARCH" = 32 ] ; then + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel + as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL" + + # Fetch kernel header + as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL" + + # Install kernel + chroot_exec dpkg -i "${temp_dir}"/kernel.deb + + # Install kernel header + chroot_exec dpkg -i "${temp_dir}"/kernel-header.deb + + # Remove temporary directory for U-Boot sources + rm -fr "${temp_dir}" + fi # Check if kernel installation was successful KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)" @@ -445,4 +469,4 @@ else # BUILD_KERNEL=false cleanup exit 1 fi -fi +fi diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 98d005a..4d40fd1 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -64,35 +64,6 @@ if [ "$ENABLE_CRYPTFS" = true ] ; then fi fi -if [ "$KERNEL_ZSWAP" = true ] ; then - # Create temporary directory for systemd-swap sources - temp_dir=$(as_nobody mktemp -d) - - # Fetch systemd-swap sources - as_nobody git -C "${temp_dir}" clone "${ZSWAP_URL}" - - # Copy downloaded systemd-swap sources - mv "${temp_dir}/systemd-swap" "${R}/tmp/" - - # Set permissions of the systemd-swap sources - chown -R root:root "${R}/tmp/systemd-swap" - - # Remove temporary directory for systemd-swap sources - rm -fr "${temp_dir}" - - # Change into downloaded src dir - cd "${R}/tmp/systemd-swap" || exit - - # Build package - . ./systemd-swap/package.sh debian - - # Install package - chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb - - # Change back into script root dir - cd "${WORKDIR}" || exit -fi - #locks cpu at max frequency if [ "$ENABLE_TURBO" = true ] ; then echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" @@ -191,6 +162,48 @@ else chroot_exec systemctl disable serial-getty@"$SET_SERIAL".service fi +# Remove cmdline.txt entry of starting zswap +if [ "$KERNEL_ZSWAP" = true ] ; then + CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" +fi + +if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then + + # Remove cmdline.txt entry of starting zswap + if [ "$KERNEL_ZSWAP" = true ] ; then + sed -i 's|zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4||g' + fi + # Create temporary directory for systemd-swap sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch systemd-swap sources + as_nobody git -C "${temp_dir}" clone "${ZSWAP_URL}" + + # Copy downloaded systemd-swap sources + mv "${temp_dir}/systemd-swap" "${R}/tmp/" + + # Set permissions of the systemd-swap sources + chown -R root:root "${R}/tmp/systemd-swap" + + # Remove temporary directory for systemd-swap sources + rm -fr "${temp_dir}" + + # Change into downloaded src dir + cd "${R}/tmp/systemd-swap" || exit + + # Build package + . ./systemd-swap/package.sh debian + + # Install package + chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb + + # Enable service + chroot_exec systemctl enable systemd-swap + + # Change back into script root dir + cd "${WORKDIR}" || exit +fi + # Remove IPv6 networking support if [ "$ENABLE_IPV6" = false ] ; then CMDLINE="${CMDLINE} ipv6.disable=1" diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index dfd82f0..0b0a798 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -61,11 +61,12 @@ RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmr #default bcmrpi3_defconfig target kernel RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} #enhanced kernel -RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} +RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL} BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} -ZSWAP_URL=${ZSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} - +SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} +RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb} +RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb} # Build directories WORKDIR=$(pwd) @@ -147,6 +148,7 @@ SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} # Advanced settings +ENABLE_SYSTEMDSWAP=${ENABLE_MINBASE:=false} ENABLE_MINBASE=${ENABLE_MINBASE:=false} ENABLE_REDUCE=${ENABLE_REDUCE:=false} ENABLE_UBOOT=${ENABLE_UBOOT:=false}