Hacker News new | past | comments | ask | show | jobs | submit login
Boot legacy PCs from NVMe storage (github.com/manawyrm)
117 points by wmlive 11 months ago | hide | past | favorite | 31 comments



This is a really interesting approach, as embedding into an option ROM means you could potentially flash it into a modded BIOS.

My preferred method to boot NVMe on a legacy system though is to boot tianocore UEFI with an NVME module in it[1]. This is a UEFI firmware that you can chainload from a legacy bios. Extremely good compatibility this way, and a great option for any system with an unused usb header.

1: https://winraid.level1techs.com/t/guide-nvme-boot-for-system...


> you could potentially flash it into a modded BIOS

Indeed you can [0]. I have a Supermicro X9DRi-LN4F+ booting from an NVMe drive in a PCIe adapter, works great.

[0]: https://winraid.level1techs.com/t/howto-get-full-nvme-suppor...


I knew that you could boot an "EFI bios" from experience with rEFIt from my time as a Mac Admin, so when I got my rEFInd USB drive working with a NVME drive on a pci-e adapter I was ecstatic until a month later when the USB drive failed and I forgot everything I had done.

Make backups of that USB drive or yeah it would be super cool if you could leverage the bios chip on a motherboard.


Yeah, I have one of the rare old laptops (HP ZBook G2) that has a PCIe M.2 slot for storage drives, but no support for NVMe booting.

This means that the only M.2 drives it’ll boot from are non-NVMe PCIe drives, which were actually made as an HP OEM part (Z Turbo Drive) for this specific model of laptop, but are otherwise nonexistent.

It would be really nice if I could somehow add NVMe support to the laptop’s UEFI, but AFAIK there are no existing solutions for this, other than chainloading from a second drive.

The subsequent model (ZBook G3) actually does support NVMe, but HP never backported that support to the G2/G1 (of course, according to them, if you simply use the specified OEM parts there’s no problem…). Oh well, 2.5” SATA drives work just fine for such an old beast.


Definitely an interesting problem.

If you're interested in going down the rabbit hole, some light googling suggests that HP uses an AMI BIOS. You might be able to mod it: https://winraid.level1techs.com/t/howto-get-full-nvme-suppor...


> the only M.2 drives it’ll boot from are non-NVMe PCIe drives

This is not as rare, there were some drives which are logically seen as a PCI AHCI device (aka SATA controller). It is also possible to directly use actual SATA signaling in M.2 socket. This was way more common, and has a slightly different key position in the connector so it is easy to see visually. However I find it more likely it is a NVMe driver but with the proper option BIOS that makes it bootable.


Yes, you are correct that they are PCIe AHCI drives. Looking on eBay again, they are only available as the aforementioned HP (or Lenovo) OEM parts directly from China (so you can’t really know if they aren’t fake), and they’re very overpriced (around €50 for a 256GB drive, which is the only available size).

Contrast this to NVMe drives, which are ubiquitous and cheap.

The laptop unfortunately doesn’t support M.2 SATA, but it does have a regular 2.5” SATA bay, so that’s what I’m using (it still has the OEM drive from the factory :))


Note that if you are 100% sure it is an PCIe AHCI drive, an PCIe NVME drive with the correct option ROM will also work, and be bootable. The first NVMe drives all had working option ROMs; you can google around and you'll find people compiling lists.


Ah, that's interesting. Perhaps if I get around to upgrading some other parts, I'll take a look at that too. Thanks!


I was pretty astounded this wasn't part of the standard. When did they make these, and was it common?


I know for sure the Samsung 950 Pro has a working option ROM, and it was pretty common at the time. The successor apparently doesn't have it but I don't know that for sure.


> My preferred method to boot NVMe on a legacy system though is to boot tianocore UEFI with an NVME module in it[1]. This is a UEFI firmware that you can chainload from a legacy bios.

If you already have UEFI, but no NVMe support all you need to do is boot into a UEFI shell-script (it’s a thing) which 1. loads a NVMe module (which you’ll need to provide, get it from tianocore), 2. does a device probe and 3. chain boots from the NVMe drive.

It’s not too much work to get going, barely a few megabytes and any old USB stick you have should make do without causing the USB stick to wear out because it won’t have to endure bootloader updates in the booted OS (which may happen if you put your whole /boot on the USB drive).


It looks like the formatting in the post got broken when level1techs migrated their forums from a different platform? I'm seeing strings of sequential numbers (intended as line or ordered-list numbers?) prior to a block of code with some lines blank.


You can do this with Linux easily as long as your bios allows you to boot from USB. Just put /boot on the USB and everything else on the NVMe (via PCI Express to NVMe card). This trick has allowed me to save several old PCs and use them as home servers and for my home lab.


> Just put /boot on the USB and everything else on the NVMe

Hold up - that works? I’ve got a SBC device that has to boot off sd card but has ssd attached.

