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

overlayfs-setup: Fallback to read only mount when overlay not supported #417

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

dbnicholson
Copy link
Member

Overlayfs doesn't support using case insensitive filesystems such as vfat and exfat as a lower directory. Change the mount to read only so changes can't be made there.

In theory this would simply be mount -o remount,ro. Unfortunately, if systemd has setup an automount, autofs is not our friend. In that case, the mount options need to be persisted into the mount unit so that a subsequent remounting retains the ro option.

https://phabricator.endlessm.com/T35641

@dbnicholson dbnicholson requested a review from wjt October 16, 2024 22:16
Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

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

LGTM.

I wonder what happens if you have both rw and ro in the mount options. Which one wins? Is it the last one specified? If so the mount flag change could be simplified to unconditionally appending ,ro.

eos-live-boot-overlayfs-setup Show resolved Hide resolved
@dbnicholson
Copy link
Member Author

I wonder what happens if you have both rw and ro in the mount options. Which one wins? Is it the last one specified? If so the mount flag change could be simplified to unconditionally appending ,ro.

I'm not sure. I think probably last one wins and just appending was my first thought. Lemme try that out...

@dbnicholson
Copy link
Member Author

I wonder what happens if you have both rw and ro in the mount options. Which one wins? Is it the last one specified? If so the mount flag change could be simplified to unconditionally appending ,ro.

I'm not sure. I think probably last one wins and just appending was my first thought. Lemme try that out...

Yeah, that seems to work. I added an override to a test mount unit that set Options=umask=0077,noauto,rw,ro. After mounting the options were displayed as ro,... with no rw anywhere. I don't know if mount(8) or the kernel is doing the canonicalizing. Similary, I tried mount -o remount,rw,ro and it similary became ro,.... I suspect it's the kernel that does this since it always lists ro or rw as the first option regardless of what order they were specified.

I'll change that since the mount option editing was definitely my least favorite part of this patch.

@dbnicholson
Copy link
Member Author

I suspect it's the kernel that does this since it always lists ro or rw as the first option regardless of what order they were specified.

Oh, actually it is mount(8). I ran strace mount -o umask=0077,rw,ro /dev/vda1 /mnt and the resulting syscall was mount("/dev/vda1", "/mnt", "vfat", MS_RDONLY, "umask=0077"). Since read only is a mount(2) flag, it has to extract it from the options. Running it again with ro,rw or neither ro or rw resulted in mount("/dev/vda1", "/mnt", "vfat", 0, "umask=0077"). In other words, rw is the default of no flags specified.

Overlayfs doesn't support using case insensitive filesystems such as
vfat and exfat as a lower directory. Change the mount to read only so
changes can't be made there.

In theory this would simply be `mount -o remount,ro`. Unfortunately,
if systemd has setup an automount, autofs is not our friend. In that
case, the mount options need to be persisted into the mount unit so that
a subsequent remounting retains the ro option.

https://phabricator.endlessm.com/T35641
@dbnicholson dbnicholson force-pushed the T35641-overlay-case-insensitive branch from 8bd6208 to fff1cfe Compare October 18, 2024 12:08
@dbnicholson
Copy link
Member Author

Updated now to unconditionally append ro. I tested in a VM and it seems to work correctly.

@wjt wjt merged commit 23bb448 into master Oct 18, 2024
2 checks passed
@wjt wjt deleted the T35641-overlay-case-insensitive branch October 18, 2024 12:20
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