# FreeBSD boot time



## ist (Apr 15, 2020)

Hi, newcomer here.

I'm having problems with unusually long boot time of the system. It takes around 45 seconds. I don't remember it being that way last time I tinkered with FreeBSD. The system I installed it on is Thinkpad T440p with i5-4300m, 12GB RAM and I used the m.2 SATA SSD for it. I used UEFI with GPT partitions. 

It's a fresh install with ZFS. I didn't enable any services at startup other than cleanup of /tmp directory. I didn't update or upgrade anything yet.

Any help is appreciated.


----------



## SirDice (Apr 15, 2020)

Is it connected to the network if you boot it?  It might be waiting for a DHCP response on the (wired) interface before it continues to boot. If it's not connected it will take a while for this to time-out.


----------



## ist (Apr 15, 2020)

Yes, it's connected to network through wlan interface. I don't remember configuring anything for wired interface.

Something strange I noticed during boot are these messages showing up few times. Quite a bit of time is spent on these.

```
Root mount waiting for: usbus0
usbd_req_re_enumerate: addr=2, set address failed (USB_ERR_TIMEOUT, ignored)
```

Other than that, there's 8-10 seconds delay after following command appears:

```
wlan0: link state changed to UP
```

Is there a way to log boot process?


----------



## SirDice (Apr 15, 2020)

Those USB time-outs don't look good. 



ist said:


> Is there a way to log boot process?


You can do a verbose boot, you can enable that on the loader menu. That should provide more information. Also look at dmesg(8) and/or /var/log/messages for anything out of the ordinary.


----------



## George (Apr 15, 2020)

I have never tried this. But according to the Syslogd manpage, you can enable timestamps in the dmesg output.



> _*O* format
> Select the    output format of generated log messages.  The values
> bsd and rfc3164 are used to generate RFC 3164 log messages. The
> values syslog and rfc5424 are used to generate RFC 5424 log mes-
> ...



This could help finding the one process that slows you down.


----------



## ist (Apr 15, 2020)

The USB thing is definitely out of order. There seems to be a problem with XHCI drivers for USB 3.0. There seems to be a few bugs reported for this issues similar to this. But even with that bug, boot takes too long. Usually stuff on old thinkpads work .


----------



## ist (Apr 16, 2020)

SirDice, I think you were right. I freshly installed FreeBSD without configuring network at installation and boot time reduced to 15 seconds. I'll try to manually configure network now.


----------



## Mjölnir (May 22, 2020)

Lessen the USB timeout in /boot/loader.conf:

```
kern.cam.boot_delay="2000"
```
and concerning the WLAN interface, change in /etc/rc.conf

```
defaultrouter=""
background_dhclient="YES"
ifconfig_wlan0="WPA DHCP"
```
This might help. background_dhclient is not really needed as it's default.


----------



## DavidMarec (May 28, 2020)

mjollnir said:


> ```
> defaultrouter=""
> synchronous_dhclient="YES"
> # ....
> ```



If one would like to improve boot time, maybe background_dhclient="yes" may be used instead ?


----------



## Mjölnir (May 28, 2020)

DavidMarec said:


> If one would like to improve boot time, maybe background_dhclient="yes" may be used instead ?


Ouch, sorry.


----------



## wolffnx (May 29, 2020)

and maybe 

```
defaultroute_delay="1" 
# Time to wait for a default route on a DHCP interface.
```


----------



## Alain De Vos (May 29, 2020)

I wander, is there a "systemd-analyze blame" alike feature ?


----------



## SirDice (May 29, 2020)

Alain De Vos said:


> I wander, is there a "systemd-analyze blame" alike feature ?


The person in the chair may or may not have that feature


----------



## Mjölnir (May 30, 2020)

Another delay comes from the UEFI boot process.  I could drasically reduce the boot time before the FreeBSD loader comes in by setting the UEFI/BIOS setting:

```
Boot Method: UEFI only
CSM: off
```


----------

