That didn't work. An example command that fails:
mount -t cifs //192.168.101.53/media /media/smb/192.168.101.53 -o username=guest,guest,noperm
mount: mounting //192.168.101.53/media on /media/smb/192.168.101.53 failed: No such file or directory
The destination directory (on the local machine) exists. So it must think /media is not exported from the remote host. SMB is running on that host.
The log on the remote host looks like this:
[2024/01/12 18:05:59.141440, 0] ../../source3/smbd/service.c:787(make_connection_snum)
make_connection_snum: canonicalize_connect_path failed for service media, path /media/usb
On a host where this doesn't happen the path /media/usb exists. On a host where it does happen /media/usb doesn't exist. So the problem is that /media/usb would ALWAYS need to exist to avoid these errors, instead of just creating /media/usb IF a usb storage device is added.
I tested manually adding /media/usb to a remote host that didn't have it and the host trying to mount it succeeded, stopping spewing errors for that remote host.
The fix, therefore, is to update postbuild.sh to do
mkdir -p ${TARGET}/media/usb
instead of just
mkdir -p ${TARGET}/media