@Ed_P : Yes, you are right, that small change fixed it! When I run this script in terminal, it works. But then, if i put it in
rc.local, nothing happens...
I think the problem lies with the order in which booting occurs and
rc.local gets called. I tried another approach. I made a whitelist of all the files I wanted to keep in the boot partition and wrote a script to remove any other file:
Code: Select all
#!/bin/bash
# Define whitelist
WHITELIST=(
"/mnt/sda1/EFI/boot/bootx64.efi"
"/mnt/sda1/EFI/boot/chain.c32"
"/mnt/sda1/EFI/boot/ldlinux.e64"
"/mnt/sda1/EFI/boot/libcom32.c32"
"/mnt/sda1/EFI/boot/libmenu.c32"
"/mnt/sda1/EFI/boot/libutil.c32"
"/mnt/sda1/EFI/boot/linux.c32"
"/mnt/sda1/EFI/boot/menu.c32"
"/mnt/sda1/EFI/boot/syslinux.c32"
"/mnt/sda1/EFI/boot/syslinux.cfg"
"/mnt/sda1/EFI/boot/vesamenu.c32"
"/mnt/sda1/boot/syslinux/isolinux.boot"
"/mnt/sda1/boot/syslinux/isolinux.bin"
"/mnt/sda1/boot/syslinux/chain.c32"
"/mnt/sda1/boot/syslinux/extlinux.conf"
"/mnt/sda1/boot/syslinux/initrd.xz"
"/mnt/sda1/boot/syslinux/isolinux.cfg"
"/mnt/sda1/boot/syslinux/ldlinux.c32"
"/mnt/sda1/boot/syslinux/libcom32.c32"
"/mnt/sda1/boot/syslinux/libutil.c32"
"/mnt/sda1/boot/syslinux/lilo.conf"
"/mnt/sda1/boot/syslinux/plpbt"
"/mnt/sda1/boot/syslinux/porteus.cfg"
"/mnt/sda1/boot/syslinux/splash.png"
"/mnt/sda1/boot/syslinux/pxelinux.0"
"/mnt/sda1/boot/syslinux/reboot.c32"
"/mnt/sda1/boot/syslinux/syslinux.cfg"
"/mnt/sda1/boot/syslinux/vesamenu.c32"
"/mnt/sda1/boot/syslinux/vmlinuz"
)
# Define mount point of BOOT partition
BOOT_PARTITION="/mnt/sda1"
# Traverse through BOOT partition
find "$BOOT_PARTITION" -type f | while read -r file; do
if ! [[ " ${WHITELIST[*]} " =~ " $file " ]]; then
echo "Removing $file"
rm "$file"
fi
done
echo "Cleanup complete!"
If I run this script in terminal, it works perfectly. But if I call the same script in
rc.local, the extra files are not deleted, although
echo "Cleanup complete!" does print to the console.
So is it possible that a script in
rc.local will not touch to the booting partition, even if I use cheatcode
copy2ram?