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

Create disk images without root #381

Merged
merged 3 commits into from
Jan 24, 2024

Conversation

eduardosm
Copy link
Contributor

mke2fs has a -d option that allows to populate the newly created filesystem without needing to temporarily mount it. That allows to use parted and mkfs.ext3 on regular files without needing root access.

I also fixed some issues I bumped into while testing (see commits).

@eduardosm eduardosm force-pushed the disk-images-without-root branch 2 times, most recently from a53322a to 8318e0e Compare December 28, 2023 21:45
@Googulator
Copy link
Collaborator

A quick note: this should not affect probably the most common case of qemu or bare-metal with kernel bootstrap without --external-sources, which already proceeds without ever creating an FS image other than srcfs.

Copy link
Collaborator

@Googulator Googulator left a comment

Choose a reason for hiding this comment

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

Other than these, LGTM.

self.external_dir = os.path.join(self.target_dir, 'external')

os.makedirs(self.external_dir, exist_ok=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove exist_ok here? I'm pretty sure this will break CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any situation where that directory can exist at that point? Previously, it would exist when the "external" image was mounted, but it is not longer the case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It exists at the beginning the latter phases of GitHub CI, which is split up into multiple phases to avoid hitting GitHub's time limits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the prepare function (the one modified here) is only called for the first step, later steps use the reuse function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like I was actually mistaken about the purpose of this.

But it is indeed necessary - when building with kernel-bootstrap and external sources, /external will already exist when we get here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still don't see how can the directory exist.

But it is indeed necessary - when building with kernel-bootstrap and external sources, /external will already exist when we get here.

That was true when the external image was mounted, which already created the directory. But now only the init directory will exist at that point.

steps/jump/linux.sh Outdated Show resolved Hide resolved
@eduardosm eduardosm force-pushed the disk-images-without-root branch from 8318e0e to fa26b1f Compare January 2, 2024 13:14
`mke2fs` has a `-d` option that allows to populate the newly created filesystem without needing to temporarily mount it. That allows to use `parted` and `mkfs.ext3` on regular files without needing root access.
…passed (with kernel bootstrap)

All distfiles are still copied to "external"
The version of stat available at that point does not support %Lr, so use instead its hexadecimal counterpar (%T)
@eduardosm eduardosm force-pushed the disk-images-without-root branch from fa26b1f to 5243d3b Compare January 12, 2024 21:41
@fosslinux fosslinux merged commit 34e4bf9 into fosslinux:master Jan 24, 2024
6 checks passed
@eduardosm eduardosm deleted the disk-images-without-root branch January 24, 2024 17:39
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.

3 participants