Discussion:
Restoring bootcode
(too old to reply)
Robert Fitzpatrick via freebsd-questions
2018-04-29 16:30:31 UTC
Permalink
Something happens to the bootcode since an upgrade a while back and I've
been starting this 10.4-RELEASE server at the loader OK prompt using
'set currdev=disk0s1a' and then boot. Here is the server system...

***@dev:~ # gpart show
=> 63 41942977 ada0 MBR (20G)
63 41929587 1 freebsd [active] (20G)
41929650 13390 - free - (6.5M)

=> 0 41929587 ada0s1 BSD (20G)
0 1024000 1 freebsd-ufs (500M)
1024000 524288 2 freebsd-swap (256M)
1548288 20480000 4 freebsd-ufs (9.8G)
22028288 19901299 5 freebsd-ufs (9.5G)

I've tried the following to install the boot code, but still ending up
at the loader prompt...

***@dev:~ # gpart bootcode -b /boot/mbr ada0
bootcode written to ada0

I also tried with ada0s1 with same result. Clearly I don't understand
how to get this done, can someone help?
--
Robert
Manish Jain
2018-04-29 18:18:04 UTC
Permalink
Post by Robert Fitzpatrick via freebsd-questions
Something happens to the bootcode since an upgrade a while back and I've
been starting this 10.4-RELEASE server at the loader OK prompt using
'set currdev=disk0s1a' and then boot. Here is the server system...
=>      63  41942977  ada0  MBR  (20G)
        63  41929587     1  freebsd  [active]  (20G)
  41929650     13390        - free -  (6.5M)
=>       0  41929587  ada0s1  BSD  (20G)
         0   1024000       1  freebsd-ufs  (500M)
   1024000    524288       2  freebsd-swap  (256M)
   1548288  20480000       4  freebsd-ufs  (9.8G)
  22028288  19901299       5  freebsd-ufs  (9.5G)
I've tried the following to install the boot code, but still ending up
at the loader prompt...
bootcode written to ada0
I also tried with ada0s1 with same result. Clearly I don't understand
how to get this done, can someone help?
Hi Robert,

/boot/mbr needs you to set ada0s1 as the active partition. The easier
solution in your case perhaps is:

gpart bootcode -b /boot/boot0 ada0
gpart bootcode -b /boot/boot ada0s1
--
Tx and Regards,
Manish Jain
Polytropon
2018-04-29 21:05:40 UTC
Permalink
Post by Manish Jain
Post by Robert Fitzpatrick via freebsd-questions
Something happens to the bootcode since an upgrade a while back and I've
been starting this 10.4-RELEASE server at the loader OK prompt using
'set currdev=disk0s1a' and then boot. Here is the server system...
=>      63  41942977  ada0  MBR  (20G)
        63  41929587     1  freebsd  [active]  (20G)
  41929650     13390        - free -  (6.5M)
=>       0  41929587  ada0s1  BSD  (20G)
         0   1024000       1  freebsd-ufs  (500M)
   1024000    524288       2  freebsd-swap  (256M)
   1548288  20480000       4  freebsd-ufs  (9.8G)
  22028288  19901299       5  freebsd-ufs  (9.5G)
I've tried the following to install the boot code, but still ending up
at the loader prompt...
bootcode written to ada0
I also tried with ada0s1 with same result. Clearly I don't understand
how to get this done, can someone help?
Hi Robert,
/boot/mbr needs you to set ada0s1 as the active partition. The easier
gpart bootcode -b /boot/boot0 ada0
gpart bootcode -b /boot/boot ada0s1
As this seems to be a MBR setup, the commands should probably be:

# gpart bootcode -b /boot/mbr ada0
# gpart set -a active -i 1 ada0
# gpart bootcode -b /boot/boot ada0s1

Step 1 will add the regular MBR boot code, assuming this is a
FreeBSD-only system (no boot manager required).

Step 2 covers the case where the "active" flag has accidentally
been cleared; make sure it is set again (so the system will
recognize the partition s1 as being active, and attempt booting
by transfering control to it).

Step 3 will install the kernel loading mechanism for the slice
that hosts the FreeBSD partitions (and therefore continue booting
the kernel from /boot/kernel/kernel on /dev/ada0s1a, its default
location).

See "man 8 boot" and "man gpart" (sec. EXAMPLES).

Further reading:

http://www.wonkity.com/~wblock/docs/html/disksetup.html#_the_old_standard_mbr

:-)
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
Robert Fitzpatrick via freebsd-questions
2018-04-30 16:28:47 UTC
Permalink
Post by Robert Fitzpatrick via freebsd-questions
# gpart bootcode -b /boot/mbr ada0
# gpart set -a active -i 1 ada0
# gpart bootcode -b /boot/boot ada0s1
Didn't work, I failed to post the messages received before kicking out
to the OK loader prompt. I'm seeing this...

can't open 'boot/menu.4th': no such file or directory
Error while including /boot/menu.rc, in the line:
include /boot/menu.4th
\
can't load 'kernel'

I can see that menu.4th is not in the /boot directory. I do see the
below in my menu.rc, all of the files are present in /boot except the
menu.4th and menu-commands.4th. The only file in the /boot folder
starting with menu is the menu.rc.

\ Load required Forth modules
include /boot/version.4th
include /boot/brand.4th
include /boot/menu.4th
include /boot/menu-commands.4th
include /boot/shortcuts.4th
--
Robert
Polytropon
2018-04-30 18:41:57 UTC
Permalink
Post by Robert Fitzpatrick via freebsd-questions
Post by Robert Fitzpatrick via freebsd-questions
# gpart bootcode -b /boot/mbr ada0
# gpart set -a active -i 1 ada0
# gpart bootcode -b /boot/boot ada0s1
Didn't work, I failed to post the messages received before kicking out
to the OK loader prompt. I'm seeing this...
can't open 'boot/menu.4th': no such file or directory
include /boot/menu.4th
\
can't load 'kernel'
This shows that a file required for boot isn't there, but
this has nothing to do with the MBR stage. It's related to
what files need to be present in /boot (usually on /dev/ada0s1a,
if no specific separate boot partition has been created).
Post by Robert Fitzpatrick via freebsd-questions
I can see that menu.4th is not in the /boot directory. I do see the
below in my menu.rc, all of the files are present in /boot except the
menu.4th and menu-commands.4th. The only file in the /boot folder
starting with menu is the menu.rc.
\ Load required Forth modules
include /boot/version.4th
include /boot/brand.4th
include /boot/menu.4th
include /boot/menu-commands.4th
include /boot/shortcuts.4th
This indicates your /boot directory's content is damaged.
You proably need to reinstall its content from source, or
hope a freebsd-update will bring it back. The easiest way
to get the file probably is to copy it from the source
directory to /boot manually (directly from its location
in /usr/src).

See "man 8 menu.4th" for details.
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
Loading...