Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install: Warn if we're not installing to gpt #709

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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