From f1bc0b1dcd9606dc234de06c312ec66895e7a255 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 18 Jul 2024 11:00:04 -0400 Subject: [PATCH] install: Warn if we're not installing to gpt I am not aware of any reason to use anything else; in theory we can leave this up to the OS, but...I think using `dos` format is really probably just a legacy mistake now. And if we see anything else...well, let's at least warn. Signed-off-by: Colin Walters --- lib/src/blockdev.rs | 10 +++++++++- lib/src/install.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/src/blockdev.rs b/lib/src/blockdev.rs index f0d08e117..29c7d871a 100644 --- a/lib/src/blockdev.rs +++ b/lib/src/blockdev.rs @@ -141,10 +141,18 @@ pub(crate) struct Partition { pub(crate) name: Option, } +#[derive(Debug, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "kebab-case")] +pub(crate) enum PartitionType { + Dos, + Gpt, + Unknown(String), +} + #[derive(Debug, Deserialize)] #[allow(dead_code)] pub(crate) struct PartitionTable { - pub(crate) label: String, + pub(crate) label: PartitionType, pub(crate) id: String, pub(crate) device: String, // We're not using these fields diff --git a/lib/src/install.rs b/lib/src/install.rs index d23f8198d..acf3e83c9 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -1216,6 +1216,18 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re rootfs.kargs.push("selinux=0".to_string()); } + match &rootfs.device_info.label { + crate::blockdev::PartitionType::Dos => crate::utils::medium_visibility_warning( + "Installing to `dos` format partitions is not recommended", + ), + crate::blockdev::PartitionType::Gpt => { + // The only thing we should be using in general + } + crate::blockdev::PartitionType::Unknown(o) => { + crate::utils::medium_visibility_warning(&format!("Unknown partition label {o}")) + } + } + // We verify this upfront because it's currently required by bootupd let boot_uuid = rootfs .get_boot_uuid()?