1
0
mirror of https://gitlab.gnome.org/GNOME/gparted synced 2024-07-02 15:58:47 +00:00

Add bcachefs growing (!123)

Shrinking a bcachefs file system is not supported.
    # truncate -s $((1*1024*1024*1024)) /tmp/disk.img
    # losetup --find --show /tmp/disk.img
    /dev/loop0
    # bcachefs format /dev/loop0
    ...
    # bcachefs device resize /dev/loop0 $((1*1024*1024*1024 - 512))
    Doing offline resize of /dev/loop0
    mounting version 1.4: member_seq
    initializing new filesystem
    going read-write
    initializing freespace
    Shrinking not supported yet
    # echo $?
    1

Growing a bcachefs file system is supported when unmounted.
    # truncate -s $((2*1024*1024*1024)) /tmp/disk.img
    # losetup --set-capacity /dev/loop0
    # bcachefs device resize /dev/loop0
    Doing offline resize of /dev/loop0
    mounting version 1.6: btree_subvolume_children
    recovering from unclean shutdown
    journal read done, replaying entries 1-1
    alloc_read... done
    stripes_read... done
    snapshots_read... done
    going read-write
    journal_replay... done
    resume_logged_ops... done
    delete_dead_inodes... done
    resizing /dev/loop0 to 16384 buckets
    # echo $?
    0
    # bcachefs show-super /dev/loop0 | egrep 'Device:|Size:'
    Device:                                     0
      Size:                                     2.00 GiB

Growing is also supported when mounted.
    # mount /dev/loop0 /mnt/0
    # truncate -s $((3*1024*1024*1024)) /tmp/disk.img
    # losetup --set-capacity /dev/loop0
    # bcachefs device resize /dev/loop0
    Doing online resize of /dev/loop0
    resizing /dev/loop0 to 24576 buckets
    # echo $?
    0
    # bcachefs show-super /dev/loop0 | egrep 'Device:|Size:'
    Device:                                     0
      Size:                                     3.00 GiB

Closes !123 - Add support for bcachefs, single device file systems only
This commit is contained in:
Mike Fleetwood 2024-03-17 08:03:50 +00:00
parent f027809e73
commit 31df2f2b75
2 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,7 @@ public:
bool create(const Partition& new_partition, OperationDetail& operationdetail);
void read_label(Partition& partition);
void read_uuid(Partition& partition);
bool resize(const Partition& partition_new, OperationDetail& operationdetail, bool fill_partition);
};

View File

@ -45,6 +45,11 @@ FS bcachefs::get_filesystem_support()
fs.create_with_label = FS::EXTERNAL;
fs.read_label = FS::EXTERNAL;
fs.read_uuid = FS::EXTERNAL;
fs.grow = FS::EXTERNAL;
#ifdef ENABLE_ONLINE_RESIZE
if (Utils::kernel_version_at_least(3, 6, 0))
fs.online_grow = FS::EXTERNAL;
#endif
}
fs_limits.min_size = 32 * MEBIBYTE;
@ -131,4 +136,11 @@ void bcachefs::read_uuid(Partition& partition)
}
bool bcachefs::resize(const Partition& partition_new, OperationDetail& operationdetail, bool fill_partition)
{
return ! execute_command("bcachefs device resize " + Glib::shell_quote(partition_new.get_path()),
operationdetail, EXEC_CHECK_STATUS);
}
} //GParted