Solved Unable to boot FreeBSD 13.1 whenever Internal or External hard drive is connected.

Hello,

Whenever I connect an internal storage SATA hard drive or external storage USB hard drive, FreeBSD does not boot and gets stuck at a prompt requiring me to enter a path name of shell. If I unplug the storage hard drive and restart the PC, FreeBSD boots as usual.

Would like to note that only the system hard drive for which FreeBSD is installed can be plugged in and would boot, if I connect another hard drive such as a storage drive, FreeBSD would simply not boot.

Here are my OS details:

Code:
OS: FreeBSD 13.1-RELEASE-p7 amd64
Uptime: 49 mins
Packages: 1874 (pkg)
Shell: sh
Resolution: 1920x1080
DE: Plasma 5.27.6
WM: KWin
Theme: [Plasma], Breeze [GTK2/3]
Icons: [Plasma], breeze-dark [GTK2/3]
Terminal: konsole
CPU: AMD FX-8350 (8) @ 3.991GHz
GPU: Ellesmere [Radeon RX 470/480/570/570X/580/580X/590]
Memory: 10265MiB / 32684MiB


Please view the picture below to get a better understanding to what I am describing:

IMG_3763_2.jpg



Here are the details of the hard drives, the system drive which FreeBSD is installed and the 2TB storage internal drive:

$ gpart show

Code:
=>       40  488397088  ada0  GPT  (233G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    4194304     3  freebsd-swap  (2.0G)
    4728832  483667968     4  freebsd-zfs  (231G)
  488396800        328        - free -  (164K)

=>        40  3907029088  ada1  GPT  (1.8T)
          40  3774873600     1  ms-basic-data  (1.8T)
  3774873640   132155488        - free -  (63G)


Thank for any advice.
 
Last edited by a moderator:
Thanks for the reply.

Boot order in BIOS is:

1) FreeBSD (I assume this is UEFI ?)
2) System hard drive (FreeBSD).
3) CD/DVD Drive.
4) USB Drive
5) UEFI (Built-in EFI Shell)

I have attached pictures of the BIOS Menu:
IMG_3765-2.jpg


IMG_3767-2.jpg


Thanks.
 
Gpart is telling us that you have a UEFI FreeBSD boot partition on ada0.

cd0 has an error, probably empty

da0 through da4a (USB?) are NOT READY and have no media.

The system is trying to boot from ada0p1, which is the EFI partition.

But the (MSDOS) file system is damaged. This is a serous issue.

It seems that you are able to boot with manual intervention (or maybe from a rescue USB/CD).

Have you tried fsck_msdosfs /dev/ada0p1
 
There is an exchange between ada0 and ada1 if I well read the messages that the kernel wrote on your screen. It seems that the system tries to mount ada0p1 but it does that on your storage disk which became ada0 (idem for the swap). Hence, the problems about file system.

You can exchange the sata connection between these two disks. You can also label your partitions on ada0 and modify /etc/fstab accordingly to avoid this.
 
If devices got reordered due to attaching a USB disk, you could label your partitions with gpart label and put those into /etc/fstab instead (i.e. "/dev/gpt/labelname" for whatever instead of /dev/ada0p1).
 
Gpart is telling us that you have a UEFI FreeBSD boot partition on ada0.

cd0 has an error, probably empty

da0 through da4a (USB?) are NOT READY and have no media.

The system is trying to boot from ada0p1, which is the EFI partition.

But the (MSDOS) file system is damaged. This is a serous issue.

It seems that you are able to boot with manual intervention (or maybe from a rescue USB/CD).

Have you tried fsck_msdosfs /dev/ada0p1

Thanks for the reply,

ada0 is the FreeBSD installation drive and I think UEFI installs at ada0.

cd0 it is a CD/DVD drive and has no media discs.

da0 to da4a is a Multi Media Memory Card Reader, nothing is inserted.

The MSDOS drive is the NTFS hard drive, it was formatted and created on FreeBSD, it works properly. This is what causes FreeBSD to not properly boot if it is plugged into the PC.
If I remove this drive from the PC, FreeBSD would boot. I can only use this drive only after FreeBSD boots and able to mount it.

There is an exchange between ada0 and ada1 if I well read the messages that the kernel wrote on your screen. It seems that the system tries to mount ada0p1 but it does that on your storage disk which became ada0 (idem for the swap). Hence, the problems about file system.

You can exchange the sata connection between these two disks. You can also label your partitions on ada0 and modify /etc/fstab accordingly to avoid this.

Thanks for the reply,

I will try to change the SATA connection.
It is weird that FreeBSD is mounting ada0p1 to the storage drive (which is formatted to NTFS) which only contains data and no OS files related to FreeBSD.

Is it possible you can describe how I could label the partition on ada0 and modify the fstab file?

If devices got reordered due to attaching a USB disk, you could label your partitions with gpart label and put those into /etc/fstab instead (i.e. "/dev/gpt/labelname" for whatever instead of /dev/ada0p1).

Thanks for the reply,

How is this done exactly?
 
Your efi partition, ada0p1, is dirty and has filesystem issues. That's why it's failing to mount from /etc/fstab. Which causes the entire boot to stop and drop to single user mode. I would recommend setting it to noauto in fstab. It doesn't need to be mounted all time. You only need to mount it if you have to update loader.efi(8).
 
Your efi partition, ada0p1, is dirty and has filesystem issues. That's why it's failing to mount from /etc/fstab. Which causes the entire boot to stop and drop to single user mode.
A dirty file system is not the issue in this case. /dev/ada0p1 is not the efi partititon on the allegedly FreeBSD system disk /dev/ada0.

Contrary to the gpart show list in post #1, in which the FreeBSD disk is listed as ada0, it is not in the image.

Note at the top of the image the disk size of ada0 (1907729MB) and ada1 (238475MB). Compared with the gpart show list it's clear which disk is the FreeBSD system.

First thing I do after a fresh install (mostly ZFS) is to edit the /etc/fstab file, changing the device names to GPT device labels, which are already available.

When installing by the dialog guided install, the system partitions are gpart labeled automatically. Example (I am writing from memory, if not correct, it should be similar):
Code:
/dev/gpt/efi0
/dev/gpt/boot0 # freebsd-boot
/dev/gpt/swap0
/dev/gpt/zfs0

If I'm not mistaken (I don't have a system at hand to check), on a fresh 13.2 installation the efi partition is noted by its GPT label in /etc/fstab.


First_Law_of_Unix, you should use GPT labels in /etc/fstab to avoid jumbled device names.

Run gpart show -l and edit /etc/fstab accordingly (set efi and swap partition labels in the corresponding lines):
Code:
/dev/gpt/...

EDIT:
OS: FreeBSD 13.1-RELEASE-p7 amd64
Note that the 13.1 branch is End of Life since July 31, 2023 and therefore not supported anymore.
 
How is this done exactly?
Check you /etc/fstab file. You'll see references to your different partitions, i.e. ada0p1 (boot/efi partition), ada0p3 (swap)

Code:
=>       40  488397088  ada0  GPT  (233G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    4194304     3  freebsd-swap  (2.0G)
    4728832  483667968     4  freebsd-zfs  (231G)
  488396800        328        - free -  (164K)

=>        40  3907029088  ada1  GPT  (1.8T)
          40  3774873600     1  ms-basic-data  (1.8T)
  3774873640   132155488        - free -  (63G)

You can label a partition like this (examples):
Code:
gpart modify -l efi -i 1 ada0
gpart modify -l swap -i 3 ada0
You will then have labeled your efi partition ada0p1 "efi" and ada0p3 as "swap". This should then allow you to change your /etc/fstab entries. Replace /dev/ada0p1 with /dev/gpt/efi and /dev/ada0p3 with /dev/gpt/swap.

My hunch is, you do not have a broken msdos efi partition, but your devices get reordered and FreeBSD is attempting to mount what is "ada1p1" in your listing above.

PS. Since I don't know, whether you've got anything in /boot/loader.conf - please be aware of disk identifier and label clashes that might originate from settings in there - see https://forums.freebsd.org/threads/missing-dev-gpt.77360/ for example
PPS. Here's a more thorough write up: https://forums.freebsd.org/threads/labeling-partitions-done-right-on-modern-computers.69250/
 
I am having the same issue. I want to add a 6TB internal HDD, but when trying to boot into my FreeBSD setup, which is on a separate HDD and which works without the "new" HDD, after adding the new HDD, FreeBSD comes up with that mountroot> which up until now I had never seen before.

I'll follow your suggestions and will try to report back.

BTW, the HDD works just fine in Windows, but I had to partition it GPT.

Ken
 
Alright... I know it's almost a year for an update.

However everything seems to be working fine now.
I simply edited the fstab to what relates stated in gpart show on connected drives and FreeBSD boots as intended with external drives connected.
I've also upgraded 13.1 to 14.1.

Thanks everyone for the advices.
 
Back
Top