Skip to content

Commit

Permalink
👷 disk: refactor zfs pool creation using gucc
Browse files Browse the repository at this point in the history
  • Loading branch information
vnepogodin committed Jan 5, 2025
1 parent 6ba8050 commit 09f9d29
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,17 @@ bool zfs_create_zpool(const std::string_view& partition, const std::string_view&
static constexpr auto zpool_options{"-f -o ashift=12 -o autotrim=on -O acltype=posixacl -O compression=zstd -O atime=off -O relatime=off -O normalization=formD -O xattr=sa -O mountpoint=none"sv};

#ifdef NDEVENV
std::int32_t ret_code{};
std::string device_path{partition};

// Find the UUID of the partition
const auto& partuuid = gucc::utils::exec(fmt::format(FMT_COMPILE("lsblk -lno PATH,PARTUUID | grep \"^{}\" | {}"), partition, "awk '{print $2}'"sv), false);

// See if the partition has a partuuid, if not use the device name
const auto& zfs_zpool_cmd = fmt::format(FMT_COMPILE("zpool create {} {}"), zpool_options, pool_name);
if (!partuuid.empty()) {
ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partuuid), true));
spdlog::info("Creating zpool {} on device {} using partuuid {}", pool_name, partition, partuuid);
} else {
ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partition), true));
spdlog::info("Creating zpool {} on device {}", pool_name, partition);
device_path = partuuid;
}

if (ret_code != 0) {
if (!gucc::fs::zfs_create_zpool(device_path, pool_name, zpool_options)) {
spdlog::error("Failed to create zpool!");
return false;
}
Expand Down

0 comments on commit 09f9d29

Please sign in to comment.