# Reduce boot time in X86 arch



## jr.santhoshkumar (Feb 21, 2019)

I am using GENERIC configuration kernel.
With that kernel FreeBSD is taking 28sec to boot from boot0 to entire control switch to user.
I striped off  auto boot by specifying  #autoboot_wait="0" in loader.conf file.
Even-though it is taking 28sec .
Please help me to reduce the booting time further, probable less-than 10sec.

Thanks in advance


----------



## balanga (Feb 21, 2019)

You could mention what hardware you are using and which version of FreeBSD...


----------



## Phishfry (Feb 21, 2019)

Boot time depends on 2 things.
1)Number of devices on system that need probing.
2)Speed of /root storage device in loading modules into memory.

For #1 On my server board I have 48CPU's. Because of this it takes much longer to boot up.
Serverboards typically have many PCI devices and buses. They all take longer to setup.

#2 - You can defiantly decrease your boot time with a fast disk subsystem.


----------



## Phishfry (Feb 21, 2019)

I don't think a kernel slimming really makes a system boot much quicker. Kernel is only ~28MB but look at all the modules.
Another area to start with is services. Do you really need vi-recover.
Checkout running services with `service -e`. All have a knob in /etc/rc.conf to disable.
Checkout the prototype in /etc/default/rc.conf


----------



## SirDice (Feb 21, 2019)

Most servers spend a LOT of time in POST initializing SAS/SATA cards and such. This alone takes more time than loading the biggest, fattest kernel you could possible have.


----------



## jr.santhoshkumar (Feb 21, 2019)

balanga said:


> You could mention what hardware you are using and which version of FreeBSD...


I am using Intel NUC platform
FreeBSD version 12.0 stable


----------



## jr.santhoshkumar (Feb 21, 2019)

SirDice said:


> Most servers spend a LOT of time in POST initializing SAS/SATA cards and such. This alone takes more time than loading the biggest, fattest kernel you could possible have.



you have specified server in your statement, you mean our pc or something else?


----------



## balanga (Feb 21, 2019)

Just out of interest, is there a facility within FreeBSD which show how long it takes to boot? ie can you set some sort of automatic timer?


----------



## SirDice (Feb 21, 2019)

Strip the kernel, remove all non-essential devices. Load additional modules with kld_list in rc.conf. Set the interface to DHCP instead of SYNCDHCP. 

What kind of disk does the NUC have? If it's a relatively slow 5400 RPM 2.5" disk you could replace that with an SSD. 

There isn't anything more you can do to speed things up.


----------



## Phishfry (Feb 21, 2019)

Even with my smallest hardware customized NanoBSD builds at 175MB it still took longer than 10 seconds to boot.


----------



## jr.santhoshkumar (Feb 21, 2019)

Phishfry said:


> Boot time depends on 2 things.
> 1)Number of devices on system that need probing.
> 2)Speed of /root storage device in loading modules into memory.
> 
> ...


*Number of devices on system that need probing:
*I commented most of the device which is not needed for Intel NUC platform
    If I run buildworld and buildkernel for that config file, in the destination directory I am not seeing all the file in /etc folder, so that I am unable to boot newly configured kernel in other plaform. It is asking for some files for eg: rc.subr.


----------



## jr.santhoshkumar (Feb 21, 2019)

SirDice said:


> Strip the kernel, remove all non-essential devices. Load additional modules with kld_list in rc.conf. Set the interface to DHCP instead of SYNCDHCP.
> 
> What kind of disk does the NUC have? If it's a relatively slow 5400 RPM 2.5" disk you could replace that with an SSD.
> 
> There isn't anything more you can do to speed things up.


In NUC 
already I am using SSD


----------



## SirDice (Feb 21, 2019)

jr.santhoshkumar said:


> If I run buildworld and buildkernel for that config file, in the destination directory I am not seeing all the file in /etc folder, so that I am unable to boot newly configured kernel in other plaform. It is asking for some files for eg: rc.subr.


Files in /etc/ are not installed with install{kernel,world}. You need to use mergemaster(8) for that.


----------



## jr.santhoshkumar (Feb 21, 2019)

SirDice said:


> Files in /etc/ are not installed with install{kernel,world}. You need to use mergemaster(8) for that.


If I kernel install{kernel, world} command. 
It is ending with an error called install symboliclink -> c    ../POSIX no such file or directory (in some path it is serching for POSIX file, sorry i forgot that path)
I can't run that command successfully


----------



## SirDice (Feb 21, 2019)

It's not a specific command. The correct procedure to do a source update is:

```
cd /usr/src
make clean
make buildworld buildkernel
make installkernel
(reboot to single user mode)
mergemaster -p
make installworld
mergemaster -U
(reboot)
```


----------



## jr.santhoshkumar (Feb 21, 2019)

balanga said:


> Just out of interest, is there a facility within FreeBSD which show how long it takes to boot? ie can you set some sort of automatic timer?


I am searching for that facility also, but still I didn't find any solution for RTC
I am using my phone to calculate time, it is an approximate time


----------



## jr.santhoshkumar (Feb 21, 2019)

SirDice said:


> It's not a specific command. The correct procedure to do a source update is:
> 
> ```
> cd /usr/src
> ...


This is the procedure to build kernel in own pc. If I reboot, our newly build kernel will upon run. But I need to run that in different platform
If I need to build kernel for different platform, whether I need to specify any destination directory ?
If I specify that destination directory , is that enough to run newly build kernel successfully?


----------



## SirDice (Feb 21, 2019)

What exactly do you mean by "different platform"? Different architecture? Or just a another machine (but the same architecture as the build server)?


----------



## jr.santhoshkumar (Feb 22, 2019)

SirDice said:


> What exactly do you mean by "different platform"? Different architecture? Or just a another machine (but the same architecture as the build server)?


I am using Intel NUC5cpyh


----------



## jr.santhoshkumar (Feb 22, 2019)

SirDice said:


> It's not a specific command. The correct procedure to do a source update is:
> 
> ```
> cd /usr/src
> ...


I created a directory in /root called geskern
I executed command %make TARGET_ARCH=amd64 KERNCONF=GESKERN DESTDIR=/root/geskern buildworld buildkernel installkernel
until this command, it executes fine.

In above procedure, next step is to reboot and enter into the single user mood and execute mergemaster -p
If I do this, whethter it will after the host system or it will affect only the DESTINATION directory, which I specified while building?


----------



## pboehmer (Feb 22, 2019)

In my experience, the biggest hang-ups during the boot procedure is typically large number of CPUS/cores, (in the past) large amount of memory, number of disk controllers/drives, followed by network initialization (more so when connect to Cisco switch with spanning-tree enabled).  I imagine a fully spec'd Intel NUC with 8G DDR3-1600 and one SSD drive, probably gets from BIOS to network init pretty darn fast (even with GENERIC kernel) and hangs up there for 10-15 seconds.  Would be curious if things improve if you try a booting with a blank or stripped down /etc/rc.conf.


----------

