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

nixos/stage-1, nixos/f2fs: added F2FS resizing #42183

Merged
merged 7 commits into from Jan 17, 2019
Merged

Conversation

vikanezrimaya
Copy link
Member

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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

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
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

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)) ''
Copy link
Member

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)

Copy link
Member Author

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!

Copy link
Member

@Mic92 Mic92 Jun 19, 2018

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...

Copy link
Member Author

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.

@vikanezrimaya vikanezrimaya changed the title nixos/stage-1: added F2FS resizing nixos/stage-1, nixos/f2fs: added F2FS resizing Jun 19, 2018
@Mic92
Copy link
Member

Mic92 commented Jun 19, 2018

@GrahamcOfBorg test ec2-nixops

(also checks resizing)

@GrahamcOfBorg
Copy link

Success on aarch64-linux

Attempted: tests.ec2-nixops

No partial log is available.

@vikanezrimaya
Copy link
Member Author

@Mic92 means I didn't broke anything? does it test f2fs? I didn't write any tests for this code.

@Mic92
Copy link
Member

Mic92 commented Jun 19, 2018

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.

@vikanezrimaya
Copy link
Member Author

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...

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: tests.ec2-nixops

Partial log (click to expand)

machine: exit status 0
machine: must succeed: stat -c %S -f /
machine# [    7.784743] sshd[770]: pam_unix(sshd:session): session closed for user root
machine: exit status 0
error: wrong free space 2078097408 at (eval 16) line 53, <__ANONIO__> line 429.
wrong free space 2078097408 at (eval 16) line 53, <__ANONIO__> line 429.
cleaning up
killing machine (pid 596)
builder for '/nix/store/0cbgj0hfrhm4q13ar9cr02lp8jni4ffx-vm-test-run-ec2-nixops-userdata.drv' failed with exit code 255
error: build of '/nix/store/0cbgj0hfrhm4q13ar9cr02lp8jni4ffx-vm-test-run-ec2-nixops-userdata.drv' failed

Copy link
Member

@fpletz fpletz left a 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?

@Mic92 Mic92 merged commit a6b97bd into NixOS:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants