Skip to content

Commit

Permalink
do not call mkfs multiple times for btrfs with multiple subvolumes in…
Browse files Browse the repository at this point in the history
… one partition

There is another bug in setup-storage that strikes with almost the same
configuration as above, but when using for example raid1 instead of
single. In that case, mkfs.btrfs is called several times on the same
raid devices, so that previously created subvolumes get lost. This is
because, in contrast to single device btrfs filesystems, setup-storage
does not check for raid if the highest level filesystem already exists.
  • Loading branch information
Christoph Pleger authored and Mrfai committed Dec 23, 2022
1 parent 6ed247f commit 369b6f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/setup-storage/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,12 @@ sub build_btrfs_commands {
$mkfs_done{join(" ", @devs)} = '1';
}
} else {
$btrfs_tool = "mkfs.btrfs -d raid$raidlevel $createopts ".join(" ",@devs);
if (exists $mkfs_done{join(" ", sort @devs)}) {
$btrfs_tool = "true";
} else {
$btrfs_tool = "mkfs.btrfs -d raid$raidlevel $createopts ".join(" ", sort @devs);
$mkfs_done{join(" ", sort @devs)} = '1';
}
}

# nothing more to do if we need to proserve this volume. No mkfs, no subvolume
Expand All @@ -394,7 +399,7 @@ sub build_btrfs_commands {
"btrfs_created_$initial_subvolume");

# unmounting the device itself
&FAI::push_command("umount $devs[0]",
&FAI::push_command("umount /mnt",
"btrfs_created_$initial_subvolume",
"");
}
Expand Down

0 comments on commit 369b6f9

Please sign in to comment.