[pve-devel] [PATCH installer 4/6] warn on existing rpool if installing on ZFS

Stoiko Ivanov s.ivanov at proxmox.com
Fri Nov 29 11:53:46 CET 2019


Having two pools named rpool leads to an unbootable system.
This can happen if reusing an old diks, which is not selected during the
initial installation.

Warn the user accordingly and give them the option to abort the installation.
The pool is not renamed (as we do for the LVM-case with VGs named pve), since
this would fail if the pool is not importable (e.g. user added only one old
disk from a RAIDZ install to that system.
The alternative of running `zpool labelclear` would potentially destroy data.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 proxinstall | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/proxinstall b/proxinstall
index 47faa09..d2abdcd 100755
--- a/proxinstall
+++ b/proxinstall
@@ -3326,6 +3326,7 @@ sub create_hdsel_view {
 	    }
 	    $config_options->{target_hds} = [ map { $_->[1] } @$devlist ];
 	    $unused = get_unused_bdevs($config_options->{target_hds});
+	    warn_existing_rpool_ignore_or_abort($unused);
 	} elsif ($config_options->{filesys} =~ m/btrfs/) {
 	    my ($devlist) = eval { get_btrfs_raid_setup() };
 	    if (my $err = $@) {
@@ -3393,6 +3394,32 @@ EOF
     ask_existing_diskconfig_or_abort($message, "existing ESPs");
 }
 
+sub warn_existing_rpool_ignore_or_abort {
+    my ($unused_devs) = @_;
+
+    my $is_rpool = sub {
+	my ($bdev) = $_;
+	if (($bdev->{parttype} eq '6a898cc3-1dd2-11b2-99a6-080020736631') &&
+	    ($bdev->{label} eq 'rpool')) {
+	    return ( $bdev->{path} );
+	}
+	return ();
+    };
+
+    my @rpools = map { $is_rpool->($_) } @$unused_devs;
+    return if !scalar(@rpools);
+
+    my $message = "Detected existing ZFS Pool(s) named rpool:\n- " . join("\n- ", @rpools);
+    $message .= <<'EOF';
+
+
+This could prevent correct booting!
+Do you want to ignore or cancel the installation?
+EOF
+
+    ask_existing_diskconfig_or_abort($message, "existing rpools");
+}
+
 sub ask_existing_diskconfig_or_abort {
     my ($message, $fail_reason, $ok_action) = @_;
 
-- 
2.20.1





More information about the pve-devel mailing list