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
nixos/stage-1, nixos/f2fs: added F2FS resizing #42183
Conversation
F2FS is used on Raspberry Pi-like devices to enhance SD card performance. Allowing F2FS resizing would help in automatic deploying of SD card images without a Linux box to resize the file system offline.
@@ -126,6 +126,10 @@ let | |||
${optionalString (any (fs: fs.autoResize) fileSystems) '' | |||
# We need mke2fs in the initrd. | |||
copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs | |||
# Copy also f2fs-tools' fsck and resize | |||
# TODO: separate these in case no f2fs fs are present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but I don't seem to understand how this conditional works: (any (fs: fs.autoResize) fileSystems)
If you can explain it or link me to documentation how this works, I'd be happy to implement separate conditions for ext* and f2fs resizing like this:
if anyfs.type("f2fs").hasparam(autoresize):
# include f2fs-tools
if anyfs.type("ext*").hasparam(autoresize):
# include e2fsprogs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a similar check for zfs: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/tasks/filesystems/zfs.nix#L18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 I pushed a separate check for f2fs. The only problem is - it includes mke2fs even if no ext* filesystems need resizing, because I wasn't sure how to wildcard ext2, ext3 and ext4 filesystems in the check.
@@ -128,6 +128,13 @@ let | |||
copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs | |||
''} | |||
|
|||
# Copy f2fs-tools' fsck and resize if needed | |||
${optionalString (any (fs: fs.autoResize) (filter (x: x.fsType == "f2fs") fileSystems)) '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say:
${optionalString (any (fs: fs.autoResize && fs.fsType = "f2f2") fileSystems)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Didn't consider the obvious fact that && stands for logical AND operation. One sec, will push the updated version!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are at it, please also move this code to: modules/tasks/filesystems/f2fs.nix
There we already have an f2fs check anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 moved to nixos/f2fs module.
@GrahamcOfBorg test ec2-nixops (also checks resizing) |
Success on aarch64-linux Attempted: tests.ec2-nixops No partial log is available. |
@Mic92 means I didn't broke anything? does it test f2fs? I didn't write any tests for this code. |
Only ext4, which is also changed in this pull request. Since there is no log, I am not sure, if it is performed on aarch64 at all. |
Where do the resizing tests reside? Maybe it will be beneficial if I write the tests for it too. Who knows if it works or not, I don't have a NixOS box to test it... |
Failure on x86_64-linux (full log) Attempted: tests.ec2-nixops Partial log (click to expand)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Is there any reason why this was not merged yet?
Adding F2FS resize support like with ext* filesystems in stage1.
Motivation for this change
F2FS is used on Raspberry Pi-like devices to enhance SD card performance. Allowing F2FS resizing would help in automatic deploying of SD card images without a Linux box to resize the file system offline.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)