# Source code of FreeBSD installer



## ahev (Mar 28, 2020)

Where do I find the logic behind the FreeBSD installer that is contained in a memstick image and is run when I boot from it?


----------



## Phishfry (Mar 28, 2020)

If you have the source code installed you can use find:
`find /usr/src -name 'bsdinstall*'`
/usr/src/usr.sbin/bsdinstall
/usr/src/usr.sbin/bsdinstall/bsdinstall.8
/usr/src/usr.sbin/bsdinstall/bsdinstall
/usr/src/release/packages/bsdinstall.ucl


----------



## Phishfry (Mar 28, 2020)

As you can see here:








						freebsd-src/usr.sbin/bsdinstall/scripts at master · freebsd/freebsd-src
					

FreeBSD src tree (read-only mirror). Contribute to freebsd/freebsd-src development by creating an account on GitHub.




					github.com
				



The various phases are simply scripts.


----------



## ahev (Mar 28, 2020)

Phishfry said:


> As you can see here:
> 
> 
> 
> ...



Exactly, but I have imagined the installer to be some graphical application and skipped studying bsdinstall at all, (and in fact I see in the usr.sbin/bsdinstall/(distextract|partedit|distfetch)/Makefile that curses library is need as a dependency, so things add up).

But there is still this thing that I do not understand. If the various steps are scripts, then where is the logic that asks the user to select which of them to execute?


----------



## Phishfry (Mar 28, 2020)

The application `dialog` is an offshoot of ncurses. It is what bsdinstall uses for gui.
Notice in the jail script the very first bsdinstaller screen.

```
dialog --backtitle "FreeBSD Installer" --title "Abort" \
        --no-label "Exit" --yes-label "Restart" --yesno \
        "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
    if [ $? -ne 0 ]; then
exit
```
So dialog is creating --yesno type input.


----------



## Phishfry (Mar 28, 2020)

Here is a small tutorial to checkout dialog and how it works:




__





						Dialog: An Introductory Tutorial | Linux Journal
					






					www.linuxjournal.com


----------

