A few stupid questions regarding MBR and boot0

Trond Endrestøl Trond.Endrestol at fagskolen.gjovik.no
Thu Apr 14 12:00:33 UTC 2016


On Thu, 14 Apr 2016 14:48+0300, Aleksander Alekseev wrote:

> Hello
> 
> I was trying to figure out how FreeBSD boot process works and noticed
> something strange.
> 
> 1) If I understand correctly first 512 bytes of /dev/ad0
> and /boot/boot0 file should match, but they don't:
> 
> http://afiskon.ru/s/31/665dc9755c_mbr.txt

The MBR consists of two parts, the bootcode and the partition table. 
Any discrepancies is generally due to the partition table being zero 
in /boot/boot0 and realistic data stored in block 0.

> Could someone please explain why they don't match?
> 
> 2) I tried to compile boot0 from source (r297956) but compilation
> failed:
> 
> ```
> $ cd sys/boot/i386/boot0
> $ make
> 
> Warning: Object directory not changed from
> original /usr/home/eax/freebsd-src/sys/boot/i386/boot0
> 
> /usr/local/bin/clang38 -O2 -pipe -O2 -pipe -g -march=native
> -DVOLUME_SERIAL -DPXE -DFLAGS=0x8f  -DTICKS=0xb6  -DCOMSPEED="7 << 5 +
> 3" -march=i386 -ffreestanding  -msoft-float -m32 -std=gnu99
> -Qunused-arguments -m32 -c boot0.S -o boot0.o clang -cc1as: fatal
> error: error in backend: invalid .org offset '430' (at offset '439')
> *** Error code 1
> 
> Stop.
> make: stopped in /usr/home/eax/freebsd-src/sys/boot/i386/boot0
> ```
> 
> Am I doing something wrong?

I have never attempted to build the FreeBSD sources outside /usr/src. 
The advice below might be plain wrong.

Try:

  cd sys/boot/i386/boot0
  make clean
  make OBJDIR=/usr/home/eax/freebsd-obj obj
  make OBJDIR=/usr/home/eax/freebsd-obj all

If you want it installed, run

  make OBJDIR=/usr/home/eax/freebsd-obj install

-- 
+-------------------------------+------------------------------------+
| Vennlig hilsen,               | Best regards,                      |
| Trond Endrestøl,              | Trond Endrestøl,                   |
| IT-ansvarlig,                 | System administrator,              |
| Fagskolen Innlandet,          | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,       | Cellular...: +47 952 62 567,       |
| sentralbord 61 14 54 00.      | Switchboard: +47 61 14 54 00.      |
+-------------------------------+------------------------------------+


More information about the freebsd-hackers mailing list