mkdir challenge
cd challenge
mkdir root
mkdir root/proc
mkdir root/sys
mkdir root/dev
mkdir root/bin
git clone --depth 1 https://github.com/richfelker/musl-cross-make
cd musl-cross-make
make TARGET=i686-linux-musl -j8
sudo make install
cd ..
export PATH=$PATH:/home/maplecircuit/challenge/musl-cross-make/output/bin/
git clone --depth 1 https://git.busybox.net/busybox/
cd busybox
make menuconfig
CROSS_COMPILE=i686-linux-musl- make CONFIG_PREFIX=../root install
git clone --depth 1 https://github.com/landley/toybox
cd toybox
LDFLAGS="--static" CROSS_COMPILE=i686-linux-musl- make defconfig toybox
PREFIX=/home/maplecircuit/challenge/root/bin make install_flat
cd ..
wget https://git.kernel.org/pub/scm/utils/dash/dash.git/snapshot/dash-0.5.12.tar.gz
tar -xf dash-0.5.12.tar.gz
cd dash-0.5.12
bash autogen.sh
CC=i686-linux-musl-gcc ./configure --enable-static --host x86_64 --prefix=/
make -j8
make DESTDIR=/home/maplecircuit/challenge/root install
cd ..
rm -R root/share
ln -s dash root/bin/sh
cd root/bin
nano init
init:
#!/bin/dash
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/dash
chmod +x init
cd ..
find . -print0 | cpio --null -ov --format=newc > initramfs.cpio
xz --check=crc32 ./initramfs.cpio
mv initramfs.cpio.xz ..
cd ..
git clone --depth 1 https://github.com/torvalds/linux
mv initramfs.cpio.xz linux/
cd linux
make tinyconfig
make menuconfig
General setup ---> Initial RAM filesystem and RAM disk (initramfs/initrd) support ---> yes
General setup ---> [*] Support initial ramdisk/ramfs compressed using XZ
General setup ---> (initramfs.cpio.xz) Initramfs source file(s)
General setup ---> Configure standard kernel features ---> Enable support for printk ---> yes
Processor type and features ---> x86-32 Processor family (Pentium-II/Celeron(pre-Coppermine)) --->
Executable file formats / Emulations ---> Kernel support for ELF binaries ---> yes
Executable file formats / Emulations ---> Kernel support for scripts starting with #! ---> yes
Device Drivers ---> Generic Driver Options ---> Maintain a devtmpfs filesystem to mount at /dev ---> yes
Device Drivers ---> Generic Driver Options ---> Automount devtmpfs at /dev, after the kernel mounted the rootfs ---> yes
Device Drivers ---> Character devices ---> Enable TTY ---> yes
Device Drivers ---> Character devices ---> Serial drivers ---> 8250/16550 and compatible serial support ---> yes
Device Drivers ---> Character devices ---> Serial drivers ---> Console on 8250/16550 and compatible serial port ---> yes
File systems ---> Pseudo filesystems ---> /proc file system support ---> yes
File systems ---> Pseudo filesystems ---> sysfs file system support ---> yes
make -j8 fdimage
#make -j8 isoimage
****burn to floppy (didn't happen because too big)****
#sudo dd if=arch/x86/boot/fdimage of=/dev/sdc bs=512
make menuconfig
make -j8
mv arch/x86/boot/bzImage ../
cd ..
sudo pacman -S nasm
yay -S ufiformat
sudo modprobe sg
sudo ufiformat /dev/sdc
git clone --depth 1 https://github.com/oerg866/w98qi-tiny-floppy-bootloader
cd w98qi-tiny-floppy-bootloader
./build.sh ../bzImage disk.img 1474560
qemu-system-x86_64 -fda disk.img
sudo dd if=disk.img of=/dev/sdc bs=512 conv=noerror
so, the problem i'm having is either the initramfs is not being loaded (only meaningful change being that it is included inside the kernel) or something the dash and the other commands need is not present when the initramfs is not external.
Turns out i had multiple errors,
New init
#!/bin/dash
/bin/mount -t devtmpfs devtmpfs /dev
exec 0/dev/console
exec 2>/dev/console
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/dash
new initramfs
find . -print0 | cpio --null -ov --format=newc > ../initramfs.cpio
Turns out the 2 sector bootloader doesn't work....
lets get a new one
git clone --depth 1 https://github.com/snacsnoc/tiny-floppy-bootloader