Skip to content

Commit 71d3435

Browse files
committed
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 <[email protected]>
1 parent 8fb489f commit 71d3435

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/src/blockdev.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,18 @@ pub(crate) struct Partition {
138138
pub(crate) name: Option<String>,
139139
}
140140

141+
#[derive(Debug, Deserialize, PartialEq, Eq)]
142+
#[serde(rename_all = "kebab-case")]
143+
pub(crate) enum PartitionType {
144+
Dos,
145+
Gpt,
146+
Unknown(String),
147+
}
148+
141149
#[derive(Debug, Deserialize)]
142150
#[allow(dead_code)]
143151
pub(crate) struct PartitionTable {
144-
pub(crate) label: String,
152+
pub(crate) label: PartitionType,
145153
pub(crate) id: String,
146154
pub(crate) device: String,
147155
// We're not using these fields

lib/src/install.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,18 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
13381338
// Drop exclusive ownership since we're done with mutation
13391339
let rootfs = &*rootfs;
13401340

1341+
match &rootfs.device_info.label {
1342+
crate::blockdev::PartitionType::Dos => crate::utils::medium_visibility_warning(
1343+
"Installing to `dos` format partitions is not recommended",
1344+
),
1345+
crate::blockdev::PartitionType::Gpt => {
1346+
// The only thing we should be using in general
1347+
}
1348+
crate::blockdev::PartitionType::Unknown(o) => {
1349+
crate::utils::medium_visibility_warning(&format!("Unknown partition label {o}"))
1350+
}
1351+
}
1352+
13411353
// We verify this upfront because it's currently required by bootupd
13421354
let boot_uuid = rootfs
13431355
.get_boot_uuid()?

0 commit comments

Comments
 (0)