| mkdir pxerescue | |
| mkdir pxerescue/chroot | |
| cd pxerescue | |
| git clone https://github.com/medallia/ramroot | |
| sudo debootstrap --arch=i386 xenial chroot http://apt/mirrors/ubuntu | |
| sudo cp -r ramroot/initramfs-tools/* chroot/etc/initramfs-tools/ | |
| sudo chroot chroot | |
| mount none -t proc /proc | |
| mount none -t sysfs /sys | |
| mount none -t devpts /dev/pts | |
| export HOME=/root | |
| export LC_ALL=C | |
| apt install install initramfs-tools pixz | |
| apt install linux-generic <--- can install linux-virtual for a smallrt kernel, but almost no modules included, usb keyboard won't work | |
| apt autoremove --purge | |
| apt clean | |
| apt remove --purge resolvconf | |
| rm /etc/resolv.conf | |
| vi /etc/resolv.conf <-- add whatever you want | |
| *FIX BUSYBOX* (see below) | |
| passwd root (or enable autologin) | |
| You can instead edit the file /lib/systemd/system/getty@.service and change the line | |
| ExecStart=-/sbin/agetty --noclear %I $TERM | |
| to | |
| ExecStart=-/sbin/agetty --noclear -a root %I $TERM | |
| change motd | |
| - rm /etc/update-motd.d/* | |
| - vi /etc/motd <--- whatever you want. You can also drop scripts in the above dir | |
| ** saving space / slimming down | |
| echo -n '' > /var/cache/apt/pkgcache.bin | |
| echo -n '' > srcpkgcache.bin | |
| apt remove --purge <bunch of stuff linux-headers* and more, linux-firmware if you don't need it > | |
| rm -rf /tmp/* | |
| *** cleaning up and coming out of the image | |
| umount -lf /proc | |
| umount -lf /sys | |
| umount -lf /dev/pts | |
| exit the chroot | |
| *** GET THE FILES YOU NEED TO BOOT | |
| sudo cp chroot/{initrd,vmlinuz} . | |
| sudo rm chroot/boot/{initrd,vmlinuz} <--- free up space, not needed in the image anyway, but need to install them for kernel modules and initrd generation | |
| cd chroot | |
| sudo tar Jcvf ../rootram.tar.xz . | |
| ==== Fix busybox === | |
| By default does not ship with wget and fails miserably | |
| apt-get install -y gcc build-essential libncurses5-dev libpam0g-dev libsepol1-dev libselinux1-dev | |
| wget busybox + extract | |
| make defconfig | |
| make clean && make LDFLAGS=-static | |
| cp busybox chroot//usr/lib/initramfs-tools/bin/busybox | |
| === If you need a GUI === | |
| apt-get install xserver-xorg-core xorg fluxbox | |
| can then startx | |
| === PXE setup === | |
| assumes you have pxe set up with lpxelinux + apache running | |
| copy over vmlinuz initrd.img and ramtoot.tar.xz | |
| menu stanza looks like this | |
| LABEL 1 | |
| MENU LABEL RamRoot | |
| KERNEL http://pxe/netinstall/ramroot/vmlinuz | |
| INITRD http://pxe/netinstall/ramroot/initrd.img | |
| APPEND boot=ramdisk ramroot=http://pxe/netinstall/ramroot/ramroot.tar.xz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment