NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: playing with bootxx_ext2fs



Hello Greg.  Thank you for the extensive answer.

## Sectors 0 and 1

Would sector 0 simply correspond to what is called the Partition Boot Record? *

There are bits of disklabel onto sector 1 indeed.

## Sectors 2-13 and getting closer

The bootxx_ffsv2 and bootxx_ext2fs are both 6656 bytes (13 sectors) so one could assume the home for boot blocks is rather the same.  As an attempt to figure that out, I eventually filled-up an ext2 file-system with with random bytes and checked what space at the beginning happens to stay intact.  Not much happens until sector 434 and 436.  So I guess there's lots of room there for whatever purposes.

I found out why I had no magic.  It was because fsck.ext2 cleans-up sector 2 and above.  Its output is pretty self-explanatory as it also talks about "Bad magic".

# fsck.ext2 -y /dev/sda1
e2fsck 1.44.1 (24-Mar-2018)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
/dev/sda1 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes

So I finally tried the dirty way of `dd`ing bootxx_ext2fs right onto the partition but now without fscking.  The result is

NetBSD/x86 ext2fs Primary Bootstrap
Boot failed (errno  2): Can't open /boot

Reboot and Select proper Boot device
or Insert Boot Media in selected Boot device and press a key

It suggests the phase 1 boot strap code needs have a clue on its own device name.  Maybe it simply needs a disklabel.  I am stuck again, although I could try to dd/push a working disklabel over there.  I though I could avoid that, as the netbsd kernel seems to generate a soft-generated `e` partition.

## 63 vs 64 vs 2048

On NetBSD x86 we're still starting at 63.  In my previous attempt, I used the gnu/linux fdisk and cfdisk utilities with their modern defaults so the partition was starting at sector 2048.  While using `fdisk -c=dos` I could create a partition starting at 63 (the default was indeed 64).

I do not think this makes a big difference for my purpose of boot strapping netbsd.

## /boot supports ext2fs?

> I am unclear on which filesystems /boot can handle, other than
> ffs1/ffs2.  Surely that includes ext2fs and fat32, or we'd have
> /boot-foo for them and I'd have heard about it.

I would not be so certain.  As far as I've seen, bootxx_ext2fs is a pretty new thing and nothing tells the netbsd phase 2 boot strap can use it.  I do not know where to check tho.

## good news

> In a filesystem/partition, sectors 2-15 contain bootxx_foo.  These read
> the fs and find /boot.  On some systems (sparc?) they are patched with
> the sectors of /boot, but on x86 they read the fs and this isn't
> necessary.  /boot always reads the fs to find /netbsd.

This means on amd64 my problem and task is not about hard-coding the location of /boot.  

## hardware

I should have mentioned bare-metal IaaS or root-server only, not VPS.  This is a Supermicro SYS-5038MA-H24TRFG-ON002 and I reach its physical console through IPMI & Java.  NetBSD current dmesg here: http://tmp.nethence.com/dmesg/xc2015.txt (that dedibox dates 2015)

The _rescue_ environment I am trying to install NetBSD from -- is an Ubuntu Bionic.  I got all the tools I want including qemu-kvm which allowed me to install NetBSD as such.  But I am trying to find the best approach.  FreeBSD 11.1 is also available.

I have no issue with the MBR.  I have only issues with bootxx_ext2fs versus an mkfs.ext2.


* sys/arch/i386/stand/bootxx/pbr.S
sys/arch/i386/stand/bootxx/bootxx.S
https://wiki.netbsd.org/how_netbsd_boots_on_x86/
-- 
Pierre-Philipp Braun
SNE Russia https://os3.su/


Home | Main Index | Thread Index | Old Index