Remix.run Logo
csdvrx 4 days ago

You would have to add support for the peripherals in the kernel, and have some kind of init system. You would also need a filesystem supported to boot the computer.

I was doing something similar for the entire OS a few years ago: cosmopolinux, a distribution of cosmopolitan binaries: https://github.com/csdvrx/cosmopolinux

My idea was to replace the WSL binaries to have a Linux distribution living on C:\, but that could also be booted baremetal if you didn't want to use Windows

I had to put together a multi stage init system for that: if you get the ISO, you can put in on a thumbdrive and boot it: https://gitlab.com/csdvrx/cosmopolinux

The only difference between them is the kernel and the filesystem: the github NTFS has a firecracker linux kernel, the gitlab ISO has a regular kernel with many modules.

I wanted to do a full NTFS solution but I couldn't find a bootloader I liked that would support booting from a NTFS partition.

Booting from an ISO was simpler and faster.

yjftsjthsd-h 4 days ago | parent [-]

> I wanted to do a full NTFS solution but I couldn't find a bootloader I liked that would support booting from a NTFS partition.

Could you stick the Linux kernel and initramfs on the EFI boot partition as a UKI, and then just tell it about its rootfs being on the NTFS C drive? You don't really need any bootloader except the firmware's UEFI implementation on most modern PCs, and Linux supports NTFS.

csdvrx 4 days ago | parent [-]

> Could you stick the Linux kernel and initramfs on the EFI boot partition as a UKI

I considered that, even if it would go against the idea of having everything inside the Windows partition. I'd rather have had a shim in the EFI, with the UKI in C:\

The difficulty was bitlocker: my approach was a UKI with a small kernel and a few binaries to open the bitlocker volume and kexec the bigger kernel.

I was also exploring how to mark part of the NTFS volume as unusable to stick a different payload there.

The "ISO on a thumbdrive" was done to get baremetal boot working and out of the way, to see if I needed deeper changes to what had started as a 2 stages boot process, or if it was good enough as-as.

> Linux supports NTFS.

The kernel module is great!

I wish there was a linux distribution that could be run from either WSL or baremetal, to get more people familiar with baremetal linux.

yjftsjthsd-h 4 days ago | parent [-]

> The difficulty was bitlocker: my approach was a UKI with a small kernel and a few binaries to open the bitlocker volume and kexec the bigger kernel.

Why not do that from the initramfs with the real kernel? I'm pretty sure that's how it works on a normal encrypted root Linux install

csdvrx 4 days ago | parent [-]

I wanted to limit the space needed on the EFI, and keep as much as possible on the Windows partition because there's also the question of where the bitlocker key would go.

With something like a chainloader using a special part of the NTFS partition posing as bad blocks, Windows could "remove" this access easily, without having to touch the EFI partition or the boot variables.