Solved Recovering bad loader.conf

Greetings,

I was reading a tutorial (now lost) that suggested adding a vesa="YES" directive to my loader.conf for one reason or another. Apparently, this was no good as the bad setting is preventing me from successfully booting into FreeBSD. What I would like to do is to use the LiveCD to mount my boot partition and fix the issue. However, after a heavy amount of googling, I have not been able to address my issue.

When I installed FreeBSD 11, I installed using the ZFS partition option and kept most / all of the default settings. As such, I am under the assumption that I need to use the zpool command to access my ZFS partition on the Live CD:

Code:
mkdir /tmp/zroot
zpool import -fR /tmp/zroot zroot

After typing the above, I now have access to the tmp, usr, var, and zroot directories within /tmp/zroot. However, the boot directory (and thus loader.conf) is not there. Is this expected, and if so, how can I access my boot directory?

Thanks,
Adam
 
gpart show:
Code:
ada0 GPT (60G)
1 freebsd-boot (512k)
2 freebsd-swap (2G)
3 freebsd-zfs (58G)

zpool import:
Code:
pool: zroot
id: {numbers}
state: ONLINE
config: 
   zroot ONLINE
      ada0p3 ONLINE

gkontos, typing unset vesa into the loader prompt (option #3 at boot menu?) results in the message "no such file or directory"

Thanks both for your replies,
Adam
 
Last edited by a moderator:
Greetings,

I was reading a tutorial (now lost) that suggested adding a vesa="YES" directive to my loader.conf for one reason or another. Apparently, this was no good as the bad setting is preventing me from successfully booting into FreeBSD. What I would like to do is to use the LiveCD to mount my boot partition and fix the issue. However, after a heavy amount of googling, I have not been able to address my issue.

When I installed FreeBSD 11, I installed using the ZFS partition option and kept most / all of the default settings. As such, I am under the assumption that I need to use the zpool command to access my ZFS partition on the Live CD:

Code:
mkdir /tmp/zroot
zpool import -fR /tmp/zroot zroot

After typing the above, I now have access to the tmp, usr, var, and zroot directories within /tmp/zroot. However, the boot directory (and thus loader.conf) is not there. Is this expected, and if so, how can I access my boot directory?

Thanks,
Adam
That option kicked one of my boxes too. it was an old option used I think on FreeBSD 8 or 9 and supported until 11. Now it crash the system and freebsd-update and even mergemaster do not knows about it :-(((( Good, old rough FreeBSD!

Then you still can boot selectiing the old kernel you had before upgrade (kernel.old) in the boot menu, fix the problem, and reboot 11.
 
  • Thanks
Reactions: Oko
gkontos, typing unset vesa into the loader prompt (option #3 at boot menu?) results in the message "no such file or directory"

I replicated your problem in a VM by specifying the exact parameters. System, FreeBSD 11.0-RELEASE

Screen_Shot_2016_11_14_at_16_53_42.png


However, please keep in mind that the error message you got, means that the setting is not present.
 
So then, what would be the next step? Clearly, I could just reinstall, but I've always felt like hitting my head against the wall is a great way to learn.
 
Greetings,

I was reading a tutorial (now lost) that suggested adding a vesa="YES" directive to my loader.conf for one reason or another. Apparently, this was no good as the bad setting is preventing me from successfully booting into FreeBSD. What I would like to do is to use the LiveCD to mount my boot partition and fix the issue. However, after a heavy amount of googling, I have not been able to address my issue.

When I installed FreeBSD 11, I installed using the ZFS partition option and kept most / all of the default settings. As such, I am under the assumption that I need to use the zpool command to access my ZFS partition on the Live CD:

Code:
mkdir /tmp/zroot
zpool import -fR /tmp/zroot zroot

After typing the above, I now have access to the tmp, usr, var, and zroot directories within /tmp/zroot. However, the boot directory (and thus loader.conf) is not there. Is this expected, and if so, how can I access my boot directory?

What's the output of ls /tmp/zroot after importing the pool?
 
  • Thanks
Reactions: Oko
/tmp/zroot has tmp, usr, var, and zroot. Obviously missing are boot and etc. Any ideas of where they might be?
 
From zfs list, I see that zroot/ROOT isn't mounted. Might that be the problem?
 

Attachments

  • zfs list.png
    zfs list.png
    9.9 KB · Views: 857
It's not supposed to be mounted because it only acts as a "container" for the enclosed datasets. You'll see the same pattern all over ZFS pools because a strict hierarchy of nested datasets all mounted in sequence can't be used like that.
 
I ran into this problem a month ago and since I was doing a fresh install, I just started over again. But this thread made me want to dig into it a little more. I setup a VM and was able to duplicate the problem and the fix that worked for me was to press "3" at the Boot Menu and then:

Code:
OK disable-module vesa
vesa will not be loaded
OK boot

The system then booted up normally without trying to load vesa and I was able to login and edit /boot/loader.conf
 
I ran into this problem a month ago and since I was doing a fresh install, I just started over again. But this thread made me want to dig into it a little more. I setup a VM and was able to duplicate the problem and the fix that worked for me was to press "3" at the Boot Menu and then:

Code:
OK disable-module vesa
vesa will not be loaded
OK boot

The system then booted up normally without trying to load vesa and I was able to login and edit /boot/loader.conf
This is the immediate fix; please try it. However, I'm curious why the fs did not mount. It worked in my tests.
 
Datapanic thanks that worked!

phoenix /tmp/zroot/zroot is empty. From a learning perspective, it's nice to know the quick fix. However, I too am curious as to why I can't see /boot, /etc, (others?) when I do a zpool import. This seems like it might be useful if I were to plug a drive into another computer for recovery or to pull files. Thanks everyone for all of their interest.
 
Okay, here's how to get to the filesystems of a RootOnZFS setup:

Boot into the Live CD and login as root.
Run zpool import to get the name of the zpool, which will probably be zroot
Create a mountpoint for the zpool: mkdir /tmp/zroot
Import the zpool: zpool import -fR /tmp/zroot zroot
Create a mountpoint for zfs /: mkdir /tmp/root
Mount /: mount -t zfs zroot/ROOT/default /tmp/root

The RootOnZFS directories will now be under /tmp/root so that you can make changes as needed. When done, export the zpool: zpool export zroot and reboot back to your normal system.

It looks like the ZFS file systems need to be mounted after the zpool is imported.

I found the clue when looking at a normal RootOnZFS bootup - one of the last lines in dmesg will be:
Code:
Trying to mount root from zfs:zroot/ROOT/default []...
If you run zfs list after the zpool has been imported, you can see the / MOUNTPOINT:

Code:
NAME               USED  AVAIL  REFER  MOUNTPOINT
...
zroot/ROOT/default  8.22G  3.58T  8.22G  /
...
 
Okay, here's how to get to the filesystems of a RootOnZFS setup:

Boot into the Live CD and login as root.
Run zpool import to get the name of the zpool, which will probably be zroot
Create a mountpoint for the zpool: mkdir /tmp/zroot
Import the zpool: zpool import -fR /tmp/zroot zroot
Create a mountpoint for zfs /: mkdir /tmp/root
Mount /: mount -t zfs zroot/ROOT/default /tmp/root

The RootOnZFS directories will now be under /tmp/root so that you can make changes as needed. When done, export the zpool: zpool export zroot and reboot back to your normal system.

It looks like the ZFS file systems need to be mounted after the zpool is imported.

I found the clue when looking at a normal RootOnZFS bootup - one of the last lines in dmesg will be:
Code:
Trying to mount root from zfs:zroot/ROOT/default []...
If you run zfs list after the zpool has been imported, you can see the / MOUNTPOINT:

Code:
NAME               USED  AVAIL  REFER  MOUNTPOINT
...
zroot/ROOT/default  8.22G  3.58T  8.22G  /
...

Can we get this into the handbook please? I couldn't find anything about performing this sort of recovery.
 
Datapanic your directions just saved me from re-installing a whole server, for which KVM is not available, so I was unable to boot in single-user mode.

I was able to boot using mfsbsd, and import zroot.

But /etc and /boot were missing.

I could not find anywhere how to mount /etc and /boot directories of a remote server while in rescue mode.

It took me a few hours of searching to finally reach your post.

Your directions should definitely be put in the handbook.

Thank you very much, I owe you one!
 
Last edited by a moderator:
Thank you. Just ran into this and it wasn't clear where the missing files/directories were.

---

One of my systems (a remote system) was not booting after an attempted upgrade to FreeBSD 11.1-RELEASE. Adding this line to /etc/fstab got the system to boot:

Code:
zroot/ROOT/default      /       zfs     rw      0       0
 
Last edited:
Can we get this into the handbook please? I couldn't find anything about performing this sort of recovery.
That is it !!!
I looked for a week for this answer. The handobook induces us to enter vesa_driver = "YES", but does not warn that it works only on 386 (as I read in other posts).
By the way ... Thanks for my misery: so I learned a lot in this FreeBSD Forum and even learned about zfs (wonderful, in the least).
Thank you Topcat for your accurate guidance!
 
Back
Top