Skip to content

libcrun: fall back to bind mount for /dev/console on read-only file systems#2061

Merged
giuseppe merged 1 commit intocontainers:mainfrom
jnovy:fix-readonly-console
Mar 26, 2026
Merged

libcrun: fall back to bind mount for /dev/console on read-only file systems#2061
giuseppe merged 1 commit intocontainers:mainfrom
jnovy:fix-readonly-console

Conversation

@jnovy
Copy link
Copy Markdown
Contributor

@jnovy jnovy commented Mar 26, 2026

Commit 405d2a2 changed /dev/console setup to use unlink+symlink instead
of a bind mount when mount_dev_from_host is false. When the rootfs is
read-only and /dev is not a separate tmpfs mount, unlink fails with EROFS.

Fall back to the original bind mount approach when unlink returns EROFS.

Closes #1745

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where container terminal setup would fail on read-only root filesystems if /dev was not a separate tmpfs. Previously, the system attempted to unlink and symlink /dev/console, which would fail with EROFS on a read-only filesystem. The changes introduce a fallback to the original bind mount approach for /dev/console specifically when an EROFS error is encountered during the unlink operation, ensuring robust terminal allocation in such environments. A new test case has been added to validate this fix.

Highlights

  • Error Handling: Implemented a fallback mechanism for /dev/console setup when unlink fails due to a read-only filesystem (EROFS).
  • Terminal Setup: Reverted to using a bind mount for /dev/console in read-only rootfs scenarios where /dev is not a separate tmpfs.
  • Testing: Added a new test case to verify terminal functionality on read-only root filesystems without a dedicated /dev tmpfs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue where libcrun failed to set up a terminal on a read-only root filesystem when /dev/console could not be unlinked. The changes introduce a fallback mechanism in libcrun_set_terminal to bind mount the PTY to /dev/console if an EROFS error occurs during the unlink operation. A new test case, test_terminal_readonly_rootfs_no_dev_tmpfs, has been added to verify this behavior by simulating a container with a read-only rootfs and no /dev tmpfs. There is no feedback to provide as no review comments were made.

…ystems

Commit 405d2a2 changed /dev/console setup to use unlink+symlink instead
of a bind mount when mount_dev_from_host is false.  When the rootfs is
read-only and /dev is not a separate tmpfs mount, unlink fails with EROFS.

Fall back to the original bind mount approach when unlink returns EROFS.

Closes: containers#1745
Signed-off-by: Jindrich Novy <jnovy@redhat.com>
@jnovy jnovy force-pushed the fix-readonly-console branch from fc423c6 to 4c530d4 Compare March 26, 2026 06:29
@jnovy jnovy changed the title libcrun: fall back to bind mount for /dev/console on read-only filesystems libcrun: fall back to bind mount for /dev/console on read-only file systems Mar 26, 2026
Copy link
Copy Markdown
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit e5e96a3 into containers:main Mar 26, 2026
48 checks passed
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.

Regression run --read-only: Error: OCI runtime error: crun: unlink /dev/console: Read-only file system

2 participants