Any pointers as to where I could read up more on how to split a fs system like that? I can copy files easily enough but presumably needs so additional magic to link/integrate it


Believe it or not, you don't even need a physical disk to boot at all (on many systems).

The first step in the boot process is loading the boot firmware. On a BIOS/UEFI PC, this gives you Preboot Execution Environment (PXE) [0]. Raspberry Pi boards have something similar since the Pi 3, though it's not exactly PXE. Network booting allows you to setup a DHCP server in a way that automatically serves the machine a kernel, initramfs, and cmdline over the network. You can run a full Linux that way, though you probably want to switch_root [1] to another filesystem that has a block device backing it with more storage, for practical purposes. This is what most initramfs images do.

Once the machine can automatically retrieve those three, you're set. The initramfs can be built with whatever binaries, firmware, and kernel modules you need to initialize the network and set up an NBD or NFS share. Add `root=/dev/nbd0` or whatever, and you're running over the network.

Same concept applies to booting with a split boot partition. The boot partition contains the kernel, initramfs, and bootloader, along with the boot configuration. The kernel cmdline specifies which disk contains the root filesystem. It need not be on the same disk as the kernel, or even on the same machine.

[0] https://en.wikipedia.org/wiki/Preboot_Execution_Environment

[1] https://landley.net/writing/rootfs-programming.html


Many thanks for the detailed response. This is probably the part that was missing in my mind

>The kernel cmdline specifies which disk contains the root filesystem.


Absolutely. It's a part of the kernel I find very interesting.

Here's a related bit from the kernel docs that describes the initramfs and switch_root in more detail.

https://www.kernel.org/doc/Documentation/filesystems/ramfs-r...

Interestingly, there's even a mechanism for leaving programs running even after exiting the initramfs.


Possibly you may be get by installing normally on NVMe; `cp -R /mnt/nvme0p1/boot /mnt/mmcblk0p1/boot`; `sudo reboot`. There shall be requisite kernel modules and /etc/fstab inside initramfs to find `nvme0` and chroot into it.

It ultimately should not matter how Kernel + initramfs finds itself on RAM, or whether it was loaded from what it thinks it was loaded from. Kernel is just a baremetal program, and BIOS/firmware is just the least elaborate tool to make Kernel appear on RAM.


I'm doing something similar with the VisionFive 2, boot is on the SD card, the NVME does the rest.


Note that current u-boot (latest official fw release, u-boot patches already upstreamed) can boot straight from NVME.


Looks like an interesting project, but upon seeing that screenshot and this...

It's a heavily modified version of iPXE (which usually allows for booting from the network), but instead of the network, this code uses a port of the SeaBIOS NVMe implementation to talk to a local NVMe drive.

I can't help but feel like that's a very roundabout way of doing it (especially the fact that it seems to be manual?); after all, the BIOS Boot Specification exists and it's what lets PCs boot from things like SCSI and other block devices.


Assuming the NVMe manufacturers neglected to support the BIOS Boot Specification themselves, you've got to put some code into your option rom... And it may as well be a modified iPXE that has NVMe support? iPXE can be scripted it you want the whole process automated, but maybe that doesn't make as nice of a demo?


Their example of a ThinkPad T43 is an interesting choice, because it was a rare model that used a problematic SATA-PATA bridge kludge for storage.

https://www.thinkwiki.org/wiki/Problem_with_non-ThinkPad_har...

It couldn't even take a proper hard drive when new, 18 years ago, but now it can boot from NVMe.


»This project allows old x86 computers using a classic BIOS to boot from modern NVMe storage attached via PCI(e). It's a heavily modified version of iPXE (which usually allows for booting from the network), but instead of the network, this code uses a port of the SeaBIOS NVMe implementation to talk to a local NVMe drive.«


Using network boot to inject a custom loader is ingenious! Was literally faced with this today. My AMD motherboard circa 2012 did not recognize the PCIe NVMe SSD. It was rather slow on this PC for some reason anyway (yes, I did my due diligence). Ended up putting it in a laptop which was thankfully able to muster a higher throughput.


More interested in how the PCIe breakout board being used works.. is there some kind of bridge to a mini PCI slot?


The "classic" ones have a small adapter inside the computer case (this can be ExpressCard, a mini PCIe or an M.2 plug). They'll use either HDMI or USB 3 connectors and cabling as these can maintain reasonable signal integrity; this plugs in to the regular sized PCIe slot on the outside. There's also a barrel jack and/or a PCIe PSU connector on them for power.

I don't think there's any smartness hiding inside of these, the connector and number of conductors will limit you to a ×2 or ×4 connection anyways.


Explaining Computers covered them in a recent video[0].

0. https://www.youtube.com/watch?v=Ktqa11VT1xI


A lot of NVME drives already ship such an option ROM. This has only become a problem relatively recently now that most SSDs do not care to ship one (or ship untested ones).


Cant you just use a m.2 to 2.5 inch sata dummy drive?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: