# FreeBSD startup freezes after first install



## Robby (Jan 7, 2021)

Sorry for my English...

I've installed FreeBSD (FreeBSD-12.1-RELEASE-amd64-disc1.iso) on a multiboot PC (Legacy, GPT, sda3). All seems well, only the DHCP confiuration doesn't work. I added some static values, and hope to correct DHCP later.
In Grub I added:

```
menuentry "FreeBSD Loader" {
    insmod bsd
    insmod ufs2
    insmod part_gpt
    set root=(hd0,gpt3)
    chainloader /boot/boot1.efi
}
```

FreeBSD starts up for the first time with an error: "can't find /etc/hostid." Then it continues and freezes after the line: Masks:

What did I do wrong? Any suggestions?


----------



## T-Daemon (Jan 7, 2021)

Please boot the xx-disc1.iso, at the installer "Welcome" dialog change to "Shell", plug in a USB stick, mount it, enter `gpart show > /path_to_USB/gpart`, post gpart.


----------



## Robby (Jan 8, 2021)

Hi T-Daemon,
Thanks for looking into it. I'm not yet that familiar with the shell commands for FreeBSD.  `lsblk -l` in Linux gives this:

```
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda    8:0    0 232,9G  0 disk
sda1   8:1    0     1G  0 part
sda2   8:2    0   512K  0 part
sda3   8:3    0    50G  0 part
sdb    8:16   0 111,8G  0 disk
sdb1   8:17   0   529M  0 part
sdb2   8:18   0   100M  0 part /boot/efi
sdb3   8:19   0    16M  0 part
sdb4   8:20   0    74G  0 part
sdb5   8:21   0  37,1G  0 part /
sdc    8:32   0 465,8G  0 disk
sdc1   8:33   0    16M  0 part
sdc2   8:34   0 465,7G  0 part /mnt/Data
```
FreeBSD is on sda3 (sda2 seems to be a FreeBSD boot partition) and the usb is /dev/sdd (Ventoy)

Is this the info you need? If it is not, sorry. To do what you need me to do, should I enter the command: `mount_msdosfs /dev/daOs1 media/usb`


----------



## SirDice (Jan 8, 2021)

Robby said:


> should I enter the command: `mount_msdosfs /dev/daOs1 media/usb`


