brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: scripts on the Unraid boot device need bash in front of them

Unraid
~/tips/tip-unraid-boot-device-no-execute

bash /boot/config/scripts/myscript.sh

Run your own scripts from the boot device even though it blocks execute permission.

Keeping a few handy scripts in /boot/config/scripts sounds logical, since the boot device survives a reboot. Then you type the path, press enter and get “Permission denied”. Nothing is broken.

The Unraid docs explain that files on the boot device can no longer be given execute permission. It’s a security change, so malicious or accidental code can’t run straight off the stick that holds your configuration and license. A chmod there won’t help.

There are two ways around it. The simple one is to hand the script to its interpreter yourself:

bash /boot/config/scripts/myscript.sh

That works from the terminal, from a cron line and from config/go. If you’d rather type myscript.sh like a normal command, the docs suggest copying it to /usr/local/bin, which is on the default system path, and setting the execute permission after the copy. Put the copy commands in /boot/config/go so it happens at every boot:

cp /boot/config/scripts/myscript.sh /usr/local/bin/
chmod +x /usr/local/bin/myscript.sh

I’d use the first variant for things you run once in a while and the second for tools you call often enough to get annoyed by the long path.

The caveat is that the copy in /usr/local/bin is just a copy. When you edit the script, edit the one on the boot device, and the change only reaches /usr/local/bin after the next boot or when you copy it again yourself.

Further reading: Unraid docs: Securing your boot device

More Unraid tips Change the RAID profile of a Unraid BTRFS pool with Balance Replace a disk in a redundant Unraid pool from the Main tab Test every Unraid drive with the DiskSpeed container See the XML behind a VM with the inline XML view in Unraid 7 Choose where a new VM's disk image is created with Unraid's storage override All Unraid tips (77) All topics

Link