#!/bin/bash #Author: Era Scarecrow #License: GPL 2 #Date: 22 Sep 2021 #Description: Convert Slax bundles to LZO # #By default the savechanges and dir2sb files use xz compression, while good for size is terrible for older computers laptops, chromebooks, VM's and the like #LZO will make it nearly lightning fast. Just specify the mounted directory, which may be /media/sda1 or another folder if [ ! -e "$1" ]; then echo "Add directory of package bundles to be recompressed: ex /media/sda1" exit fi if [ ! "`whoami`" = 'root' ]; then echo "Requires root..." su if [ ! "`whoami`" = 'root' ]; then echo "Not root, probably wouldn't work" exit 1 fi fi if [ ! \( -f /usr/bin/sb2dir -a -f /usr/bin/dir2sb -a -f /usr/bin/savechanges -a -d /run/initramfs/memory/bundles \) ]; then echo "Error: Utilities sb2dir, dir2sb, savechanges; Are missing, probably not Slax Distro." echo "\tuse sb2lzo instead" exit 1 fi #remove trailing slash if there. DIR=`echo "$1" | sed -E -e 's:/$::'` if [ ! -f "$DIR/01-lzo.sb" ]; then echo "Creating lzo versions & tap-to-touch bundle" #make dirs used or not and populate mkdir -p /tmp/sb/usr/bin mkdir -p /tmp/sb/etc/X11/xorg.conf.d #make lzo versions, just replace xz with lzo in scripts for X in dir2sb savechanges; do sed -E -e 's/\bxz\b/lzo/g' "/usr/bin/${X}" > "/tmp/sb/usr/bin/${X}_lzo" chmod 755 /tmp/sb/usr/bin/* done #makes tap-to-touch which is missing in slax. #If you don't like it you can always delete it later. echo 'Section "InputClass" Identifier "libinput touchpad catchall" MatchIsTouchpad "on" MatchDevicePath "/dev/input/event*" Driver "libinput" Option "Tapping" "on" EndSection' > /tmp/sb/etc/X11/xorg.conf.d/40-libinput.conf mksquashfs /tmp/sb "$DIR/01-lzo.sb" -comp lzo -b 1024K -always-use-fragments >/dev/null #cleanup rm -fr /tmp/sb fi #runtime bundles location, all mounted readonly directories cd /run/initramfs/memory/bundles #cycle through directories of mounted bundles for X in *; do #if file is present, we don't bother to repack it if [ -f "$DIR/$X" ]; then continue; fi printf "Repacking: %s" "$X" #Skips firmware, as you won't need it to be smaller echo "$X" | grep "firmware" > /dev/null && echo " Skipped" && continue; mksquashfs "$X" "$DIR/$X" -comp lzo -b 1024K -always-use-fragments >/dev/null printf "\t%s -> %s\n" `du -h "$DIR/slax/$X" | sed -E -e 's/[^a-zA-Z0-9].*//'` `du -h "$DIR/$X" | sed -E -e 's/[^a-zA-Z0-9].*//'` done echo sync echo "Moving and rebooting" for X in ... .. .; do echo "$X" sleep 1 done cd "$DIR" mv *.sb slax sync #reboot, if done right the live files are LZO now shutdown -r now