That would be da0 (that's a zero, not the letter O). The numbering follows the same order on Linux, sda = da0, sdb = da1, etc. Where Linux uses letters, a,b,c,d, etc. FreeBSD uses numbers, 0,1,2,3, etc. Note that we start counting disks from zero.

The s1 is the first partition (in BSD lingo, a slice) of an MBR partitioned disk. You said you have GPT then the partitions are named and numbered as p1, p2, etc. The stick is likely MBR, they often are. You can check with the `gpart show` command.


----------



## Robby (Jan 8, 2021)

Hi SirDice,
Thanks for explaining that. I've 3 physical HDD's. The one with BSD has GPT. (I had to change it from MBR to GPT because I couldn't get BSD running on MBR).
The USB has on /dev/sdd2 (da3s2 ?) a MBR, FAT16. I thought that after the instillation on the HDD it wouldn't matter any more how the original USB was formatted.


----------



## T-Daemon (Jan 9, 2021)

Robby said:


> I'm not yet that familiar with the shell commands for FreeBSD.


No problem. After booting the ISO, enter "Shell", plug in the USB. There should appear messages regarding the USB device, including the device name and unit number (eg.: da0). Check with `gpart show` the complete name of the device as SirDice explained.

Execute (replace unit number 0 if necessary):

```
# mount_msdosfs /dev/da0s1 /mnt
# gpart show > /mnt/gpart
# sysctl machdep.bootmethod > /mnt/bootm
# umount /mnt
```
Post gpart and bootm files.


----------



## Robby (Jan 9, 2021)

I'm a bit confused. After BSD boots I get the welcome menu. What should I do next to enter "Shell". Typing a "S" results in starting the single user mode. Using f.i. a <space bar>  results in leaving the menu. But "Shell" isn't a command. I googled... Sorry for the stupid question but how do I enter "Shell"?


----------



## SirDice (Jan 9, 2021)

Robby said:


> After BSD boots I get the welcome menu.


Just wait or hit enter here. The choice comes a little later in the boot process.


----------



## Robby (Jan 9, 2021)

Ah, that explains it. Well than I've got a problem... Before that point the system freezes. The last line a see in the boot process is: "Masks .....   ....... ..... ..... "


----------



## T-Daemon (Jan 9, 2021)

Robby said:


> I'm a bit confused. After BSD boots I get the welcome menu. What should I do next to enter "Shell". Typing a "S" results in starting the single user mode.


It's not the "Welcome to FreeBSD" boot menu I meant.






You need to boot the FreeBSD installation image (FreeBSD-12.1-RELEASE-amd64-disc1.iso) from which you installed the system. After finishing boot, the "FreeBSD Installer Welcome" dialog is presented as seen in the screenshot. Choose "Shell" to enter the shell to execute the commands.





After you are done with the commands from post #6, to shutdown the system enter `poweroff`.

Or does the system freeze happens booting the FreeBSD installation image?


----------



## Robby (Jan 9, 2021)

When I boot from the PC I get this (see photo):

I can however boot from USB and then there is no problem. I can hit the Shell option. But as far as I understand this is not what you want me to do, right?


----------



## T-Daemon (Jan 9, 2021)

Robby said:


> When I boot from the PC I get this (see photo):


_Don't_ boot from the PC installed system. 



Robby said:


> I can however boot from USB and then there is no problem. I can hit the Shell option. But as far as I understand this is not what you want me to do, right?


That's exactly what I want. 

Boot from the USB, when the "FreeBSD Installer Welcome" dialog appears (the image with the blue background from post #10) hit the "Shell" option, in the shell execute the commands from post #6, afterwards shutdown system by entering `poweroff`, post gpart and bootm files.


----------



## Robby (Jan 10, 2021)

I get: No such file or directory.
gpart shows:


----------



## T-Daemon (Jan 10, 2021)

At the GRUB menu choose "FreeBSD loader", press the "E" key to edit the menu entry, set


```
menuentry "FreeBSD Loader" {
    set root="(hd0,gpt3)"
    kfreebsd /boot/loader
}
```

Press Ctrl-X or F10 to boot. If the system boot successful edit the linux GRUB configuration accordingly.


----------



## Robby (Jan 11, 2021)

If I do it the way you describe it results in a black screen. If I really update grub than it results in Error: file ‘boot/loader’ not found. So far I can only start BSD with chainloader /boot/boot1.efi or chainloader /boot/loader.efi


----------



## T-Daemon (Jan 11, 2021)

I'm away and will be away for some time from my systems, can not test in place.

You could use Supergrubdisk2





						Rescue your Windows & GNU/Linux systems
					

Rescatux Fixes GRUB / GRUB2 Many UEFI boot options Check and fix filesystems Clear Windows password Change Gnu/Linux password Regenerate sudoers file And much more features… How to put Rescatux into a CDROM or a USB ~ 672 MB Size Super Grub2 Disk Boots into many systems and GRUB2 ones! Helps you...




					www.supergrubdisk.org
				



to determine the correct GRUB menu entry:


			https://sourceforge.net/projects/supergrub2/files/2.04s1/super_grub2_disk_2.04s1/super_grub2_disk_hybrid_2.04s1.iso/download
		


Install [ 1 ] the image on a USB stick, boot that stick, let Supergrub2 detect FreeBSD. There will be multiple menu entries for FreeBSD, test the EFI detected. If that doesn't work try the others.

If FreeBSD boots well, reboot into Supergrub2, choose the menu entry booting well, press the 'E' key to enter into editor mode, copy the entry into the on PC installed GRUB's custom configuration file. If you have difficulties following the instructions please ask.

[ 1 ] `dd if=super_grub2_disk_hybrid_2.04s1.iso of=/dev/da0 bs=1m conv=sync`

Make sure /dev/da0 is the USB stick, change the unit number (0) if necessary.


----------



## Robby (Jan 12, 2021)

I think we are making some progress. This is what supergrub2 makes of it:

```
setparams ‘FreeBSD (ufs2 hd1,gpt3) (Default boot loader)’hd1,pgt3’ ‘5ffae7bddec55b14’

set root=”$2”

kfreebsd bootloader
```

Supergrub2 can start FreeBSD. But I have some problem to set this code to the 40_custom file. This code results in "error: unknown filesystem."


```
menuentry "FreeBSD" {

insmod ufs2

set root=(hd1,gpt3)

kfreebsd /boot/loader

}
```

How should I adjust it?


----------



## T-Daemon (Jan 12, 2021)

Robby said:


> setparams ‘FreeBSD (ufs2 hd1,gpt3) (Default boot loader)’hd1,pgt3’ ‘5ffae7bddec55b14’
> set root=”$2”
> kfreebsd bootloader


If that's the exact menu entry in Supergrub2 for FreeBSD, set in the 40_custom file:

```
menuentry "FreeBSD" {
   set root=(hd1,gpt3)
   kfreebsd bootloader
}
```


----------



## Robby (Jan 13, 2021)

> setparams ‘FreeBSD (ufs2 hd1,gpt3) (Default boot loader)’hd1,pgt3’ ‘5ffae7bddec55b14’
> set root=”$2”
> kfreebsd /boot/loader



If forgot the / in boot/loader. Sorry. After I add the / in your code, I get the error "unknown filesystem". Because BSD is on hd0,3 and not on hd1,3 I've tried also hd0,gpt3 resulting in a black screen. I'm ready to give up...


----------



## Robby (Jan 13, 2021)

T-Daemon, thanks for all your help!


----------



## W.hâ/t (Jan 15, 2021)

You can try this

```
menuentry {
    setroot=(hd0, gpt3)
    kfreebsd=/boot/kernel/kernel
}
```
Or this (not sure this is a working configuration)
Make sure that you have the bootcode written in the freebsd-boot partition.

`gpart bootcode -b /boot/pmbr -i 2 -p /boot/gptboot ada0`

```
menuentry {
    set root=(hd0, gpt2)
}
```

Look at this thread: https://forums.FreeBSD.org/threads/how-do-i-configure-grub2-to-boot-freebsd-11-1.65992/

If none of this work, you can try to reinstall. Don't give up. FreeBSD is one of the best OS I know!


----------

