Ramroot – Run Arch Linux Entirely from RAM (2017)
ostechnix.com
ostechnix.com
Virtually all network booted computers run their OSs from RAM. If you have never pxe booted a machine, it is a beautiful experience once you overcome a few challenges: easy upgrades and rollbacks, being able to use a machine with different contexts/platforms by just rebooting, and having your servers cleaned up just by cycling (assuming you don't have local storage)
If you enjoy the idea of RAM root devices, please try pxe/ipxe to boot your computer from a network. Also, if you have a sufficiently fast network... it is probably faster than booting from disk!
EDIT: I missed the word "all" on the second paragraph, and another typo... sorry!
http://ipxe.org/start has all the info you'll need.
Even in the event you have to use some secure zone crap, it’s pretty trivial to build since all PXE requires are dhcpd and tfptd — which are often available by default on nearly any *nix variant.
A hint if you're doing this on Linux. We PXEBoot an iPXE loader to boot the machines. Doesn't work properly on UEFI unfortunately, gotta use BIOS boot.
If it helps, I have notes on how to set that up:
Go to http://rom-o-matic.net and choose gPXE git. Click on the "Customize" button to expand all of the options.
Choose: 1. PXE bootstrap loader image [Unload PXE stack] (.pxe)
2. all-drivers
3. PCI VENDOR CODE: [blank] PCI DEVICE CODE: [blank]
X CONSOLE_PCBIOS
_ CONSOLE_SERIAL
BANNER_TIMEOUT [20]
_ NET_PROTO_IPV6
(Serial Port Options are irrelevant)
X DOWNLOAD_PROTO_TFTP
X DOWNLOAD_PROTO_HTTP
_ DOWNLOAD_PROTO_HTTPS
_ DOWNLOAD_PROTO_FTP
_ SANBOOT_PROTO_ISCSI
_ SANBOOT_PROTO_AOE
X DNS_RESOLVER
X IMAGE_ELF
X IMAGE_NBI
X IMAGE_MULTIBOOT
X IMAGE_PXE
X IMAGE_SCRIPT
X IMAGE_BZIMAGE
X IMAGE_COMBOOT
X AUTOBOOT_CMD
X NVO_CMD
X CONFIG_CMD
X IFMGMT_CMD
X IWMGMT_CMD
X ROUTE_CMD
X IMAGE_CMD
X DHCP_CMD
_ SANBOOT_CMD
X LOGIN_CMD
_ TIME_CMD
_ DIGEST_CMD
X PXE_CMD
_ IPV6_CMD
_ CRYPTO_80211_WEP
_ CRYPTO_80211_WPA
_ CRYPTO_80211_WPA2
Embedded Script:
-----------------------------------------------------------------------------
#!gpxe
dhcp any
initrd http://<your_server_here>/initrd.img
kernel http://<your_server_here>/pxelinux.0
imgargs pxelinux.0 root=/dev/nfs rw boot=nfs nfsroot=<your_nfs_server_here>:/netroot root ip=dhcp nfsrootdebug
boot pxelinux.0
-----------------------------------------------------------------------------
[1] https://github.com/joelandman/nyble
[2] https://github.com/joelandman/tiburon
[3] https://scalability.org/2019/05/nyble-ftw-installing-my-ramb...
Especially useful for Windows; it is rather slower diskless (compared to BSD/linux) but it makes Windows instances disposable.
Takes a bit of effort (more these days, FUVM systemd) but having a RAMdisk + diskless RO /usr is a great way of having computers everywhere all singing the same song.
Is this also true on Windows, with all the hardware initialization it has to do on boot when it finds new hardware?
It worked basically how a Live CD worked - creating a temporary filesystem in ram, and I only learned later that they already existed (I didn't know at the time and the Internet wasn't as good at finding things as it is today :) )
In theory, the kernel uses a buffer cache that will hold on to disk pages until they're invalidated by writes. It'll evict the cache if there's memory pressure. But this setup will presumably just crash if there's memory pressure, so that doesn't seem like a win for the RAM disk.
For example, if you want to run hardware diagnostics on multiple machines at the same time with 1 consistent, custom environment, you can just setup one USB stick with this, and plug it on each machine in turn to boot them up. You wouldn't need to keep the USB stick plugged in while they're running.
I started implementing raw block device support for my own databases about five years ago and it turned out to be brilliant for more reasons than I expected. I should have tried it much sooner. Ironically, it requires less code than using the file system.
sqlite3 /dev/sda
(Don't try to hold me responsible if you run that with root)I'd agree that making ureadahead more aggressive would indeed make more sense than just sticking your roots in RAM. It shouldn't impact your boot time very much and is much more flexible!
But maybe there's some special perf benefit to the ramroot approach..
Sure people have been running distros from ram for a while but getting the tooling situated to make it like any other feature it super cool.
Is that only true for Arch, or is that also working on other distros?
The nice thing about NBD is that its a super simple protocol, the server runs in user space, and it's easy to modify to suit own needs. I built sometime ago a version with block deduplication for a farm of disk-less clusters that had very little ram in ~1k LOC. Main disk had persistence activated, while swap drives were pure RAM.
[1]: tinycorelinux.net
I'm currently working on the next version in my spare time (you'll see it in the dev branch). Improvements include: configuration now done via /etc/ramroot.conf, ability to specify actions taken for other partitions, ability to copy files to any location only when booting from RAM (allowing custom configs and whatnot to be used when in the live environment), new install hook that includes binaries and modules rather than adding them to /etc/mkinitcpio.conf, sudo will no longer be a required package, custom memory requirement settings, and more...
Also, I have gotten this to work on Debian, Ubuntu, and Kali with minor modifications. I plan to include a makefile for installing to these distros but don't plan on packaging for them at this time.
Some info about it here:
[0]https://forums.gentoo.org/viewtopic-t-622085-start-0.html
I understood the capitalisation to indicate the default. Or does the default change? That seems bad if you're intending to wrap this in a script.
I came to know about this from Puppy Linux.
What do so something cool? Boot a whole computer cluster using BitTorrent as a backend, diskless, diskfull, at lightning speeds: https://github.com/dchirikov/luna
FreeNAS prefers ZFS so it’s RAM hungry anyway. The article recommend 500mb more than you need.
Can you do this to an Arch VM?
Amazon has $4.99 16GB USB 2.0 flash drives from SanDisk. I’m sure you could find cheaper chinese brands.
The FreeNAS community recommends 5+ year old server hardware running refurbished or used enterprise SAS drives. Performance is not an issue when you never want to shut it down.
Because this is a "real" (headless) 2U server, none of the USB ports were being used so, while dedicated SSDs for the boot volume would be nice, a pair of decent 16 GB USB flash drives have been doing a wonderful job serving as my mirrored "freenas-boot" pool.
However, you can use Ubuntu/Debian/Void as well.
Here are my personal recipes: https://github.com/pauldotknopf/darch-recipes
PS: I'm the author of Darch.
The piratebay used to run their servers like this. They'd boot off of a USB stick, pivot root to a ram disk, and then unmount the USB stick. Then when the cops would seize the machines and cut power to save as much evidence as they could, they'd actually be doing the opposite.
Let's for a second assume that forensic computer technicians aren't completely incompetent and actually understand that you do not pull the plug on a system that potentially contains evidence the first thing you do.
While this has been known to happen in the past, I can almost guarantee it's because of "helpful" police officers, much in the same way the job of any forensic technician can be ruined by good intentions of those who don't know better.
And this piratebay mitigation was in the early 2000s. At that point most of the anti forensic mitigations were booby traps on input channels (keyboard, console, etc) and maybe a tilt sensor that'd wipe the drive if anyone tried to access it. Under that scheme, pulling power before inspection is what you want to do.
Why? Are you saying there were no measures to make data inaccessible in case of power failure?
What's new here is being able to optionally and seamlessly copy the regular disk install into RAM on boot.
One of them had such a shit slow (RLL I think) hard disc, I decided to network boot it instead and saved quite a lot of money.
- Testing - quickly deploy a version of an OS and software to a fleet, then reboot into a pristine state or new state.
- Lab cost reduction. No hard drives in most of the fleet. Less power used.
- Consistent version across many test servers. People change things, reboot or power cycle and you are back into the same state.
I've used something like this in production before using NFS diskless. That was a bit messy. For labs, testing, it is great.