Skip to content

grml-live: make MIRROR_DIRECTORY readonly in chroot#529

Open
zeha wants to merge 2 commits into
masterfrom
zeha/mounts
Open

grml-live: make MIRROR_DIRECTORY readonly in chroot#529
zeha wants to merge 2 commits into
masterfrom
zeha/mounts

Conversation

@zeha

@zeha zeha commented May 28, 2026

Copy link
Copy Markdown
Member

Drive-by: umount all mountpoints inside CHROOT_OUTPUT during cleanup. Frees us from tracking which directories got mounted into CHROOT_OUTPUT.

mount with rbind needs util-linux >= 2.39, available in bookworm.

Serves as a basis for mounting further directories into the chroot area.

@zeha zeha requested a review from mika May 28, 2026 23:52
@github-actions

Copy link
Copy Markdown

🐳 Docker image for this PR is available:

docker pull ghcr.io/grml/grml-live:pr-529

@zeha zeha requested a review from jkirk May 28, 2026 23:52
@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown

@mika mika left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting idea, thx!

Comment thread grml-live
local mountpoint
while IFS= read -r mountpoint; do
einfo "Unmounting ${mountpoint} ..."
umount -R "${mountpoint}" ; eend $?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAICS we're now trying to unmount all mount points without taking care of any preference/ordering in mind, no matter whether it's a parent (/chroot/) or children (/chroot/proc/ + /chroot/sys/) directory, but we don't care?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i've reworked this to ignore the parent and umount all mountpoints inside CHROOT_DIRECTORY in reverse order. this might not always work, but it shouldn't be worse than before

Comment thread grml-live Outdated
while IFS= read -r mountpoint; do
einfo "Unmounting ${mountpoint} ..."
umount -R "${mountpoint}" ; eend $?
done < <(findmnt -k -rn -o TARGET | awk -v p="${CHROOT_OUTPUT%/}" '$0==p || index($0,p"/")==1')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do I understand this right that we hereby list all currently mounted paths, then only match lines that either match exactly ${CHROOT_OUTPUT} or start with ${CHROOT_OUTPUT} and also de-duplicate e.g. /chroot and /chroot/ into the same directory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

what we need is all direct children of $CHROOT_OUTPUT that are mountpoints.

unfortunately findmnt has a lot of options, but doesn't help us with this.

$CHROOT_OUTPUT itself shouldn't be a mountpoint. you're right though that if $CHROOT_OUTPUT is a mountpoint, this will break.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the "direct children" thing was a massive think-o on my side

Comment thread grml-live
@zeha zeha force-pushed the zeha/mounts branch 3 times, most recently from 2f2c406 to cc364c2 Compare June 3, 2026 06:46
Recursively umount mountpoints inside CHROOT_OUTPUT in cleanup. Frees us
from tracking which directories got mounted into CHROOT_OUTPUT

Gbp-Dch: full

@mika mika left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lovely, thanks! (FTR: didn't test/verify it, but LGTM!)

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