koverstreet / bcachefs-tools

http://bcachefs.org
GNU General Public License v2.0
122 stars 90 forks source link

RFE: mkfs.bcachefs should support populating the file system from a directory #164

Open keszybz opened 1 year ago

keszybz commented 1 year ago

For example, mkfs.ext4 has -d which takes a directory to use the files from, mkfs.btrfs has the equivalent under -r.

This is extremely useful because it allows file system images to be created from unprivileged userspace, without access to block devices, for example in containers. https://github.com/systemd/mkosi uses this to build images without requiring privileges.

It would be great if compression was supported. mkfs.btrfs currently does not allow compression when the file system is created in this way, which makes images painfully large.

/cc @DaanDeMeyer

koverstreet commented 1 year ago

cmd_migrate already has code that could be tweaked for this

On Fri, Sep 15, 2023, 5:30 PM Zbigniew Jędrzejewski-Szmek < @.***> wrote:

For example, mkfs.ext4 has -d which takes a directory to use the files from, mkfs.btrfs has the equivalent under -r.

This is extremely useful because it allows file system images to be created from unprivileged userspace, without access to block devices, for example in containers. https://github.com/systemd/mkosi uses this to build images without requiring privileges.

It would be great if compression was supported. mkfs.btrfs currently does not allow compression when the file system is created in this way, which makes images painfully large.

/cc @DaanDeMeyer https://github.com/DaanDeMeyer

— Reply to this email directly, view it on GitHub https://github.com/koverstreet/bcachefs-tools/issues/164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPGX3QQHUGNXXK2OSPNV23X2RYCPANCNFSM6AAAAAA4Z7OPEY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DaanDeMeyer commented 1 year ago

Would also be amazing to add support for making specific directories in the root directory subvolumes before they are populated with files from the root directory using an option such as --subvol "DIR"

MatthewCroughan commented 3 months ago

This feature would be needed in order to build disk images with systemd-repart, without requiring a loopback device. Currently since this option isn't available https://github.com/systemd/systemd/blob/main/src/partition/repart.c#L6736-L6740 is hit. But once this flag is added, it can be added to the list of FS that support this option here https://github.com/systemd/systemd/blob/main/src/shared/mkfs-util.c#L46-L48