Skip to content

Commit

Permalink
Merge pull request #709 from cgwalters/warn-install-non-gpt
Browse files Browse the repository at this point in the history
install: Warn if we're not installing to gpt
  • Loading branch information
cgwalters authored Jul 23, 2024
2 parents 0305ace + 71d3435 commit 2a64b84
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 2a64b84

Please sign in to comment.