Skip to content

Commit

Permalink
install: Warn if we're not installing to gpt
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cgwalters committed Jul 23, 2024
1 parent 8fb489f commit 71d3435
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/src/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,18 @@ pub(crate) struct Partition {
pub(crate) name: Option<String>,
}

#[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
Expand Down
12 changes: 12 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,18 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
// Drop exclusive ownership since we're done with mutation
let rootfs = &*rootfs;

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()?
Expand Down

0 comments on commit 71d3435

Please sign in to comment.