OS-1337 / OS1337

OS/1337 Project
https://os1337.com
Other
19 stars 2 forks source link

Boot issues - hanging after loading Kernel [bzimage] and initramfs [rootfs.cpio.xz]... #2

Closed kkarhan closed 10 months ago

kkarhan commented 10 months ago

As of now, OS/1337 doesn't boot - it just hangs after the 342785ed8ec1833e

I've gotten some cals for help out and some replies were quite helpful, including a different .config for the Kernel...

This needs further examination and triage

kkarhan commented 10 months ago

Building a minimalist Linux Kernel as per Floppinux manual at least spit out some error messages... https://github.com/OS-1337/OS1337/commit/eb69dd3c9ef9af854daaf3062a1b65dbd190e32e Bildschirmfoto vom 2023-12-03 23-45-37

kkarhan commented 10 months ago

I recorded the whole boot process in VirtualBox 7.0 setting the max CPU utilization to 1% [ which should translate to 46 MHz on my overclocked i7-6700K @ 4,6GHz]:

OS1337-screen0.webm

I guess I did feck up the .config for said Linux Kernel re: xz compression and initramfs settings... Should be quick to fix...

kkarhan commented 10 months ago

Progress is being made with the latest commit and whilst the current image version does not yet fully boot, it's now hanging at the init process... Bildschirmfoto vom 2023-12-04 00-32-14

Two Options to fix it:

  1. Set Kernel parameter to find /etc/init.d/rc
  2. rename and move it to /etc/init

This should - in theory - run the minimalist toybox executeable and it's build-in bash-style shell just fine.

kkarhan commented 10 months ago

Personally I prefer to use #2 as "Configuration by Exception" will prevent me from getting a Tom Scott "Future Me" issue down the line... 1693ebf3835299160b78a95389e983de

kkarhan commented 10 months ago

Issue still persisting as of current version of the image...

Will need to find out why it still dislikes the /etc/init file...

kkarhan commented 10 months ago

Taking a look at mkroot for i486's structure shows a fully-fledged Toybox/Linux with a huge Kernel

-rw-r--r-- 1 user user 471K Jul 30 21:39 initramfs.cpio.gz
-rw-r--r-- 1 user user 2,7M Jul 30 14:46 linux-kernel

and a huge number of symlinks to toybox:

