feat: delete ext2_saved subvolume after btrfs-convert

Removes the ext2_saved subvolume (created by btrfs-convert to preserve
original ext4 metadata) before running defrag to reclaim space.
This commit is contained in:
Aiden McClelland
2026-03-26 23:37:41 -06:00
parent f8efd6e6be
commit 8401b753fb

View File

@@ -344,12 +344,17 @@ pub async fn mount_fs<P: AsRef<Path>>(
.arg(&blockdev_path)
.invoke(ErrorKind::DiskManagement)
.await?;
// Defragment after conversion for optimal performance
// Delete ext2_saved subvolume and defragment after conversion
let tmp_mount = datadir.as_ref().join(format!("{name}.convert-tmp"));
tokio::fs::create_dir_all(&tmp_mount).await?;
BlockDev::new(&blockdev_path)
.mount(&tmp_mount, ReadWrite)
.await?;
Command::new("btrfs")
.args(["subvolume", "delete"])
.arg(tmp_mount.join("ext2_saved"))
.invoke(ErrorKind::DiskManagement)
.await?;
Command::new("btrfs")
.args(["filesystem", "defragment", "-r"])
.arg(&tmp_mount)