Struggling with minix 3 booting / installation, MBR and PBR source code

278 views
Skip to first unread message

rodoforer06

unread,
Apr 22, 2018, 7:08:44 AM4/22/18
to minix3
Hi to everybody, I am trying to install minix 3 in a dual core pentium 4 pc, with a SATA hd drive for several weeks. At moment I am diving in mbr, pbr and  bootxx_minix3fs source code.

MBR loads the primary booting code bootxx_minixfs3 and this in turn loads boot_monitor to load the minix 3 kernel and modules.
bootxx_minixfs3 writes pbr.S code into sector 0 of minix 3 paritition, and bootxx.S code into sector 2+.

I saw that MBR correctly loads PBR and this in turn load bootxx.S code. The problem I am stuck in is that bootxx.S overwrite minix3 fs superblock (particularly when  loads boot_params.S).

I think it could be a bad partitioning scheme on my part, maybe subpartitioning.

I know it is a highly specific question, so I appreciate any ideas, specially any document about minix 3 partitioning and / or any more direct instructions.

Best regards Minixers
Rodrigo, from Mexico

Jean-Baptiste Boric

unread,
Apr 23, 2018, 3:36:14 AM4/23/18
to minix3
Hi,

Check that you're partitioning with a gap between the MBR and your first partition. Modern advise is to align every partition on a 1 MiB boundary, that leaves plenty of space for the bootloader to stash itself into. Failing that, you can try using GRUB if you're installing a multiboot-capable MINIX3.

rodoforer06

unread,
Apr 23, 2018, 7:31:54 AM4/23/18
to minix3
First partition starts in sector 2048 (with 512 byte / sector) so is already aligned with a 1Mib boundary. That don't appear to be the problem, as debugging has shown that pbr.S code was loaded correctly.

The problem is that superblock (originally written by linux's mkfs.minix) is overwritten by the primary bootxx_minixfs3).

So the question is can minix boot from a primary partition? or should be subpartitions?.

Best.
R.

-------------------

Jean-Baptiste Boric

unread,
Apr 25, 2018, 1:51:17 PM4/25/18
to minix3

So the question is can minix boot from a primary partition? or should be subpartitions?.

The x86_hdimage.sh script generates a working HDD image with MINIX3 installed on three primary partitions. Subpartitions are just partitions that are themselves MBR partitioned.

Are you using the setup script, or are you doing the installation by hand? bootxx_minixfs3 overwriting the superblock suggests to me you are either trying to install MINIX3 directly on the hard drive and not inside a partition, or (more likely) you are trying to install the bootloader inside the MINIX3 partition and not directly on the hard drive.

rodoforer06

unread,
Apr 25, 2018, 7:50:07 PM4/25/18
to minix3
I tried to cross-compile minix in a ubuntu 16.04 box. It failed, so I dowload a minix iso image, and it too failed to boot the target computer.

So I started to dive into the code.

1. Minix' mbr was copied into sector 0 of an 3Gb hdd (sda)
2. Using linux fdisk a primary partition (2Gb) was made starting at sector 2048 (sda1).
3. Bootxx_minix3fs was cross-compiled and installed starting in sector 0 of partition using nbinstallboot. Several markers were used to keep track of progress. They shown that mbr sucessfully loaded primary and that it failed to load superblock at sector 2 of sda1 partition (otherwise overwritten by primary.

What is wrong in this layout?. I am sure I am missing something very basic.

Regards.
Rodrigo

Jean-Baptiste Boric

unread,
Apr 26, 2018, 5:59:31 PM4/26/18
to minix3

I tried to cross-compile minix in a ubuntu 16.04 box. It failed, so I dowload a minix iso image, and it too failed to boot the target computer.

If you want to cross-compile MINIX3, I recommend a Debian Jessie LXC (or chroot) container (https://github.com/Stichting-MINIX-Research-Foundation/minix/issues/229).

3. Bootxx_minix3fs was cross-compiled and installed starting in sector 0 of partition using nbinstallboot. Several markers were used to keep track of progress. They shown that mbr sucessfully loaded primary and that it failed to load superblock at sector 2 of sda1 partition (otherwise overwritten by primary.

What is wrong in this layout?. I am sure I am missing something very basic.


Looking at the setup script and at x86_hdimage.sh, installboot must be used on the raw disk itself and not inside a partition. The bootloader will be installed on the MBR and inside the beginning of the unpartitioned space between the first sector and the first partition. Trying to install it inside a partition will nuke its superblock. It's like installing GRUB for a BIOS system on a MBR-partitioned disk.

I'll admit I haven't touched MINIX3 for quite some time now, but hopefully I got it right.

rodoforer06

unread,
May 7, 2018, 9:47:51 AM5/7/18
to minix3
Thanks a lot Jean-Baptiste Boric, I used x86_hdimage.sh to make an image, finally I was able to boot minix!. Surprisingly to me, primary was written directly over mbr.

Antoine Leca

unread,
May 11, 2018, 11:02:34 AM5/11/18
to min...@googlegroups.com
Hi,
Sorry for the delay, I was not paying attention to the group :-(

On 2018-04-22 04:08:44 -0700 (PDT) rodoforer06 wrote:
> MBR loads the primary booting code bootxx_minixfs3 and this in turn loads
> boot_monitor to load the minix 3 kernel and modules.
> bootxx_minixfs3 writes pbr.S code into sector 0 of minix 3 paritition, and
> bootxx.S code into sector 2+.

Yes. All of this derives from NetBSD way of organizing things; in
particular, 4BSD/OS organization has the first 16 sectors reserved to boot
area, and the superblock is located further away.
Minix since its beginning had a different setup, the same as original V7,
where the superblock is at address 1K inside the file system area;
it means the boot area is limited to 1K, which is usually too small.

> I saw that MBR correctly loads PBR and this in turn load bootxx.S code. The
> problem I am stuck in is that bootxx.S overwrite minix3 fs superblock
> (particularly when loads boot_params.S).

It should not. PBR is a the start of the partition. Minix3 file systems are
installed in "subpartitions" (which is a specific MINIX concept) which are
*offset* with respect to PBR.
There is a (lowly documented) trick in Minix since 3.2, where the file system
in subpartition 0 (or a) should be located 32 sectors inside, for the code
in bootxx_minix3 to automatically find that super block (at sector 34.)

If you partition yourself, you should make sure that the root file system is
at the expected place, or it won't boot.


Antoine
Reply all
Reply to author
Forward
0 new messages