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

btrfs-progs: add --subvol option to mkfs.btrfs #868

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

maharmstone
Copy link
Contributor

This patch adds a --subvol option, which tells mkfs.btrfs to create the specified directories as subvolumes.

Given a populated directory img, the command

$ mkfs.btrfs --rootdir img --subvol usr --subvol home --subvol home/username /dev/loop0

will create subvolumes usr and home within the FS root, and subvolume username within the home subvolume. It will fail if any of the directories do not yet exist.


This is version 6 of the patch; I figured it'd be easier doing things here rather on the mailing list, if we're using both.

I've incorporated Qu's suggestion that we can free the subvol list as we go along, and thus speed up iteration slightly. I've also changed it so that the --subvol value is again relative to the --rootdir rather than the working directory, which was this way because of a potential future patch allowing out-of-tree subvolumes.
I've discussed this with @DaanDeMeyer, who wants this for mkosi, and agreed that the best way to do "out-of-tree" subvolumes would be for a future --default-subvol option instead.

@maharmstone
Copy link
Contributor Author

Whoops, fixed test

@DaanDeMeyer
Copy link

I tested this systemd/systemd#33498 and it works perfectly

This patch adds a --subvol option, which tells mkfs.btrfs to create the
specified directories as subvolumes.

Given a populated directory img, the command

$ mkfs.btrfs --rootdir img --subvol usr --subvol home --subvol home/username /dev/loop0

will create subvolumes usr and home within the FS root, and subvolume
username within the home subvolume. It will fail if any of the
directories do not yet exist.

Signed-off-by: Mark Harmstone <[email protected]>
@maharmstone
Copy link
Contributor Author

New version including adding --subvol to mkfs.btrfs man page

Copy link
Collaborator

@adam900710 adam900710 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@adam900710 adam900710 merged commit 5e83c69 into kdave:devel Aug 14, 2024
@adam900710
Copy link
Collaborator

I've discussed this with @DaanDeMeyer, who wants this for mkosi, and agreed that the best way to do "out-of-tree" subvolumes would be for a future --default-subvol option instead.

Just a little curious about this future feature. Do you plan to add a new option "--default-subvolume" or something like that, so that you can specify a subvolume inside the rootdir as the default one, after filling the rootdir along with the subvolumes?

If so, that new "--default-subvolume" option should still rely on the current rootdir + subvolume mechanism, just a new offline way to set default subvolue.

And if that's the case, everything looks fine to me, including the future feature.

@maharmstone
Copy link
Contributor Author

I've discussed this with @DaanDeMeyer, who wants this for mkosi, and agreed that the best way to do "out-of-tree" subvolumes would be for a future --default-subvol option instead.

Just a little curious about this future feature. Do you plan to add a new option "--default-subvolume" or something like that, so that you can specify a subvolume inside the rootdir as the default one, after filling the rootdir along with the subvolumes?

If so, that new "--default-subvolume" option should still rely on the current rootdir + subvolume mechanism, just a new offline way to set default subvolue.

And if that's the case, everything looks fine to me, including the future feature.

Yes, that's right

@Conan-Kudo
Copy link
Contributor

FYI @schaefi, we probably want to use this in kiwi too!

kdave pushed a commit that referenced this pull request Aug 14, 2024
Add a new option --subvol, which tells mkfs.btrfs to create the
specified directories as subvolumes when used with --rootdir.

Given a populated directory dir, the command

  $ mkfs.btrfs --rootdir dir --subvol usr --subvol home --subvol home/username img

will create subvolumes 'usr' and 'home' within the toplevel subvolume,
and subvolume 'username' within the 'home' subvolume. It will fail if
any of the directories do not yet exist.

Pull-request: #868
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Mark Harmstone <[email protected]>
Signed-off-by: David Sterba <[email protected]>
kdave pushed a commit that referenced this pull request Aug 15, 2024
Add a new option --subvol, which tells mkfs.btrfs to create the
specified directories as subvolumes when used with --rootdir.

Given a populated directory dir, the command

  $ mkfs.btrfs --rootdir dir --subvol usr --subvol home --subvol home/username img

will create subvolumes 'usr' and 'home' within the toplevel subvolume,
and subvolume 'username' within the 'home' subvolume. It will fail if
any of the directories do not yet exist.

Pull-request: #868
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Mark Harmstone <[email protected]>
Signed-off-by: David Sterba <[email protected]>
@kdave kdave added this to the v6.11 milestone Aug 21, 2024
kdave pushed a commit that referenced this pull request Sep 17, 2024
Add a new option --subvol, which tells mkfs.btrfs to create the
specified directories as subvolumes when used with --rootdir.

Given a populated directory dir, the command

  $ mkfs.btrfs --rootdir dir --subvol usr --subvol home --subvol home/username img

will create subvolumes 'usr' and 'home' within the toplevel subvolume,
and subvolume 'username' within the 'home' subvolume. It will fail if
any of the directories do not yet exist.

Pull-request: #868
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Mark Harmstone <[email protected]>
Signed-off-by: David Sterba <[email protected]>
@kdave kdave modified the milestones: v6.11, v6.12 Sep 17, 2024
kdave pushed a commit that referenced this pull request Nov 8, 2024
Add a new option --subvol, which tells mkfs.btrfs to create the
specified directories as subvolumes when used with --rootdir.

Given a populated directory dir, the command

  $ mkfs.btrfs --rootdir dir --subvol usr --subvol home --subvol home/username img

will create subvolumes 'usr' and 'home' within the toplevel subvolume,
and subvolume 'username' within the 'home' subvolume. It will fail if
any of the directories do not yet exist.

Pull-request: #868
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Mark Harmstone <[email protected]>
Signed-off-by: David Sterba <[email protected]>
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.

5 participants