I would like to create a live system that would run entirely from memory. Is it possible to achieve this using only kernel + initrd?
My root filesystem is approx. 1.5 GB of data, which is currently sitting on /dev/sda1. I was thinking something like this:
1. create a /init script that would somehow start systemd directly
2. pack entire root filesystem using cpio + gzip
3. use the resulting file as initrd in boot loader (syslinux, grub, pxelinux...)
At least in theory, this should be possible, given the sufficient RAM. However...
- would the initrd be writable?
- what modifications would need to be made to the "ordinary" root filesystem so that it would work as initrd?
Yes, is possible.
1) Just symlink /usr/lib/systemd/systemd to /init
* You need at least sizeof(compressed initrd) + sizeof (uncompressed initrd) + sizeof(memory usage for unpack gzip) of RAM.
* If image if bigger than about 800M you need a kernel running in 64-bit
* Initrd (or more appropiate name initramfs) is uncompressed on rootfs (a special case of tmpfs) so this space if writeable.
* The symlink only and remove uneeded entries from fstab.