I have an HDD (or SSD, or flash drive) with FreeBSD installed on it, and somehow I broke the bootcode (first 446 bytes of MBR). How could I boot into this FreeBSD?
Freebsd – How to boot FreeBSD system with broken bootcode
bootfreebsdmbr
bootfreebsdmbr
I have an HDD (or SSD, or flash drive) with FreeBSD installed on it, and somehow I broke the bootcode (first 446 bytes of MBR). How could I boot into this FreeBSD?
Best Answer
Assuming that there is 512-byte DOS-like MBR, and you have replaced first 446 bytes of it with some crap (zeros or just
/dev/urandom
output), or damaged the bootcode some other way. In this case MBR partition table is on it's place, but system cannot boot from this device.Idea is to use other BSD-like system's loader to boot with your device and your kernel.
unload
disk0s1a
) by typinglsdev
set currdev="disk0s1a"
loder.conf
from your device (to be sure that all your kernel tunings and hacks would apply) by typingread-conf boot/loader.conf
boot-conf
When your OS starts, you could repair bootcode. I use
sysinstall
for it (Custom -> Partition, W,<Yes>
,BootMgr
("Install the FreeBSD Boot Manager"),<OK>
, Q,<Exit>
,<Exit Install>
), but it is deprecated since 9.0-RELEASE and removed from base since 10.0-RELEASE. Other way is to use backup, stored in/boot
, to extract bootcode from it: