[Build/Dev Blog] Christmas Workstation Build (EFI RAM Disk Fun)

So I’m starting this blog now, three months early, because there’s going to be a lot of stuff that needs figured out before I actually buy hardware/have the money in December. And hooo boy is this one gonna be an expensive rebuild. Maybe Threadripper Storm Peak will be out by then, or whatever Intel’s been up to.


The Goal:

I want to have one PC, with an insane amount of RAM for a desktop (probably 512GB), which can load a VHD/similar disk image over the network into a RAM disk and boot from that. I’d like to have multiple images stored on the NAS - one with Windows gaming stuff, one with Linux development stuff, etc - that I can choose from at boot and then flush changes back to that storage whenever something on the OS drive (I’d still have network storage connected) gets modified that I want to preserve.

No local storage except a device for the bootloader.


That means I’ve got several steps to figure out. Connecting to an iSCSI target as a storage device is easy… it’s everything afterwards that’s the hard part. Do I:

  • Have a local bootloader which connects to the iSCSI target, prompts to select an image, and then mounts that image as a RAM disk and boots.
  • Have the iSCSI initiator actually select and boot the image which would leave each OS image to do its own RAM disk setup/configuration.
  • Run some kind of hypervisor I’m unaware of that would handle most of this and accept the performance hit.

Dunno yet, these are all just shower thoughts so far.

Now this is all very similar to what Windows PE already does, minus the network boot… the RAM disk is assigned X: at boot. So, maybe I have something to investigate there? GRUB can initialize a RAM disk, that’s an option. I see something about adding EFI entries to the Windows boot manager, maybe that’s a thing?..


I have no idea what I’m doing, but it’s gonna be an adventure and I’ll document it here as it happens slowly over the next few months.


Leaving these here for my own reference:

Summary

Setup BCD to boot PE from RAM? - Microsoft Q&A

Windows PE - ArchWiki

UEFI Shell Scripting Tutorial

Re: [edk2] how do I use RamDiskDxe?

https://www.digitalstorm.com/forums/howto-add-uefi-shell-boot-option-tidf53003/

[edk2] Memory mapped file system on RAM used by EDK shell

EFI Toolkit download | SourceForge.net

https://www.intel.com/content/dam/support/us/en/documents/motherboards/server/sb/efi_instructions.pdf

Arch Linux - efifs 1.9-1 (any)

https://efi.akeo.ie/

Releases · pbatard/ntfs-3g · GitHub

GitHub - tianocore/edk2 at UDK2018

Index of /dell/hardware/OMSA_7.4.0/platform_independent/suse10_64/payloads/
Dell_Lifecycle_Controller_componentid_18980_for_system_ven_0x1028_dev_0x02a3

Programming for EFI: Creating a "Hello, World" Program

“Hello World” Quick-Start with edk2-stable201908 | Basic Input/Output

5 Likes

It sounds like you’re talking about TFTP and PXE boot. TrueNAS has a TFTP server built-in, and most NICs these days should be able to manage PXE booting with a little help from your local DHCP server.

Switching between OS images easily might be a thing… not sure offhand exactly how that would work.

That way you’d have no local storage at all, but it might be easier to run Proxmox or XCP-ng, and just have all your VM images pulled in over the network. XCP-ng calls them “storage repositories” and it’s pretty easy to define them as either local, or via NFS or iSCSI. Not sure what the analogue is for Proxmox, but there’s probably something.

2 Likes

Could be… PXE is something I’ve somehow avoided my entire life, so I have no idea what I’m getting into. Will do some reading on it.

A lot of the suggestions I’m seeing elsewhere right now are for mounting the boot drive over NFS which is specifically what I’m avoiding.

Yeah, I was looking through Hyper-V documentation too and I see it supports basically what I’m trying to do. If I can’t figure out a better way to do it on bare metal, I’ll probably just virtualize it and eat the performance cost. Not in a hurry though, so I’m gonna try a few things first.

The difficult part seems to be that I want the OS image mounted as a block storage device.

If you’re not going to be sharing the same data across multiple operating systems, then yeah I don’t see a reason why you’d be tied to NFS. iSCSI should work, it’s just like you said, a difference in how you boot from it.

Not sure this is for you, but you may want to investigate LTSP:

1 Like

I don’t think Storm Peak will be here by December. Probably OEM only in early 2023, and DIY summer of 2023 if AMD sticks with past practice. I was considering building a wrx80 workstation on 5000 series, but I think I’ll be waiting for Threadripper 7000. My workloads take advantage of higher clock memory and TR 5000 relies on bios updates on 3000 series boards. I think storm peak will hit at the ideal time where you won’t have to pay the early adopter tax on ddr5, and the boards will be built with adequite power delivery for cooking ram and beastly CPUs

1 Like

Am learning things here at the moments, so I might not respond directly to everyone’s posts but I am reading them.


Also it’s occurred to me that one downside of what I’m trying to do is that by loading the entire OS drive into RAM instead of mounting it over the network, I’m gonna be waiting at boot for the thing to transfer at least a 100GB image over the network. Which isn’t great, but 40G InfiniBand should make it tolerable at least.

I might kinda have something hideous that works.

I’m just testing things on a crap desktop PC with like 4GB of laptop DDR3 at work right now, but it’s a UEFI system and it appears I can:

  • Load into an EFI shell on USB,
  • Create a RAM disk as a block device in memory with the old EFI-Toolkit utilities,
  • Load a Linux kernel stub and DD from an image/block device onto that new RAM disk block device,
  • Unload the kernel stub and execute the EFI OS loader for the OS that was just DD’ed into memory.

I don’t have the RAM to see if anything actually loads, but it’s progress I think

1 Like

Why?

2 Likes

image

2 Likes

Do you understand the trouble, and possibly the hardware requirements of what you are planning?
Also the fact that if by chance you are able to pull it off you’ll be on your own with regards to troubleshooting/backups?

You’re probably better off buying the cheapest possible fiber channel San that can take snapshots, and use that as your storage system…

That’s no fun, that’s way too easy. :kissing:

I understand that I’m about to buy $800 of registered DDR4, a few NVMe NAS drives, and that writing bare metal EFI block I/O drivers as I type this is beyond what anyone on the internet can/will take the time to help with.

This one’s a project blog and not another help desk thread asking for someone to put together a sensible PC build. Am doing it for the same reason my home network runs QDR InfiniBand - I enjoy learning about new things and figuring out stuff that sounds interesting.

3 Likes

Gotcha, just wanted to make sure it wasn’t a spur of the moment need, inspired by a random youtube video :slight_smile:

Have you looked into IPXE?
https://ipxe.org/howto/wds_iscsi

1 Like

If you’ve got a way you can get 512GB of ECC DDR4 for $800, then I hate you.

best

1 Like

Hell yeah, spent two days learning about how to recompile EFI binaries from the EDK2 and we have a working 1GB RAM disk in EFI on Z490.

4 Likes

Slowly we make progress.

The EFI RAM disk enumerates in GRUB, as HD1 here. Configuring GRUB to just run on its own, standalone/without Linux, was a miserable experience as those of you who saw me venting in the Lounge about it today have probably guessed lol

This thing is gonna boot through so many different shells at startup

2 Likes

image

Gentlemen it’s been an honor. I’ll be spending the week learning how to use the EFI specification to write part of this thing that doesn’t appear to exist in the wild exactly as I need it.

Good thing C is about the only proper programming language I’m actually familiar with.


Note to self,

iPXE: include/ipxe/efi/Protocol/BlockIo.h File Reference

UEFI Programming - First Steps

2 Likes

If you’re not back in a week I’ll call your mother.

3 Likes

Out of curiosity I tried to copy the Arch installation ISO to that RAM disk to see if GRUB could boot it from there. It failed copying about 2/3 of the way through. Now that I’m looking at the source code, it turns out there are several problems which I’m in the process of resolving:

The EFI driver RAMDISK.EFI creates the block device and handle in memory but also loads it with a FAT16 filesystem. The driver itself enforces a max 512MB size on the RAM disk (if > 512, set = 512 and continue), and the underlying GetDiskSize() & related function calls use UINT32 types which limit me to 4GB.

image

I’m removing the FAT filesystem entirely and rewriting the RAMDISK driver and MKRAMDISK command to use UINT64 integers so they can make an arbitrarily large block device. We’ll see how many problems that causes once I get the environment set back up to compile it.

1 Like