.
├── docs
│   ├── linux-fullconfig
│   ├── linux-microconfig
│   ├── linux-miniconfig
│   └── README
├── initramfs
│   └── initramfs
│       ├── bin -> usr/bin
│       ├── dev
│       ├── etc
│       │   ├── group
│       │   ├── passwd
│       │   ├── rc
│       │   └── resolv.conf
│       ├── home
│       ├── init
│       ├── lib -> usr/lib
│       ├── mnt
│       ├── proc
│       ├── root
│       ├── run -> tmp/run
│       ├── sbin -> usr/sbin
│       ├── sys
│       ├── tmp
│       │   └── run
│       ├── usr
│       │   ├── bin
│       │   │   ├── [ -> toybox
│       │   │   ├── acpi -> ../../bin/toybox
│       │   │   ├── arch -> ../../bin/toybox
│       │   │   ├── ascii -> ../../bin/toybox
│       │   │   ├── base32 -> ../../bin/toybox
│       │   │   ├── base64 -> ../../bin/toybox
│       │   │   ├── basename -> ../../bin/toybox
│       │   │   ├── bash -> toybox
│       │   │   ├── blkdiscard -> toybox
│       │   │   ├── blkid -> toybox
│       │   │   ├── bunzip2 -> ../../bin/toybox
│       │   │   ├── bzcat -> ../../bin/toybox
│       │   │   ├── cal -> ../../bin/toybox
│       │   │   ├── cat -> toybox
│       │   │   ├── chattr -> toybox
│       │   │   ├── chgrp -> toybox
│       │   │   ├── chmod -> toybox
│       │   │   ├── chown -> toybox
│       │   │   ├── chrt -> ../../bin/toybox
│       │   │   ├── chvt -> ../../bin/toybox
│       │   │   ├── cksum -> toybox
│       │   │   ├── clear -> ../../bin/toybox
│       │   │   ├── cmp -> ../../bin/toybox
│       │   │   ├── comm -> ../../bin/toybox
│       │   │   ├── count -> ../../bin/toybox
│       │   │   ├── cp -> toybox
│       │   │   ├── cpio -> toybox
│       │   │   ├── crc32 -> toybox
│       │   │   ├── cut -> ../../bin/toybox
│       │   │   ├── date -> toybox
│       │   │   ├── dd -> ../../bin/toybox
│       │   │   ├── deallocvt -> ../../bin/toybox
│       │   │   ├── df -> toybox
│       │   │   ├── dirname -> ../../bin/toybox
│       │   │   ├── dmesg -> toybox
│       │   │   ├── dnsdomainname -> toybox
│       │   │   ├── dos2unix -> toybox
│       │   │   ├── du -> ../../bin/toybox
│       │   │   ├── echo -> toybox
│       │   │   ├── egrep -> toybox
│       │   │   ├── eject -> ../../bin/toybox
│       │   │   ├── env -> ../../bin/toybox
│       │   │   ├── expand -> ../../bin/toybox
│       │   │   ├── factor -> ../../bin/toybox
│       │   │   ├── fallocate -> ../../bin/toybox
│       │   │   ├── false -> toybox
│       │   │   ├── fgrep -> toybox
│       │   │   ├── file -> ../../bin/toybox
│       │   │   ├── find -> ../../bin/toybox
│       │   │   ├── flock -> ../../bin/toybox
│       │   │   ├── fmt -> ../../bin/toybox
│       │   │   ├── free -> ../../bin/toybox
│       │   │   ├── fstype -> toybox
│       │   │   ├── fsync -> toybox
│       │   │   ├── ftpget -> ../../bin/toybox
│       │   │   ├── ftpput -> ../../bin/toybox
│       │   │   ├── getconf -> ../../bin/toybox
│       │   │   ├── gpiodetect -> ../../bin/toybox
│       │   │   ├── gpiofind -> ../../bin/toybox
│       │   │   ├── gpioget -> ../../bin/toybox
│       │   │   ├── gpioinfo -> ../../bin/toybox
│       │   │   ├── gpioset -> ../../bin/toybox
│       │   │   ├── grep -> toybox
│       │   │   ├── groups -> ../../bin/toybox
│       │   │   ├── gunzip -> ../../bin/toybox
│       │   │   ├── head -> ../../bin/toybox
│       │   │   ├── help -> toybox
│       │   │   ├── hexedit -> ../../bin/toybox
│       │   │   ├── host -> ../../bin/toybox
│       │   │   ├── hostname -> toybox
│       │   │   ├── httpd -> ../../bin/toybox
│       │   │   ├── iconv -> ../../bin/toybox
│       │   │   ├── id -> ../../bin/toybox
│       │   │   ├── inotifyd -> ../../bin/toybox
│       │   │   ├── install -> ../../bin/toybox
│       │   │   ├── ionice -> ../../bin/toybox
│       │   │   ├── iorenice -> ../../bin/toybox
│       │   │   ├── iotop -> ../../bin/toybox
│       │   │   ├── kill -> toybox
│       │   │   ├── killall -> ../../bin/toybox
│       │   │   ├── link -> ../../bin/toybox
│       │   │   ├── linux32 -> ../../bin/toybox
│       │   │   ├── ln -> toybox
│       │   │   ├── logger -> ../../bin/toybox
│       │   │   ├── login -> toybox
│       │   │   ├── logname -> ../../bin/toybox
│       │   │   ├── ls -> toybox
│       │   │   ├── lsattr -> toybox
│       │   │   ├── lspci -> ../../bin/toybox
│       │   │   ├── lsusb -> ../../bin/toybox
│       │   │   ├── makedevs -> ../../bin/toybox
│       │   │   ├── mcookie -> ../../bin/toybox
│       │   │   ├── md5sum -> ../../bin/toybox
│       │   │   ├── microcom -> ../../bin/toybox
│       │   │   ├── mix -> ../../bin/toybox
│       │   │   ├── mkdir -> toybox
│       │   │   ├── mkfifo -> ../../bin/toybox
│       │   │   ├── mknod -> toybox
│       │   │   ├── mkpasswd -> ../../bin/toybox
│       │   │   ├── mktemp -> toybox
│       │   │   ├── mount -> toybox
│       │   │   ├── mountpoint -> toybox
│       │   │   ├── mv -> toybox
│       │   │   ├── nbd-client -> ../../bin/toybox
│       │   │   ├── nbd-server -> ../../bin/toybox
│       │   │   ├── nc -> ../../bin/toybox
│       │   │   ├── netcat -> toybox
│       │   │   ├── netstat -> toybox
│       │   │   ├── nice -> toybox
│       │   │   ├── nl -> ../../bin/toybox
│       │   │   ├── nohup -> ../../bin/toybox
│       │   │   ├── nproc -> ../../bin/toybox
│       │   │   ├── nsenter -> ../../bin/toybox
│       │   │   ├── od -> ../../bin/toybox
│       │   │   ├── openvt -> toybox
│       │   │   ├── passwd -> ../../bin/toybox
│       │   │   ├── paste -> ../../bin/toybox
│       │   │   ├── patch -> ../../bin/toybox
│       │   │   ├── pgrep -> ../../bin/toybox
│       │   │   ├── pidof -> toybox
│       │   │   ├── ping -> ../../bin/toybox
│       │   │   ├── ping6 -> ../../bin/toybox
│       │   │   ├── pkill -> ../../bin/toybox
│       │   │   ├── pmap -> ../../bin/toybox
│       │   │   ├── printenv -> toybox
│       │   │   ├── printf -> ../../bin/toybox
│       │   │   ├── prlimit -> ../../bin/toybox
│       │   │   ├── ps -> toybox
│       │   │   ├── pwd -> toybox
│       │   │   ├── pwdx -> ../../bin/toybox
│       │   │   ├── pwgen -> ../../bin/toybox
│       │   │   ├── readahead -> toybox
│       │   │   ├── readelf -> ../../bin/toybox
│       │   │   ├── readlink -> ../../bin/toybox
│       │   │   ├── realpath -> ../../bin/toybox
│       │   │   ├── renice -> ../../bin/toybox
│       │   │   ├── reset -> ../../bin/toybox
│       │   │   ├── rev -> ../../bin/toybox
│       │   │   ├── rm -> toybox
│       │   │   ├── rmdir -> toybox
│       │   │   ├── rtcwake -> ../../bin/toybox
│       │   │   ├── sed -> toybox
│       │   │   ├── seq -> ../../bin/toybox
│       │   │   ├── setfattr -> ../../bin/toybox
│       │   │   ├── setsid -> ../../bin/toybox
│       │   │   ├── sh -> toybox
│       │   │   ├── sha1sum -> ../../bin/toybox
│       │   │   ├── sha224sum -> ../../bin/toybox
│       │   │   ├── sha256sum -> ../../bin/toybox
│       │   │   ├── sha384sum -> ../../bin/toybox
│       │   │   ├── sha3sum -> ../../bin/toybox
│       │   │   ├── sha512sum -> ../../bin/toybox
│       │   │   ├── shred -> ../../bin/toybox
│       │   │   ├── shuf -> ../../bin/toybox
│       │   │   ├── sleep -> toybox
│       │   │   ├── sntp -> ../../bin/toybox
│       │   │   ├── sort -> ../../bin/toybox
│       │   │   ├── split -> ../../bin/toybox
│       │   │   ├── stat -> toybox
│       │   │   ├── strings -> ../../bin/toybox
│       │   │   ├── su -> toybox
│       │   │   ├── sync -> toybox
│       │   │   ├── tac -> ../../bin/toybox
│       │   │   ├── tail -> ../../bin/toybox
│       │   │   ├── tar -> ../../bin/toybox
│       │   │   ├── taskset -> ../../bin/toybox
│       │   │   ├── tee -> ../../bin/toybox
│       │   │   ├── test -> ../../bin/toybox
│       │   │   ├── time -> ../../bin/toybox
│       │   │   ├── timeout -> ../../bin/toybox
│       │   │   ├── top -> ../../bin/toybox
│       │   │   ├── touch -> toybox
│       │   │   ├── toybox
│       │   │   ├── toysh -> toybox
│       │   │   ├── true -> toybox
│       │   │   ├── truncate -> ../../bin/toybox
│       │   │   ├── tty -> ../../bin/toybox
│       │   │   ├── tunctl -> ../../bin/toybox
│       │   │   ├── uclampset -> ../../bin/toybox
│       │   │   ├── ulimit -> ../../bin/toybox
│       │   │   ├── umount -> toybox
│       │   │   ├── uname -> toybox
│       │   │   ├── unicode -> ../../bin/toybox
│       │   │   ├── uniq -> ../../bin/toybox
│       │   │   ├── unix2dos -> toybox
│       │   │   ├── unlink -> ../../bin/toybox
│       │   │   ├── unshare -> ../../bin/toybox
│       │   │   ├── uptime -> ../../bin/toybox
│       │   │   ├── usleep -> toybox
│       │   │   ├── uudecode -> ../../bin/toybox
│       │   │   ├── uuencode -> ../../bin/toybox
│       │   │   ├── uuidgen -> ../../bin/toybox
│       │   │   ├── vmstat -> toybox
│       │   │   ├── w -> ../../bin/toybox
│       │   │   ├── watch -> ../../bin/toybox
│       │   │   ├── wc -> ../../bin/toybox
│       │   │   ├── wget -> ../../bin/toybox
│       │   │   ├── which -> ../../bin/toybox
│       │   │   ├── who -> ../../bin/toybox
│       │   │   ├── whoami -> ../../bin/toybox
│       │   │   ├── xargs -> ../../bin/toybox
│       │   │   ├── xxd -> ../../bin/toybox
│       │   │   ├── yes -> ../../bin/toybox
│       │   │   └── zcat -> ../../bin/toybox
│       │   ├── lib
│       │   └── sbin
│       │       ├── blockdev -> ../bin/toybox
│       │       ├── chroot -> ../../bin/toybox
│       │       ├── devmem -> ../../bin/toybox
│       │       ├── freeramdisk -> ../bin/toybox
│       │       ├── fsfreeze -> ../../bin/toybox
│       │       ├── halt -> ../bin/toybox
│       │       ├── hwclock -> ../bin/toybox
│       │       ├── i2cdetect -> ../../bin/toybox
│       │       ├── i2cdump -> ../../bin/toybox
│       │       ├── i2cget -> ../../bin/toybox
│       │       ├── i2cset -> ../../bin/toybox
│       │       ├── i2ctransfer -> ../../bin/toybox
│       │       ├── ifconfig -> ../bin/toybox
│       │       ├── insmod -> ../bin/toybox
│       │       ├── killall5 -> ../bin/toybox
│       │       ├── losetup -> ../bin/toybox
│       │       ├── lsmod -> ../bin/toybox
│       │       ├── mkswap -> ../bin/toybox
│       │       ├── modinfo -> ../bin/toybox
│       │       ├── oneit -> ../bin/toybox
│       │       ├── partprobe -> ../bin/toybox
│       │       ├── pivot_root -> ../bin/toybox
│       │       ├── poweroff -> ../bin/toybox
│       │       ├── reboot -> ../bin/toybox
│       │       ├── rfkill -> ../../bin/toybox
│       │       ├── rmmod -> ../bin/toybox
│       │       ├── route -> ../bin/toybox
│       │       ├── swapoff -> ../bin/toybox
│       │       ├── swapon -> ../bin/toybox
│       │       ├── switch_root -> ../bin/toybox
│       │       ├── sysctl -> ../bin/toybox
│       │       ├── vconfig -> ../bin/toybox
│       │       └── watchdog -> ../bin/toybox
│       └── var
├── initramfs.cpio.gz
├── linux-kernel
└── run-qemu.sh
kkarhan commented 10 months ago

My best guess is that [mkroot] spawns a fully-fledged toybox+musl/linux and thus also sets a lot of variables not necessary for a minimalist system.

#!/bin/sh

export HOME=/home PATH=/bin:/sbin

if ! mountpoint -q dev; then
  mount -t devtmpfs dev dev
  [ $$ -eq 1 ] && ! 2>/dev/null <0 && exec 0<>/dev/console 1>&0 2>&1
  for i in ,fd /0,stdin /1,stdout /2,stderr
  do ln -sf /proc/self/fd${i/,*/} dev/${i/*,/}; done
  mkdir -p dev/shm
  chmod +t /dev/shm
fi
mountpoint -q dev/pts || { mkdir -p dev/pts && mount -t devpts dev/pts dev/pts;}
mountpoint -q proc || mount -t proc proc proc
mountpoint -q sys || mount -t sysfs sys sys
echo 0 99999 > /proc/sys/net/ipv4/ping_group_range

if [ $$ -eq 1 ]; then # Setup networking for QEMU (needs /proc)
  mountpoint -q mnt || [ -e /dev/?da ] && mount /dev/?da /mnt
  ifconfig lo 127.0.0.1
  ifconfig eth0 10.0.2.15
  route add default gw 10.0.2.2
  [ "$(date +%s)" -lt 1000 ] && timeout 2 sntp -sq 10.0.2.2 # Ask host
  [ "$(date +%s)" -lt 10000000 ] && sntp -sq time.google.com

  # Run package scripts (if any)
  for i in $(ls -1 /etc/rc 2>/dev/null | sort); do . /etc/rc/"$i"; done

  [ -z "$HANDOFF" ] && [ -e /mnt/init ] && HANDOFF=/mnt/init
  [ -z "$HANDOFF" ] && HANDOFF=/bin/sh && echo -e '\e[?7hType exit when done.'
  echo 3 > /proc/sys/kernel/printk
  exec oneit $HANDOFF
else # for chroot
  /bin/sh
  umount /dev/pts /dev /sys /proc
fi

After all it also configures networking for qemu specifically

kkarhan commented 10 months ago

Thx to @sweetaibelle for hinting that I overlooked at the persisting issue of the failing decompression...

Bildschirmfoto vom 2023-12-04 04-09-21

kkarhan commented 10 months ago

Apparently @sweetaibelle found a fix for my botched rootfs.cpio.xz and I found the culprit in the init file:

Otherwise toybox otherwise just vomits out it's main message to tell which commands are implemented.

kkarhan commented 10 months ago

@sweetaibelle in theory this commit should fix it to the point the very bare-bones OS/1337 prerelease will boot through cleanly.

I've to update & rebuild the rootfs.cpio.xz to include those fixes but that should've done that issue...

kkarhan commented 10 months ago

The boot issue have been solved. Bildschirmfoto vom 2023-12-04 22-25-00

OS_1337-screen0.webm

Autocompletes and so forth are still broken but it does boot and at least can cat welcome.txt and from here on out this should get much smoother...

@sweetaibelle your hint fixed it.

kkarhan commented 10 months ago

Working image is at: https://github.com/OS-1337/OS1337/blob/966753e739878e281fb1a2bb5dc250aae753cc9e/build/0.CORE/os1337.img