THIS IS A DRAFT – FAIL: bootxx_ext2fs gets wiped out by gnu/linux fsck.ext2
tested on scaleway dedibox with bionic as a rescue system
export LANG=C export LC_MESSAGES=C alias ll='ls -alhF' apt update apt install -y man-db manpages mlocate binutils
freaking ubuntu — it mounts the swap space if it finds one
swapon -s swapoff -a
and proceed
source=http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-8.0/amd64/ #source=http://ftp.fr.netbsd.org/pub/NetBSD-daily/netbsd-8/201903100010Z/amd64 wget $source/binary/kernel/netbsd-GENERIC.gz wget $source/binary/kernel/netbsd-INSTALL.gz zcat netbsd-INSTALL.gz > netbsd wget $source/binary/sets/base.tgz #wget $source/binary/sets/base.tar.xz mkdir base/ tar xzphf base.tgz -C base/ #tar xJphf base.tar.xz -C base/ ls -lF base/usr/mdec/mbr ls -lF base/usr/mdec/bootxx_ext2fs ls -lF base/usr/mdec/boot
watch for possible errors
strings base/usr/mdec/mbr strings base/usr/mdec/bootxx_ext2fs strings base/usr/mdec/boot
start clean
mount | grep sda #umount /mnt/dev/ #umount /mnt/ #dd if=/dev/zero of=/dev/sda bs=1M count=1
THIS WILL ERASE THE PARTITION TABLE AS WELL (512 bytes)
dd if=base/usr/mdec/mbr | hexdump -vC dd if=base/usr/mdec/mbr of=/dev/sda #dd if=base/usr/mdec/mbr of=/dev/sda bs=1 count=440
note - netbsd mbr wants a9
not sure we really need to force sector 63
#fdisk -c=dos -u /dev/sda #o #n p 1 63 +25G #t a9 #a cfdisk /dev/sda 25G a9 BOOTABLE
build the filesystem without -r 0
as largefiles is available now
mkfs.ext2 -O^dir_index /dev/sda1 tune2fs -l /dev/sda1 | grep features:
gives
ext_attr resize_inode dir_index filetype sparse_super large_file
mount /dev/sda1 /mnt cp base/usr/mdec/boot /mnt/ cp netbsd-GENERIC.gz netbsd-INSTALL.gz netbsd /mnt/ umount /mnt
everything is almost zeroes so far in sectors 0,1,2-11
dd if=/dev/sda1 count=13 skip=0 | hexdump -C | less
backup the first sectors of the partition
dd if=/dev/sda1 of=sda1.13sec.bkp count=13 ls -lF sda1.13sec.bkp # 6656 bytes
WRITE
dd if=base/usr/mdec/bootxx_ext2fs of=/dev/sda1 #DO NOT #fsck.ext2 -y /dev/sda1 #ext2fs_open2: Bad magic number in super-block #fsck.ext2: Superblock invalid, trying backup blocks...
check and compare against the 13 blocks long pbr+bootxx
dd if=/dev/sda1 count=1 skip=0 | hexdump -vC dd if=/dev/sda1 count=1 skip=1 | hexdump -vC dd if=/dev/sda1 count=11 skip=2 | hexdump -vC | less dd if=base/usr/mdec/bootxx_ext2fs count=1 skip=0 | hexdump -vC dd if=base/usr/mdec/bootxx_ext2fs count=1 skip=1 | hexdump -vC dd if=base/usr/mdec/bootxx_ext2fs count=11 skip=2 | hexdump -vC | less
FOUND PROBLEM – that part has been wiped by fsck.ext2
#hexdump -vC base/usr/mdec/bootxx_ext2fs | less #dd if=/dev/sda1 count=13 | hexdump -vC | less mount /dev/sda1 /mnt diff base/usr/mdec/boot /mnt/boot diff netbsd-GENERIC.gz /mnt/netbsd-GENERIC.gz diff netbsd.gz /mnt/netbsd.gz diff MD5 /mnt/MD5 diff netbsd /mnt/netbsd umount /mnt
FAIL – got this (no boot prompt)
NetBSD MBR boot Error no magic
==> this string is from base/usr/mdec/bootxx_ext2fs
meaning that we cannot reach the secondary bootstrap
cd ~/ sync mount | grep sda umount /mnt/dev umount /mnt
and finally switch the dedibox to normal mode
NetBSD MBR boot Error no slice
==> needs a9/netbsd DOS partition, not 83/linux
Chapter 2. Installing NetBSD: Preliminary considerations and preparations https://www.netbsd.org/docs/guide/en/chap-inst.html
how netbsd boots on x86 https://wiki.netbsd.org/how_netbsd_boots_on_x86/
https://linux.die.net/man/1/hexdump
http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/installboot/
mbr, bootselect Master Boot Record bootcode http://netbsd.gw.com/cgi-bin/man-cgi?mbr+8
boot system bootstrapping procedures http://netbsd.gw.com/cgi-bin/man-cgi?boot+8
boothowto, BOOT_FLAG flags passed to kernel during boot or shutdown http://netbsd.gw.com/cgi-bin/man-cgi?boothowto+9
options Miscellaneous kernel configuration options http://netbsd.gw.com/cgi-bin/man-cgi?options+4
userconf in-kernel device configuration manager http://netbsd.gw.com/cgi-bin/man-cgi?userconf+4
installboot install disk bootstrap software http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8
NOT NEEDED boot.cfg configuration file for /boot http://netbsd.gw.com/cgi-bin/man-cgi?boot.cfg+5