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

stage-1: Add support for rootfs on loop device #42

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

kirelagin
Copy link
Member

No description provided.

@kirelagin
Copy link
Member Author

New plan for the future: do what OpenWrt does. Instead of mounting the loop device directly, we can mount it read-only and then overlay tmpfs on top of it, so that we are not limited by the size of the img file.

inherit (lib) mkMerge mkOrder;

waitForRootfs =
lib.optionalString (elem "loop" rootfs.options) ''
Copy link
Member

Choose a reason for hiding this comment

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

Should this maybe happen unconditionally? I think it would make sense for block devices carrying the root filesystem too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think regular devices are better covered by udevadm-settle (which currently doesn’t work for unknown reasons).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, wait, yeah, I see what you are talking about. Yes, it’s probably not a bad idea to wait unconditionally.

Copy link
Member

Choose a reason for hiding this comment

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

Although with "real" block devices I guess we could use udev event like I also suggested in #35 (comment)

lib.optionalString (elem "loop" rootfs.options) ''
while [ ! -f "${rootfs.device}" ]; do
echo "Waiting for the rootfs image at '${rootfs.device}'..."
sleep 5
Copy link
Member

Choose a reason for hiding this comment

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

This delay could be shorter for a faster boot. To avoid spamming the console, we could print a . without a newline each on each loop rather than repeating the "Waiting" message.

@samueldr
Copy link
Member

Hi! 👋 Thanks for the contribution!

We might need documentation, or script, for pushing the image to ram. Additionally, looking into documenting or making it possible to load from unencrypted storage, maybe loaded from an SD card even. Though, as it is, the only requirement here to continue with this (in addition to the other comments) would be documentation, or a script, so it is obvious how to push to device properly.

@kirelagin
Copy link
Member Author

I’m not sure where to put this documentation, but here it is:

  1. Set fileSystems."/".device to something like /tmp/system.img.
  2. Add loop to fileSystems."/".options.
  3. fastboot boot boot.img
    adb shell mount -o remount,size=3G /  # Optional, if image is larger than default tmpfs size
    adb push system.img /tmp/system.img.part
    adb shell mv /tmp/system.img.part /tmp/system.img
    

@samueldr samueldr added the 4. type: enhancement New feature or request label Nov 19, 2019
@samueldr samueldr changed the base branch from master to development September 14, 2023 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants