Bug 271632 - Feature request: Make bsdinstall eject install ISO
Summary: Feature request: Make bsdinstall eject install ISO
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-25 16:48 UTC by Jason W. Bacon
Modified: 2023-05-25 22:48 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason W. Bacon freebsd_committer freebsd_triage 2023-05-25 16:48:58 UTC
When installing a VM under VirtualBox or similar systems, it would be helpful for bsdinstall to eject the ISO image before rebooting.

Manually ejecting is difficult since it cannot be done until the ISO is unmounted, which occurs just before reboot, and the BIOS post time is about 1 second for a VM.  The user has very little time to eject the ISO and prevent the VM from booting from the install media again after installation.

Same may apply to bare metal systems, though the user has much more time to remove the media before the next boot.
Comment 1 Glen Barber freebsd_committer freebsd_triage 2023-05-25 16:57:52 UTC
Last I looked, which I admit was quite some time ago, removing the installer before reboot(8) or shutdown(8) ended up constantly spewing garbage on the console until the system (VM or not) was forcibly reset.

FWIW, when using VirtualBox, I always set the first hard drive as the first boot device and fall back to CD-ROM as the last option, which does not exhibit the problem of booting back into the installer.
Comment 2 Mina Galić freebsd_triage 2023-05-25 17:14:09 UTC
virt-manager, smartly, ejects the installation Medium when the VM is rebooted
Comment 3 Glen Barber freebsd_committer freebsd_triage 2023-05-25 17:27:47 UTC
During the invocation of reboot(8), or when the system is reset and is about to boot again?
Comment 4 Mina Galić freebsd_triage 2023-05-25 17:35:11 UTC
(In reply to Glen Barber from comment #3)
pretty sure it's the latter.
I don't think qemu knows the system is rebooting until it resets, and probably takes that as cue that the installation is finished, and the installation medium can be removed
Comment 5 Glen Barber freebsd_committer freebsd_triage 2023-05-25 18:02:56 UTC
Then, IMHO, this is a feature request for the VirtualBox developers.  In short, you cannot take away the root mountpoint (in this case, a CD-ROM ISO) prior to or during a system reboot.  At that point, it would be up to the hypervisor to determine if the media should still be mounted.
Comment 6 Jason W. Bacon freebsd_committer freebsd_triage 2023-05-25 18:14:07 UTC
(In reply to Glen Barber from comment #1)

I had thought about making the CD secondary, but I'm mainly looking at this from the perspective of new users trying out FreeBSD for the first time.  Some of the Linux systems I've installed recently eject the media without any issues, so they appear more user-friendly in that sense right off the bat.

Maybe there's a way we can trigger an eject upon the next reset, or incorporate an eject as a command-line flag of reboot(8) or shutdown(8), which I presume could unmount the media first.  I haven't looked into any of the code yet, so I'm just hypothesizing here.
Comment 7 Jason W. Bacon freebsd_committer freebsd_triage 2023-05-25 18:15:45 UTC
(In reply to Glen Barber from comment #5)

VirtualBox is only an example here.  The same problem exists for any VM, or for bare metal if the user gets distracted.
Comment 8 Mina Galić freebsd_triage 2023-05-25 18:20:54 UTC
(In reply to Jason W. Bacon from comment #7)
true.

my biggest problem is telling the installer from the boot actually boot screen apart
Comment 9 Brooks Davis freebsd_committer freebsd_triage 2023-05-25 18:24:41 UTC
(In reply to Mina Galić from comment #8)
FWIW, jtrc27 made some improvements to the loader menu recently so it's possible to tell the installer loader from the installed loader, but it's still fairly subtle (IIRC two lines differ).
Comment 10 Jason W. Bacon freebsd_committer freebsd_triage 2023-05-25 22:48:15 UTC
If it's not obvious to anyone how to add an eject option, I can figure it out and send a suggested patch.

At some point in the reboot sequence, there must be a "umount /".  I think inserting an optional eject command after that and before the reset should solve the problem across the board (assuming eject is possible for the given media).  How we get there from bsdinstall I don't know yet (shutdown -r, reboot, init 6?), but I can track it down and figure out a tweak.