I have a script that runs inside an early boot Bash environment, where init=/bin/bash. I want to redirect script output to a log file. However, I get an error message saying that /dev/fd/XX is not available.
Is there a way to accomplish this?
This is my kernel config file (on a Raspberry Pi), cmdline.txt (new lines added for readability; this is actually one long line)
console=serial0,115200 console=tty1 root=PARTUUID=067e19d7-02 rootfstype=ext4
elevator=deadline fsck.repair=yes rootwait
init=/bin/bash -c
"mount -t proc proc /proc;
mount -t sysfs sys /sys;
mount /boot;
source /boot/unattended"
Inside of /boot/unattended
mount -t tmpfs tmp /run
mkdir -p /run/systemd
mount / -o remount,rw
# This is where I want to start redirecting command output
ls -la
# Would like the above command output to go to a log file
Typically, I would add a code snippet like the one below ... but this is the one that fails in the early boot shell.
# Redirect stdout and stderr
exec > >(tee -ia /boot/log/script_stdout.log >&1)
exec 2> >(tee -ia /boot/log/script_stderr.log >&2)
In the early Bash shell, this results in:
bash: /dev/fd/62: No such file or directory
Needless to say, there is only a number of tty files, urandom, a few (what I think is) RPi video device nodes (vc...), watchdog{0} and zero.