Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay.d/05core: support booting ISO completely from RAM #2544

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

dustymabe
Copy link
Member

It has been presented to us a use case where the user wants to actually "install" directly to the same device that was used to boot the live ISO image (i.e. the ISO was written to a block device and then booted from). The way the ISO boots today it mounts the ISO at /run/media/iso and then mounts the CoreOS rootfs from a file under that mountpoint. In this scenario /run/media/iso will be busy and can't be unmounted because the root filesystem of the live running system depends on it.

We can adjust the strategy slightly to get a system that runs completely from memory (similar to live PXE systems) by just copying the file out of /run/media/iso and into memory before doing the rootfs mount, which will allow /run/media/iso to be unmounted before the installation commences.

This patchset adds a new coreos.liveiso.fromram option to allow requesting this new behavior. We could consider making this new behavior the default, but we'd need to consider the new RAM requirements. For example, before this change on a 2G FCOS system the usage after booting looks like:

[core@localhost ~]$ free -m
               total        used        free      shared  buff/cache   available
Mem:            1953         163        1286         125         503        1519
Swap:              0           0           0

With this change (and the coreos.liveiso.fromram kernel arguemnt
specified) the usage looks like:

[core@localhost ~]$ free -m
               total        used        free      shared  buff/cache   available
Mem:            1953         173         688         808        1091         824
Swap:              0           0           0

The usage would scale with the size of the rootfs. i.e. RHCOS is larger so the memory requirements would be larger too.

dustymabe added a commit to dustymabe/coreos-assembler that referenced this pull request Aug 10, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.
@dustymabe
Copy link
Member Author

tests for this over in coreos/coreos-assembler#3555

@cgwalters
Copy link
Member

In theory too what we could do is make the whole thing dynamic using something like devicemapper - basically we only need to move ourself to RAM when we go to do an install. So we could e.g. set up devicemapper raid in raid1 backed just by the ISO originally.

Then when we want to run coreos-installer, we create the ramfs and add it to the raid, then wait for the raid to sync, then unplug the disk.

Or maybe dm switch ?

But...dunno, maybe a kernel argument is just simpler.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interesting thing here is this becomes an API we need to maintain ~forever...but so far I don't think our initramfs glue has really had any public APIs? And hence there's no explicit place to document this in this repo, we'd need to add it to fedora-coreos-docs.

@dustymabe
Copy link
Member Author

An interesting thing here is this becomes an API we need to maintain ~forever...but so far I don't think our initramfs glue has really had any public APIs? And hence there's no explicit place to document this in this repo, we'd need to add it to fedora-coreos-docs.

I imagine we'd document it wherever coreos.live.rootfs_url is documented.

@dustymabe
Copy link
Member Author

In theory too what we could do is make the whole thing dynamic using something like devicemapper - basically we only need to move ourself to RAM when we go to do an install. So we could e.g. set up devicemapper raid in raid1 backed just by the ISO originally.

Then when we want to run coreos-installer, we create the ramfs and add it to the raid, then wait for the raid to sync, then unplug the disk.

Or maybe dm switch ?

But...dunno, maybe a kernel argument is just simpler.

Yeah. In this kernel arg scenario coreos-installer itself doesn't need to know or care, which I think makes things more simple.

When it comes to modifying coreos-installer, I think we should still do the kexec option in coreos/coreos-installer#791. However, this PR would still have the benefit of not having to do a second "install" boot to get to a fully "fromram" system.

cgwalters
cgwalters previously approved these changes Aug 14, 2023
It has been presented to us a use case where the user wants to actually
"install" directly to the same device that was used to boot the live
ISO image (i.e. the ISO was written to a block device and then booted
from). The way the ISO boots today it mounts the ISO at /run/media/iso
and then mounts the CoreOS rootfs from a file under that mountpoint. In
this scenario /run/media/iso will be busy and can't be unmounted because
the root filesystem of the live running system depends on it.

We can adjust the strategy slightly to get a system that runs completely
from memory (similar to live PXE systems) by just copying the file out
of /run/media/iso and into memory before doing the rootfs mount, which
will allow /run/media/iso to be unmounted before the installation
commences.

This patchset adds a new coreos.liveiso.fromram option to allow
requesting this new behavior. We could consider making this new
behavior the default, but we'd need to consider the new RAM requirements.
For example, before this change on a 2G FCOS system the usage after
booting looks like:

```
[core@localhost ~]$ free -m
               total        used        free      shared  buff/cache   available
Mem:            1953         163        1286         125         503        1519
Swap:              0           0           0
```

With this change (and the coreos.liveiso.fromram kernel arguemnt
specified) the usage looks like:

```
[core@localhost ~]$ free -m
               total        used        free      shared  buff/cache   available
Mem:            1953         173         688         808        1091         824
Swap:              0           0           0
```

The usage would scale with the size of the rootfs. i.e. RHCOS is larger
so the memory requirements would be larger too.
@dustymabe
Copy link
Member Author

ok did a new push with the one requested deletion. I also rebased on top of latest testing-devel to get a full test run on top of the changes from #2543

@dustymabe dustymabe enabled auto-merge (rebase) August 14, 2023 19:55
dustymabe added a commit to dustymabe/coreos-assembler that referenced this pull request Aug 14, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.
@dustymabe dustymabe merged commit f01d947 into coreos:testing-devel Aug 14, 2023
1 check passed
@dustymabe dustymabe deleted the dusty-liveiso-fromram branch August 14, 2023 21:42
dustymabe added a commit to dustymabe/coreos-assembler that referenced this pull request Aug 16, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.
dustymabe added a commit to dustymabe/coreos-assembler that referenced this pull request Aug 16, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.
dustymabe added a commit to coreos/coreos-assembler that referenced this pull request Aug 17, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.
dustymabe added a commit to dustymabe/fedora-coreos-docs that referenced this pull request Aug 22, 2023
dustymabe added a commit to coreos/fedora-coreos-docs that referenced this pull request Aug 23, 2023
nikita-dubrovskii pushed a commit to nikita-dubrovskii/coreos-assembler that referenced this pull request Sep 14, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.

(cherry picked from commit 0955101)
travier pushed a commit to coreos/coreos-assembler that referenced this pull request Sep 18, 2023
In coreos/fedora-coreos-config#2544 we added
a new `coreos.liveiso.fromram` kernel argument to instruct the ISO
image to boot completely from memory in order to facilitate installs
back to the same disk the ISO was booted from in iso-as-disk mode
(i.e. dd the ISO file to a hard drive or partition on a hard drive).

Let's test here that we can boot completely from memory and that
/run/media/iso is not mounted.

Currently this doesn't actually do an install to the same disk that
we booted from (actually the iso-as-disk tests don't actually do
installs at all, but just verify they can boot), but rather just
verifies the ISO isn't mounted after the live system boots up, which
should be sufficient.

(cherry picked from commit 0955101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants