I am attempting to specify a preseed/late_command
as a shell script that enables the systemd tmp.mount
unit. Executing of a shell script in late_command
fails with error code 127 indicating confusingly that /bin/sh
doesn't exist on the target. What do I need to modify here to run a late_command shell script on the target?
My ubuntu-server-custom.seed
contains:
d-i preseed/late_command string cp \
-a /cdrom/preseed/tmp_mount.sh /target/usr/sbin/; \
chroot /target '/bin/sh /usr/sbin/tmp_mount.sh --need-target-bash --preseed-late-command';
(Note: newlines only added here for readability. The --flags
to sh
are hijacked from https://www.virtualbox.org/ticket/18411.)
Also tried:
in-target '/bin/sh /usr/sbin/tmp_mount.sh';
with same error message and exit code.
/preseed/tmp_mount.sh
exists on the ISO.
tmp_mount.sh
looks like:
#!/bin/bash
/bin/cp -aT /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
/bin/chmod 644 /etc/systemd/system/tmp.mount
/bin/sed -i -r 's/^Options=.*/Options=mode=1777,noatime,noexec,nodev,nosuid,size=4G/g' /etc/systemd/system/tmp.mount
/bin/systemctl unmask tmp.mount
/bin/systemctl enable tmp.mount
/bin/echo 'tmpfs /tmp tmpfs mode=1777,noatime,noexec,nodev,nosuid,size=4G 0 0' >> /etc/fstab
/bin/echo 'tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0' >> /etc/fstab
Booting from ISO errors with:
Execution of preseeded command failed with error code 127.
I am able to push through the boot process and log in. Examining /var/log/installer/syslog
I see:
I can also confirm that the script does actually exist on the target:
$ file /usr/sbin/tmp*
/usr/sbin/tmp_mount.sh: Bourne-Again shell script...
So what's wrong here?