[pbs-devel] [PATCH proxmox-backup v2 6/6] tools: prohibit disk wipe of EFI partition

Markus Frank m.frank at proxmox.com
Tue Nov 28 11:39:59 CET 2023


Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
This patch is based on a suggestion by Dominik.
I am not so sure if we should prohibit wiping EFI partitions.
Any opinions on this?

 src/tools/disks/mod.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 51919f9e..34ace7d6 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -39,6 +39,8 @@ lazy_static::lazy_static! {
         regex::Regex::new(r"host[^/]*/session[^/]*").unwrap();
 }
 
+const EFI_PARTITION_TYPE: &str = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b";
+
 /// Disk management context.
 ///
 /// This provides access to disk information with some caching for faster querying of multiple
@@ -1080,6 +1082,12 @@ pub fn wipe_blockdev(disk: &Disk, worker: Arc<WorkerTask>) -> Result<(), Error>
     for disk_info in get_lsblk_info()?.iter() {
         if disk_info.path == disk_path_str && disk_info.partition_type.is_some() {
             is_partition = true;
+            if matches!(
+                disk_info.partition_type.as_deref(),
+                Some(EFI_PARTITION_TYPE)
+            ) {
+                bail!("You will not be able to boot if you wipe the EFI partition.");
+            }
         }
     }
 
-- 
2.39.2






More information about the pbs-devel mailing list