20.04 autoinstall ejecting iso after first reboot

If you want to stop the physical ejection, then I think you'd have to patch the /sbin/casper-stop script in the installation environmment. If you simply want to avoid the prompt to "Please remove the installation medium, then press ENTER" then you can create the file /run/casper-no-prompt. Either of these options could be done in early-commands of your autoinstall config.

autoinstall config like the following might work

early-commands:
    - sed -ie 's/eject -p/#eject -p/' /sbin/casper-stop
    - touch /run/casper-no-prompt

When the installer, subiquity, finishes and reboots, it simply runs /sbin/reboot. This can be seen in the subiquity source code.

The installer environment will run /sbin/casper-stop during shutdown because of the systemd service defined in /lib/systemd/system/casper.service. This script will display the prompt and eject the media. The source code of the script shows that the prompt is configurable, but the eject command is called as long as the cdrom is mounted, and advertised as removable.

See also

  • https://unix.stackexchange.com/questions/528577/how-to-skip-please-remove-the-installation-medium-then-press-enter