我正在尝试将指定preseed/late_command作为一个启用systemd tmp.mount单元的shell脚本。在late_command中执行shell脚本失败,错误代码127表示目标上不存在/bin/sh。在这里我需要修改什么来在目标上运行late_command shell脚本?
我的ubuntu-server-custom.seed包含:
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';(注:此处添加的换行符仅用于可读性。从--flags到sh被从https://www.virtualbox.org/ticket/18411.劫持)
也曾尝试过:
in-target '/bin/sh /usr/sbin/tmp_mount.sh';具有相同的错误信息和退出代码。
/preseed/tmp_mount.sh存在于国际标准化组织。
tmp_mount.sh看起来像:
#!/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使用以下方法从ISO错误启动:
错误代码127执行预置命令失败。
我能够推入引导过程并登录。查看/var/log/installer/syslog我看到:

我还可以确认脚本确实存在于目标上:
$ file /usr/sbin/tmp*
/usr/sbin/tmp_mount.sh: Bourne-Again shell script...那么这里出了什么问题?
发布于 2021-05-18 17:53:48
通过对late_command调用进行一些小的调整,我就能够完成这个任务:
in-target而不是chroot /targetsh调用可执行位时需要这样做,但是无论如何都行)预发的最终结果:
d-i preseed/late_command string \
cp -a /cdrom/preseed/tmp_mount.sh /target/usr/sbin/; \
in-target chmod 700 /usr/sbin/tmp_mount.sh; \
in-target /bin/sh /usr/sbin/tmp_mount.sh请注意,这将使/usr/sbin/tmp_mount.sh出现在目标文件系统上。(我故意把它留在那里。)如果需要,可以在最终的in-target /bin/rm /usr/sbin/tmp_mount.sh中删除它。
https://askubuntu.com/questions/1339167
复制相似问题