return ($os_size, $osdev, $efibootdev);
}
+sub get_pv_list_from_vgname {
+ my ($vgname) = @_;
+
+ my $res;
+
+ my $parser = sub {
+ my $line = shift;
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ return if !$line;
+ my ($pv, $vg_uuid) = split(/\s+/, $line);
+
+ if (!defined($res->{$vg_uuid}->{pvs})) {
+ $res->{$vg_uuid}->{pvs} = "$pv";
+ } else {
+ $res->{$vg_uuid}->{pvs} .= ", $pv";
+ }
+ };
+ run_command("pvs --noheadings -o pv_name,vg_uuid -S vg_name='$vgname'", $parser, undef, 1);
+
+ return $res;
+}
+
+sub ask_existing_vg_rename_or_abort {
+ my ($vgname) = @_;
+
+ # this normally only happens if one put a disk with a PVE installation in
+ # this server and that disk is not the installation target.
+ my $duplicate_vgs = get_pv_list_from_vgname($vgname);
+ return if !$duplicate_vgs;
+
+ my $message = "Detected existing '$vgname' Volume Group(s)! Do you want to:\n";
+
+ for my $vg_uuid (keys %$duplicate_vgs) {
+ my $vg = $duplicate_vgs->{$vg_uuid};
+
+ # no high randomnes properties, but this is only for the cases where
+ # we either have multiple "$vgname" vgs from multiple old PVE disks, or
+ # we have a disk with both a "$vgname" and "$vgname-old"...
+ my $short_uid = sprintf "%08X", rand(0xffffffff);
+ $vg->{new_vgname} = "$vgname-OLD-$short_uid";
+
+ $message .= "rename VG backed by PV '$vg->{pvs}' to '$vg->{new_vgname}'\n";
+ }
+ $message .= "or cancel the installation?";
+
+ my $dialog = Gtk3::MessageDialog->new($window, 'modal', 'question', 'ok-cancel', $message);
+ my $response = $dialog->run();
+ $dialog->destroy();
+
+ if ($response eq 'ok') {
+ for my $vg_uuid (keys %$duplicate_vgs) {
+ my $vg = $duplicate_vgs->{$vg_uuid};
+ my $new_vgname = $vg->{new_vgname};
+
+ syscmd("vgrename $vg_uuid $new_vgname") == 0 ||
+ die "could not rename VG from '$vg->{pvs}' ($vg_uuid) to '$new_vgname'!\n";
+ }
+ } else {
+ set_next("_Reboot", sub { exit (0); } );
+ display_html("fail.htm");
+ die "Cancled installation by user, due to already existing volume group '$vgname'\n";
+ }
+}
+
sub create_lvm_volumes {
my ($lvmdev, $os_size, $swap_size) = @_;
my $vgname = $setup->{product};
+ ask_existing_vg_rename_or_abort($vgname);
+
my $rootdev = "/dev/$vgname/root";
my $datadev = "/dev/$vgname/data";
my $swapfile;
File::Path::make_path("$targetdir/$espmp/EFI/proxmox") ||
die "unable to create directory $targetdir/$espmp/EFI/proxmox\n";
- syscmd("chroot $targetdir bootctl --no-variables --path /$espmp install") == 0 ||
+ syscmd("chroot $targetdir bootctl --path /$espmp install") == 0 ||
die "unable to install systemd-boot loader\n";
write_config("timeout 3\ndefault proxmox-*\n",
"$targetdir/$espmp/loader/loader.conf");
die "unable to mount proc on $targetdir/proc\n";
syscmd("mount -n -t sysfs sysfs $targetdir/sys") == 0 ||
die "unable to mount sysfs on $targetdir/sys\n";
+ if ($boot_type eq 'efi') {
+ syscmd("mount -n -t efivarfs efivarfs $targetdir/sys/firmware/efi/efivars") == 0 ||
+ die "unable to mount efivarfs on $targetdir/sys/firmware/efi/efivars: $!\n";
+ }
syscmd("chroot $targetdir mount --bind /mnt/hostrun /run") == 0 ||
die "unable to re-bindmount hostrun on /run in chroot\n";
diversion_add($targetdir, "/usr/sbin/update-grub", "/bin/true");
diversion_add($targetdir, "/usr/sbin/update-initramfs", "/bin/true");
+ my $machine_id = run_command("systemd-id128 new");
+ die "unable to create a new machine-id\n" if ! $machine_id;
+ write_config($machine_id, "$targetdir/etc/machine-id");
+
+ syscmd("cp /etc/hostid $targetdir/etc/") == 0 ||
+ die "unable to copy hostid\n";
+
syscmd("touch $targetdir/proxmox_install_mode");
my $grub_install_devices_txt = '';
syscmd("umount $targetdir/mnt/hostrun");
syscmd("umount $targetdir/tmp");
syscmd("umount $targetdir/proc");
+ syscmd("umount $targetdir/sys/firmware/efi/efivars");
syscmd("umount $targetdir/sys");
if ($use_zfs) {
if (int($total_memory) < 1024) {
my $fullname = $product_fullname->{$setup->{product}};
- display_error("Less than 1 GiB memory detected, installation will probably fail.\n\n".
+ display_error("Less than 1 GiB of usable memory detected, installation will probably fail.\n\n".
"See 'System Requirements' in the $fullname documentation.");
}