[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patch to support embedding live image into the initramfs



Hi all,

First off, I apologize if I have not followed proper mailing list etiquette or standards for patch submission. If this is the case, please be so kind as to direct me as to the correct approach so that I can do the right thing next time. I'm used to a pull-request based workflow, and mailing lists are a bit tricky for me.

I am very pleased with the live-boot system, but there is one feature that I need quite desperately, and does not seem to be supported currently. If it is supported in some way that is not clear to me, please feel free to point me to an alternative approach. What I need is a way to boot the live media from inside the initramfs, without needing to fetch it from the network or another device.

My use case is primarily a network-booting system. I would like to serve up just the initramfs and kernel via PXE, without having to run a separate server for the live image itself. This has a few advantages, namely it's more reliable and simple. My build process already embeds the squashfs system into the initramfs, and they're so tightly coupled there is no reason to separate them.

In a separate use case though, I want to be able to use the exact same kernel and initramfs locally in a virtual machine for testing. This again underscores the need for simplicity, as I don't want to have to run a separate server to host the squashfs system.

The patch submitted is fairly straightforward. I have also updated the associated documentation. Basically, if 'live-media' or 'boot-from' is specified as exactly "initramfs", then it is assumed that the image is already embedded into the initramfs and exists at live-media-path.

I have verified that this works. This is the smallest and simplest possible patch I could come up with to meet my needs. I hope to upstream it in case if anyone else has a similar use case, and selfishly so that I don't have to maintain my own patch set on top of live-boot.

The patch is below and inlined. If you would prefer an attachment or another means of submission, I would happily do that.

Thanks,
-Dale

PATCH BELOW


From d1369d214d88c22cd85c65253dc17d45a4c7b3cd Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@shopify.com>
Date: Fri, 6 Nov 2015 09:22:28 -0500
Subject: [PATCH] Support embedding the live media into initramfs

---
 components/9990-main.sh | 4 ++++
 manpages/en/live-boot.7 | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/components/9990-main.sh b/components/9990-main.sh
index 512c624..0b4fa3a 100755
--- a/components/9990-main.sh
+++ b/components/9990-main.sh
@@ -49,6 +49,10 @@ Live ()
                then
                        # Do a local boot from hd
                        livefs_root=${ROOT}
+               elif [ "${LIVE_MEDIA}" = "initramfs" ]
+               then
+                       # Use the initramfs as the container for the live media
+                       livefs_root="/"
                else
                        if [ -x /usr/bin/memdiskfind ]
                        then
diff --git a/manpages/en/live-boot.7 b/manpages/en/live-boot.7
index 733e16c..e7080f4 100644
--- a/manpages/en/live-boot.7
+++ b/manpages/en/live-boot.7
@@ -79,7 +79,7 @@ Let you specify the name(s) and the options of the interface(s) that should be c
 .IP "\fBip\fR=[\fIfrommedia\fR]" 4
 If this variable is set, dhcp and static configuration are just skipped and the system will use the (must be) media\-preconfigured /etc/network/interfaces instead.
 .IP "{\fBlive\-media\fR|\fBbootfrom\fR}=\fIDEVICE\fR" 4
-If you specify one of this two equivalent forms, live\-boot will first try to find this device for the "/live" directory where the read\-only root filesystem should reside. If it did not find something usable, the normal scan for block devices is performed.
+If you specify one of this two equivalent forms, live\-boot will first try to find this device for the "/live" directory where the read\-only root filesystem should reside. If you specify "initramfs", it is assumed the initramfs already contains the live media at live-media-path. If it did not find something usable, the normal scan for block devices is performed.
 .br
 Instead of specifing an actual device name, the keyword 'removable' can be used to limit the search of acceptable live media to removable type only. Note that if you want to further restrict the media to usb mass storage only, you can use the 'removable\-usb' keyword.
 .IP "{\fBlive\-media\-encryption\fR|\fBencryption\fR}=\fITYPE\fI" 4
--
2.1.1


Reply to: