]> git.proxmox.com Git - pve-installer.git/blobdiff - proxinstall
install module: getters: correctly use plural in error messages
[pve-installer.git] / proxinstall
index 0b396f748dd43aba8f3d561ab368df2dfb149673..a6a4cfb55e4ae463ca2238f8f546c827c5c24465 100755 (executable)
 use strict;
 use warnings;
 
-use Getopt::Long;
-use IPC::Open2;
-use IO::File;
-use Cwd 'abs_path';
-use Glib;
-use Gtk3;
-use Gtk3::WebKit2;
-use Encode;
-use File::Basename;
-use File::Path;
-use Time::HiRes;
-use POSIX ":sys_wait_h";
-
-use Proxmox::Log;
-Proxmox::Log::init("/tmp/install.log");
-
-{ # NOTE: order is important here
-    my $test_image;
-    GetOptions(
-       'test-image|t=s' => \$test_image
-    ) or die "usage error\n";
-
-    Proxmox::Install::ISOEnv::set_test_image($test_image) if $test_image;
-}
-
-
-use Proxmox::Install::ISOEnv;
-use Proxmox::Install::RunEnv;
-
-# init singletons
-my $iso_env = Proxmox::Install::ISOEnv::get();
-my $run_env = Proxmox::Install::RunEnv::get();
-
-use Proxmox::Install::Config;
-use Proxmox::Install::StorageConfig;
-
-use Proxmox::Sys::Block qw(get_cached_disks wipe_disk partition_bootable_disk);
-use Proxmox::Sys::Command qw(run_command syscmd);
-use Proxmox::Sys::File qw(file_read_firstline file_read_all file_write_all);
-use Proxmox::Sys::Net qw(parse_ip_address parse_ip_mask);
-use Proxmox::UI;
-
-if (!$ENV{G_SLICE} ||  $ENV{G_SLICE} ne "always-malloc") {
-    die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
-}
-
-my $proxmox_libdir = $iso_env->{locations}->{lib};
-my $proxmox_cddir = $iso_env->{locations}->{iso};
-my $proxmox_pkgdir = "${proxmox_cddir}/proxmox/packages/";
-
-my $step_number = 0; # Init number for global function list
-
-my @steps = (
-    {
-       step => 'intro',
-       html => 'license.htm',
-       next_button => 'I a_gree',
-       function => \&create_intro_view,
-    },
-    {
-       step => 'intro',
-       html => 'page1.htm',
-       function => \&create_hdsel_view,
-    },
-    {
-       step => 'country',
-       html => 'country.htm',
-       function => \&create_country_view,
-    },
-    {
-       step => 'password',
-       html => 'passwd.htm',
-       function => \&create_password_view,
-    },
-    {
-       step => 'ipconf',
-       html => 'ipconf.htm',
-       function => \&create_ipconf_view,
-    },
-    {
-       step => 'ack',
-       html => 'ack.htm',
-       next_button => '_Install',
-       function => \&create_ack_view,
-    },
-    {
-       step => 'extract',
-       next_button => '_Reboot',
-       function => \&create_extract_view,
-    },
-);
-
-# GUI global variables
-my $gtk_state = {};
-
-my $target_hd;
-
-my ($ipversion, $ipaddress, $cidr, $ipconf_entry_addr);
-my ($netmask, $ipconf_entry_mask);
-my ($gateway, $ipconf_entry_gw);
-my ($dnsserver, $ipconf_entry_dns);
-my $hostname = 'proxmox';
-my $domain = 'domain.tld';
-my $ipconf;
-my $country = $run_env->{country};
-my $timezone = 'Europe/Vienna';
-my $keymap = 'en-us';
-my $password;
-my $mailto = 'mail@example.invalid';
-my $autoreboot_seconds = 5;
-
-# TODO: single source of config state
-my $config = {
-    # TODO: add all the user-provided options for previous button
-    country => $country,
-    timezone => $timezone,
-    keymap => $keymap,
-
-    password => $password,
-    mailto => $mailto,
-
-    mngmt_nic => undef,
-    hostname => $hostname,
-    fqdn => undef,
-    ipaddress => undef,
-    netmask => undef,
-    gateway => undef,
-};
-
-my $config_options = Proxmox::Install::Config::parse_kernel_cmdline();
-
-my $postfix_main_cf = <<_EOD;
-# See /usr/share/postfix/main.cf.dist for a commented, more complete version
-
-myhostname=__FQDN__
-
-smtpd_banner = \$myhostname ESMTP \$mail_name (Debian/GNU)
-biff = no
-
-# appending .domain is the MUA's job.
-append_dot_mydomain = no
-
-# Uncomment the next line to generate "delayed mail" warnings
-#delay_warning_time = 4h
-
-alias_maps = hash:/etc/aliases
-alias_database = hash:/etc/aliases
-mydestination = \$myhostname, localhost.\$mydomain, localhost
-relayhost =
-mynetworks = 127.0.0.0/8
-inet_interfaces = loopback-only
-recipient_delimiter = +
-
-compatibility_level = 2
-
-_EOD
-
-
-sub app_quit {
-    my ($exit_code) = @_;
-
-    Gtk3->main_quit() if Gtk3->main_level() > 0;
-
-    # reap left over zombie processes
-    while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) {
-       print STDERR "reaped child $child\n";
-    }
-    exit($exit_code);
-}
-
-sub update_progress {
-    my ($frac, $start, $end, $text) = @_;
-
-    my $res = Proxmox::UI::progress($frac, $start, $end, $text);
-
-    display_info() if $res < 0.9;
-
-    Proxmox::UI::process_events();
-}
-
-my $fssetup = {
-    ext4 => {
-       mkfs => 'mkfs.ext4 -F',
-       mkfs_root_opt => '',
-       mkfs_data_opt => '-m 0',
-       root_mountopt => 'errors=remount-ro',
-    },
-    xfs => {
-       mkfs => 'mkfs.xfs -f',
-       mkfs_root_opt => '',
-       mkfs_data_opt => '',
-       root_mountopt => '',
-    },
-};
-
-sub create_filesystem {
-    my ($dev, $name, $type, $start, $end, $fs, $fe) = @_;
-
-    my $range = $end - $start;
-    my $rs = $start + $range*$fs;
-    my $re = $start + $range*$fe;
-    my $max = 0;
-
-    my $fsdata = $fssetup->{$type} || die "internal error - unknown file system '$type'";
-    my $opts = $name eq 'root' ? $fsdata->{mkfs_root_opt} : $fsdata->{mkfs_data_opt};
-
-    update_progress(0, $rs, $re, "creating $name filesystem");
-
-    run_command("$fsdata->{mkfs} $opts $dev", sub {
-       my $line = shift;
-
-       if ($line =~ m/Writing inode tables:\s+(\d+)\/(\d+)/) {
-           $max = $2;
-       } elsif ($max && $line =~ m/(\d+)\/$max/) {
-           update_progress(($1/$max)*0.9, $rs, $re);
-       } elsif ($line =~ m/Creating journal.*done/) {
-           update_progress(0.95, $rs, $re);
-       } elsif ($line =~ m/Writing superblocks and filesystem.*done/) {
-           update_progress(1, $rs, $re);
-       }
-    });
-}
-
-sub debconfig_set {
-    my ($targetdir, $dcdata) = @_;
-
-    my $cfgfile = "/tmp/debconf.txt";
-    file_write_all("$targetdir/$cfgfile", $dcdata);
-    syscmd("chroot $targetdir debconf-set-selections $cfgfile");
-    unlink "$targetdir/$cfgfile";
-}
-
-sub diversion_add {
-    my ($targetdir, $cmd, $new_cmd) = @_;
-
-    syscmd("chroot $targetdir dpkg-divert --package proxmox --add --rename $cmd") == 0
-        || die "unable to exec dpkg-divert\n";
-
-    syscmd("ln -sf ${new_cmd} $targetdir/$cmd") == 0
-        || die "unable to link diversion to ${new_cmd}\n";
-}
-
-sub diversion_remove {
-    my  ($targetdir, $cmd) = @_;
-
-    syscmd("mv $targetdir/${cmd}.distrib $targetdir/${cmd};") == 0
-        || die "unable to remove $cmd diversion\n";
-
-    syscmd("chroot $targetdir dpkg-divert --remove $cmd") == 0
-        || die "unable to remove $cmd diversion\n";
-}
-
-sub btrfs_create {
-    my ($partitions, $mode) = @_;
-
-    die "unknown btrfs mode '$mode'"
-       if !($mode eq 'single' || $mode eq 'raid0' || $mode eq 'raid1' || $mode eq 'raid10');
-
-    my $cmd = ['mkfs.btrfs', '-f'];
-
-    push @$cmd, '-d', $mode, '-m', $mode;
-
-    push @$cmd, @$partitions;
-
-    syscmd($cmd);
-}
-
-sub zfs_create_rpool {
-    my ($vdev, $pool_name, $root_volume_name) = @_;
-
-    my $cmd = "zpool create -f -o cachefile=none";
-
-    $cmd .= " -o ashift=$config_options->{ashift}"
-        if defined($config_options->{ashift});
-
-    syscmd("$cmd $pool_name $vdev") == 0 ||
-       die "unable to create zfs root pool\n";
-
-    syscmd("zfs create $pool_name/ROOT")  == 0 ||
-        die "unable to create zfs $pool_name/ROOT volume\n";
-
-    if ($iso_env->{product} eq 'pve') {
-       syscmd("zfs create $pool_name/data")  == 0 ||
-           die "unable to create zfs $pool_name/data volume\n";
-    }
-
-    syscmd("zfs create $pool_name/ROOT/$root_volume_name")  == 0 ||
-       die "unable to create zfs $pool_name/ROOT/$root_volume_name volume\n";
-
-    # default to `relatime` on, fast enough for the installer and production
-    syscmd("zfs set atime=on relatime=on $pool_name") == 0 ||
-       die "unable to set zfs properties\n";
-
-    my $value = $config_options->{compress};
-    syscmd("zfs set compression=$value $pool_name")
-        if defined($value) && $value ne 'off';
-
-    $value = $config_options->{checksum};
-    syscmd("zfs set checksum=$value $pool_name")
-        if defined($value) && $value ne 'on';
-
-    $value = $config_options->{copies};
-    syscmd("zfs set copies=$value $pool_name")
-        if defined($value) && $value != 1;
-}
-
-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 $response = Proxmox::UI::prompt($message);
-
-    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 {
-       warn "Canceled installation by user, due to already existing volume group '$vgname'\n";
-       die "\n"; # causes abort without re-showing an error dialogue
-    }
-}
-
-sub create_lvm_volumes {
-    my ($lvmdev, $os_size, $swap_size) = @_;
-
-    my $vgname = $iso_env->{product};
-
-    ask_existing_vg_rename_or_abort($vgname);
-
-    my $rootdev = "/dev/$vgname/root";
-    my $datadev = "/dev/$vgname/data";
-    my $swapfile;
-
-    # we use --metadatasize 250k, which results in "pe_start = 512"
-    # so pe_start is aligned on a 128k boundary (advantage for SSDs)
-    syscmd("/sbin/pvcreate --metadatasize 250k -y -ff $lvmdev") == 0 ||
-       die "unable to initialize physical volume $lvmdev\n";
-    syscmd("/sbin/vgcreate $vgname $lvmdev") == 0 ||
-       die "unable to create volume group '$vgname'\n";
-
-    my $hdgb = int($os_size / (1024 * 1024));
-
-    # always leave some space at the end to avoid roudning issues with LVM's physical extent (PE)
-    # size of 4 MB.
-    my $space = $hdgb <= 32 ? 4 * 1024 : (($hdgb > 128 ? 16 : $hdgb / 8) * 1024 * 1024);
-
-    my $rootsize;
-    my $datasize = 0;
-
-    if ($iso_env->{product} eq 'pve') {
-
-       my $maxroot_mb;
-       if ($config_options->{maxroot}) {
-           $maxroot_mb = $config_options->{maxroot} * 1024;
-       } else {
-           $maxroot_mb = 96 * 1024;
-       }
-
-       my $rest = $os_size - $swap_size;
-       my $rest_mb = int($rest / 1024);
-
-       my $rootsize_mb;
-       if ($rest_mb < 12 * 1024) {
-           # no point in wasting space, try to get us actually installed and align down to 4 MB
-           $rootsize_mb = ($rest_mb - 0.1) & ~3;
-       } elsif ($rest_mb < 48 * 1024) {
-           my $masked = int($rest_mb / 2) & ~3; # align down to 4 MB
-           $rootsize_mb = $masked;
-       } else {
-           $rootsize_mb = $rest_mb / 4 + 12 * 1024;
-       }
-
-       $rootsize_mb = $maxroot_mb if $rootsize_mb > $maxroot_mb;
-       $rootsize = int($rootsize_mb * 1024);
-
-       $rest -= $rootsize; # in KB
-
-       my $minfree = $space;
-       if (defined(my $cfg_minfree = $config_options->{minfree})) {
-           $minfree = $cfg_minfree * 1024 * 1024 >= $rest ? $space : $cfg_minfree * 1024 * 1024;
-       }
-
-       $rest = int($rest - $minfree) & ~0xFFF; # align down to 4 MB boundaries
-
-       if (defined(my $maxvz = $config_options->{maxvz})) {
-           $rest = $maxvz * 1024 * 1024 <= $rest ? $maxvz * 1024 * 1024 : $rest;
-       }
-
-       $datasize = $rest;
-
-    } else {
-       my $minfree = defined($config_options->{minfree}) ? $config_options->{minfree}*1024*1024 : $space;
-       $rootsize = int($os_size - $minfree - $swap_size); # in KB
-       $rootsize &= ~0xFFF; # align down to 4 MB boundaries
-    }
-
-    if ($swap_size) {
-       syscmd("/sbin/lvcreate -Wy --yes -L${swap_size}K -nswap $vgname") == 0 ||
-           die "unable to create swap volume\n";
-
-       $swapfile = "/dev/$vgname/swap";
-    }
-
-    syscmd("/sbin/lvcreate -Wy --yes -L${rootsize}K -nroot $vgname") == 0 ||
-       die "unable to create root volume\n";
-
-    if ($datasize > 4 * 1024 * 1024) {
-       my $metadatasize = $datasize/100; # default 1% of data
-       $metadatasize = 1024*1024 if $metadatasize < 1024*1024; # but at least 1G
-       $metadatasize = 16*1024*1024 if $metadatasize > 16*1024*1024; # but at most 16G
-
-       # otherwise the metadata is taken out of $minfree
-       $datasize -= 2 * $metadatasize;
-
-       # 1 4MB PE to allow for rounding
-       $datasize -= 4 * 1024;
-
-       syscmd("/sbin/lvcreate -Wy --yes -L${datasize}K -ndata $vgname") == 0 ||
-           die "unable to create data volume\n";
-
-       syscmd("/sbin/lvconvert --yes --type thin-pool --poolmetadatasize ${metadatasize}K $vgname/data") == 0 ||
-           die "unable to create data thin-pool\n";
-    } else {
-       if ($iso_env->{product} eq 'pve' && !defined($config_options->{maxvz})) {
-           Proxmox::UI::message("Skipping auto-creation of LVM thinpool for guest data due to low space.");
-       }
-       $datadev = undef;
-    }
-
-    syscmd("/sbin/vgchange -a y $vgname") == 0 ||
-       die "unable to activate volume group\n";
-
-    return ($rootdev, $swapfile, $datadev);
-}
-
-sub compute_swapsize {
-    my ($hdsize) = @_;
-
-    my $hdgb = int($hdsize/(1024*1024));
-
-    my $swapsize_kb;
-    if (defined($config_options->{swapsize})) {
-       $swapsize_kb = $config_options->{swapsize} * 1024 * 1024;
-    } else {
-       my $ss = int($run_env->{total_memory});
-       $ss = 4096 if $ss < 4096 && $hdgb >= 64;
-       $ss = 2048 if $ss < 2048 && $hdgb >= 32;
-       $ss = 1024 if $ss >= 2048 && $hdgb <= 16;
-       $ss = 512 if $ss < 512;
-       $ss = int($hdgb * 128) if $ss > $hdgb * 128;
-       $ss = 8192 if $ss > 8192;
-       $swapsize_kb = int($ss * 1024) & ~0xFFF; # align to 4 MB to avoid all to odd SWAP size
-    }
-
-    return $swapsize_kb;
-}
-
-my sub chroot_chown {
-    my ($root, $path, %param) = @_;
-
-    my $recursive = $param{recursive} ? ' -R' : '';
-    my $user = $param{user};
-    die "can not chown without user parameter\n" if !defined($user);
-    my $group = $param{group} // $user;
-
-    syscmd("chroot $root /bin/chown $user:$group $recursive $path") == 0 ||
-       die "chroot: unable to change owner for '$path'\n";
-}
-
-my sub chroot_chmod {
-    my ($root, $path, %param) = @_;
-
-    my $recursive = $param{recursive} ? ' -R' : '';
-    my $mode = $param{mode};
-    die "can not chmod without mode parameter\n" if !defined($mode);
-
-    syscmd("chroot $root /bin/chmod $mode $recursive $path") == 0 ||
-       die "chroot: unable to change permission mode for '$path'\n";
-}
-
-sub prepare_proxmox_boot_esp {
-    my ($espdev, $targetdir) = @_;
-
-    syscmd("chroot $targetdir proxmox-boot-tool init $espdev") == 0 ||
-       die "unable to init ESP and install proxmox-boot loader on '$espdev'\n";
-}
-
-sub prepare_grub_efi_boot_esp {
-    my ($dev, $espdev, $targetdir) = @_;
-
-    syscmd("mount -n $espdev -t vfat $targetdir/boot/efi") == 0 ||
-       die "unable to mount $espdev\n";
-
-    eval {
-       my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev");
-       if ($rc != 0) {
-           if ($run_env->{boot_type} eq 'efi') {
-               die "unable to install the EFI boot loader on '$dev'\n";
-           } else {
-               warn "unable to install the EFI boot loader on '$dev', ignoring (not booted using UEFI)\n";
-           }
-       }
-       # also install fallback boot file (OVMF does not boot without)
-       mkdir("$targetdir/boot/efi/EFI/BOOT");
-       syscmd("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 ||
-           die "unable to copy efi boot loader\n";
-    };
-    my $err = $@;
-
-    eval {
-       syscmd("umount $targetdir/boot/efi") == 0 ||
-           die "unable to umount $targetdir/boot/efi\n";
-    };
-    warn $@ if $@;
-
-    die "failed to prepare EFI boot using Grub on '$espdev': $err" if $err;
-}
-
-sub extract_data {
-    my ($basefile, $targetdir) = @_;
-
-    die "target '$targetdir' does not exist\n" if ! -d  $targetdir;
-
-    my $starttime = [Time::HiRes::gettimeofday];
-
-    my $bootdevinfo = [];
-
-    my ($swapfile, $rootdev, $datadev);
-    my ($use_zfs, $use_btrfs) = (0, 0);
-
-    my $filesys = $config_options->{filesys};
-
-    my $zfs_pool_name = Proxmox::Install::StorageConfig::get_zfs_pool_name();
-    my $zfs_root_volume_name = Proxmox::Install::StorageConfig::get_zfs_root_volume_name();
-
-    if ($filesys =~ m/zfs/) {
-       $target_hd = undef; # do not use this config
-       $use_zfs = 1;
-       $targetdir = "/$zfs_pool_name/ROOT/$zfs_root_volume_name";
-    } elsif ($filesys =~ m/btrfs/) {
-       $target_hd = undef; # do not use this config
-       $use_btrfs = 1;
-    }
-
-    if ($use_zfs) {
-       my $i;
-       for ($i = 5; $i > 0; $i--) {
-           syscmd("modprobe zfs");
-           last if -c "/dev/zfs";
-           sleep(1);
-       }
-
-       die "unable to load zfs kernel module\n" if !$i;
-    }
-
-    my $bootloader_err;
-
-    eval {
-       my $maxper = 0.25;
-
-       update_progress(0, 0, $maxper, "cleanup root-disks");
-
-       syscmd("vgchange -an") if !is_test_mode(); # deactivate all detected VGs
-
-       if (is_test_mode()) {
-
-           my $test_images = Proxmox::Install::ISOEnv::get_test_images();
-           $rootdev = abs_path($test_images->[0]); # FIXME: use all selected for test too!
-           syscmd("umount $rootdev");
-
-           if ($use_btrfs) {
-
-               die "unsupported btrfs mode (for testing environment)\n"
-                   if $filesys ne 'btrfs (RAID0)';
-
-               btrfs_create([$rootdev], 'single');
-
-           } elsif ($use_zfs) {
-
-               die "unsupported zfs mode (for testing environment)\n"
-                   if $filesys ne 'zfs (RAID0)';
-
-               syscmd("zpool destroy $zfs_pool_name");
-
-               zfs_create_rpool($rootdev, $zfs_pool_name, $zfs_root_volume_name);
-
-           } else {
-
-               # nothing to do
-           }
-
-       } elsif ($use_btrfs) {
-
-           my ($devlist, $btrfs_mode) = get_btrfs_raid_setup();
-
-           foreach my $hd (@$devlist) {
-               wipe_disk(@$hd[1]);
-           }
-
-           update_progress(0, 0.02, $maxper, "create partitions");
-
-           my $btrfs_partitions = [];
-           foreach my $hd (@$devlist) {
-               my $devname = @$hd[1];
-               my $logical_bsize = @$hd[4];
-
-               my ($size, $osdev, $efidev) = partition_bootable_disk(
-                   $devname, $config_options->{hdsize}, '8300');
-               $rootdev = $osdev if !defined($rootdev); # simply point to first disk
-               my $by_id = Proxmox::Sys::Block::get_disk_by_id_path($devname);
-               push @$bootdevinfo, {
-                   esp => $efidev,
-                   devname => $devname,
-                   osdev => $osdev,
-                   by_id => $by_id,
-                   logical_bsize => $logical_bsize,
-               };
-               push @$btrfs_partitions, $osdev;
-           }
-
-           Proxmox::Sys::Block::udevadm_trigger_block();
-
-           update_progress(0, 0.03, $maxper, "create btrfs");
-
-           btrfs_create($btrfs_partitions, $btrfs_mode);
-
-       } elsif ($use_zfs) {
-
-           my ($devlist, $vdev) = get_zfs_raid_setup();
-
-           foreach my $hd (@$devlist) {
-               wipe_disk(@$hd[1]);
-           }
-
-           update_progress(0, 0.02, $maxper, "create partitions");
-
-           # install esp/boot part on all, we can only win!
-           for my $hd (@$devlist) {
-               my $devname = @$hd[1];
-               my $logical_bsize = @$hd[4];
-
-               my ($size, $osdev, $efidev) =
-                   partition_bootable_disk($devname, $config_options->{hdsize}, 'BF01');
-
-               push @$bootdevinfo, {
-                   esp => $efidev,
-                   devname => $devname,
-                   osdev => $osdev,
-                   logical_bsize => $logical_bsize,
-               };
-           }
-
-           Proxmox::Sys::Block::udevadm_trigger_block();
-
-           foreach my $di (@$bootdevinfo) {
-               my $devname = $di->{devname};
-               $di->{by_id} = Proxmox::Sys::Block::get_disk_by_id_path($devname);
-
-               my $osdev = Proxmox::Sys::Block::get_disk_by_id_path($di->{osdev}) || $di->{osdev};
-
-               $vdev =~ s/ $devname/ $osdev/;
-           }
-
-           foreach my $hd (@$devlist) {
-               my $devname = @$hd[1];
-               my $by_id = Proxmox::Sys::Block::get_disk_by_id_path($devname);
-
-               $vdev =~ s/ $devname/ $by_id/ if $by_id;
-           }
-
-           update_progress(0, 0.03, $maxper, "create rpool");
-
-           zfs_create_rpool($vdev, $zfs_pool_name);
-
-       } else {
-
-           die "target '$target_hd' is not a valid block device\n" if ! -b $target_hd;
-
-           wipe_disk($target_hd);
-
-           update_progress(0, 0.02, $maxper, "create partitions");
-
-           my $logical_bsize = Proxmox::Sys::Block::logical_blocksize($target_hd);
-
-           my ($os_size, $osdev, $efidev) =
-               partition_bootable_disk($target_hd, $config_options->{hdsize}, '8E00');
-
-           Proxmox::Sys::Block::udevadm_trigger_block();
-
-           my $by_id = Proxmox::Sys::Block::get_disk_by_id_path($target_hd);
-           push @$bootdevinfo, {
-               esp => $efidev,
-               devname => $target_hd,
-               osdev => $osdev,
-               by_id => $by_id,
-               logical_bsize => $logical_bsize,
-           };
-
-           update_progress(0, 0.03, $maxper, "create LVs");
-
-           my $swap_size = compute_swapsize($os_size);
-           ($rootdev, $swapfile, $datadev) =
-               create_lvm_volumes($osdev, $os_size, $swap_size);
-
-           # trigger udev to create /dev/disk/by-uuid
-           Proxmox::Sys::Block::udevadm_trigger_block(1);
-       }
-
-       if ($use_zfs) {
-           # to be fast during installation
-           syscmd("zfs set sync=disabled $zfs_pool_name") == 0 ||
-               die "unable to set zfs properties\n";
-       }
-
-       update_progress(0.04, 0, $maxper, "create swap space");
-       if ($swapfile) {
-           syscmd("mkswap -f $swapfile") == 0 ||
-               die "unable to create swap space\n";
-       }
-
-       update_progress(0.045, 0, $maxper, "creating root filesystems");
-
-       foreach my $di (@$bootdevinfo) {
-           next if !$di->{esp};
-           # FIXME remove '-s1' once https://github.com/dosfstools/dosfstools/issues/111 is fixed
-           my $vfat_extra_opts = ($di->{logical_bsize} == 4096) ? '-s1' : '';
-           syscmd("mkfs.vfat $vfat_extra_opts -F32 $di->{esp}") == 0 ||
-               die "unable to initialize EFI ESP on device $di->{esp}\n";
-       }
-
-       if ($use_zfs) {
-           # do nothing
-       } elsif ($use_btrfs) {
-           # do nothing
-       } else {
-           create_filesystem($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
-       }
-
-       update_progress(1, 0.05, $maxper, "mounting target $rootdev");
-
-       if ($use_zfs) {
-           # do nothing
-       } else {
-           my $mount_opts = 'noatime';
-           $mount_opts .= ',nobarrier'
-               if $use_btrfs || $filesys =~ /^ext\d$/;
-
-           syscmd("mount -n $rootdev -o $mount_opts $targetdir") == 0 ||
-               die "unable to mount $rootdev\n";
-       }
-
-       mkdir "$targetdir/boot";
-       mkdir "$targetdir/boot/efi";
-
-       mkdir "$targetdir/var";
-       mkdir "$targetdir/var/lib";
-
-       if ($iso_env->{product} eq 'pve') {
-           mkdir "$targetdir/var/lib/vz";
-           mkdir "$targetdir/var/lib/pve";
-
-           if ($use_btrfs) {
-               syscmd("btrfs subvolume create $targetdir/var/lib/pve/local-btrfs") == 0 ||
-                   die "unable to create btrfs subvolume\n";
-           }
-       }
-
-       mkdir "$targetdir/mnt";
-       mkdir "$targetdir/mnt/hostrun";
-       syscmd("mount --bind /run $targetdir/mnt/hostrun") == 0 ||
-           die "unable to bindmount run on $targetdir/mnt/hostrun\n";
-
-       update_progress(1, 0.05, $maxper, "extracting base system");
-
-       my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat ($basefile);
-       $ino || die "unable to open file '$basefile' - $!\n";
-
-       my $files = file_read_firstline("${proxmox_cddir}/proxmox/$iso_env->{product}-base.cnt") ||
-           die "unable to read base file count\n";
-
-       my $per = 0;
-       my $count = 0;
-
-       run_command("unsquashfs -f -dest $targetdir -i $basefile", sub {
-           my $line = shift;
-           return if $line !~ m/^$targetdir/;
-           $count++;
-           my $nper = int (($count *100)/$files);
-           if ($nper != $per) {
-               $per = $nper;
-               my $frac = $per > 100 ? 1 : $per/100;
-               update_progress($frac, $maxper, 0.5);
-           }
-       });
-
-       syscmd("mount -n -t tmpfs tmpfs $targetdir/tmp") == 0 || die "unable to mount tmpfs on $targetdir/tmp\n";
-
-       mkdir "$targetdir/tmp/pkg";
-       syscmd("mount -n --bind '$proxmox_pkgdir' '$targetdir/tmp/pkg'") == 0
-           || die "unable to bind-mount packages on $targetdir/tmp/pkg\n";
-       syscmd("mount -n -t proc proc $targetdir/proc") == 0 || 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 ($run_env->{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";
-
-       update_progress(1, $maxper, 0.5, "configuring base system");
-
-       # configure hosts
-
-       my $hosts =
-           "127.0.0.1 localhost.localdomain localhost\n" .
-           "$ipaddress $hostname.$domain $hostname\n\n" .
-           "# The following lines are desirable for IPv6 capable hosts\n\n" .
-           "::1     ip6-localhost ip6-loopback\n" .
-           "fe00::0 ip6-localnet\n" .
-           "ff00::0 ip6-mcastprefix\n" .
-           "ff02::1 ip6-allnodes\n" .
-           "ff02::2 ip6-allrouters\n" .
-           "ff02::3 ip6-allhosts\n";
-
-       file_write_all("$targetdir/etc/hosts", $hosts);
-
-       file_write_all("$targetdir/etc/hostname", "$hostname\n");
-
-       syscmd("/bin/hostname $hostname") if !is_test_mode();
-
-       # configure interfaces
-
-       my $ifaces = "auto lo\niface lo inet loopback\n\n";
-
-       my $ntype = $ipversion == 4 ? 'inet' : 'inet6';
-
-       my $ethdev = $ipconf->{ifaces}->{$ipconf->{selected}}->{name};
-
-       if ($iso_env->{cfg}->{bridged_network}) {
-           $ifaces .= "iface $ethdev $ntype manual\n";
-
-           $ifaces .=
-               "\nauto vmbr0\niface vmbr0 $ntype static\n" .
-               "\taddress $cidr\n" .
-               "\tgateway $gateway\n" .
-               "\tbridge-ports $ethdev\n" .
-               "\tbridge-stp off\n" .
-               "\tbridge-fd 0\n";
-       } else {
-           $ifaces .= "auto $ethdev\n" .
-               "iface $ethdev $ntype static\n" .
-               "\taddress $cidr\n" .
-               "\tgateway $gateway\n";
-       }
-
-       foreach my $iface (sort keys %{$ipconf->{ifaces}}) {
-           my $name = $ipconf->{ifaces}->{$iface}->{name};
-           next if $name eq $ethdev;
-
-           $ifaces .= "\niface $name $ntype manual\n";
-       }
-
-       file_write_all("$targetdir/etc/network/interfaces", $ifaces);
-
-       # configure dns
-
-       my $resolvconf = "search $domain\nnameserver $dnsserver\n";
-       file_write_all("$targetdir/etc/resolv.conf", $resolvconf);
-
-       # configure fstab
-
-       my $fstab = "# <file system> <mount point> <type> <options> <dump> <pass>\n";
-
-       if ($use_zfs) {
-           # do nothing
-       } elsif ($use_btrfs) {
-           my $fsuuid;
-           my $cmd = "blkid -u filesystem -t TYPE=btrfs -o export $rootdev";
-           run_command($cmd, sub {
-               my $line = shift;
-
-               if ($line =~ m/^UUID=([A-Fa-f0-9\-]+)$/) {
-                   $fsuuid = $1;
-               }
-           });
-
-           die "unable to detect FS UUID" if !defined($fsuuid);
-
-           $fstab .= "UUID=$fsuuid / btrfs defaults 0 1\n";
-       } else {
-           my $root_mountopt = $fssetup->{$filesys}->{root_mountopt} || 'defaults';
-           $fstab .= "$rootdev / $filesys ${root_mountopt} 0 1\n";
-       }
-
-       # mount /boot/efi
-       # Note: this is required by current grub, but really dangerous, because
-       # vfat does not have journaling, so it triggers manual fsck after each crash
-       # so we only mount /boot/efi if really required (efi systems).
-       if ($run_env->{boot_type} eq 'efi' && !$use_zfs) {
-           if (scalar(@$bootdevinfo)) {
-               my $di = @$bootdevinfo[0]; # simply use first disk
-
-               if ($di->{esp}) {
-                   my $efi_boot_uuid = $di->{esp};
-                   if (my $uuid = Proxmox::Sys::Block::get_dev_uuid($di->{esp})) {
-                       $efi_boot_uuid = "UUID=$uuid";
-                   }
-
-                   $fstab .= "${efi_boot_uuid} /boot/efi vfat defaults 0 1\n";
-               }
-           }
-       }
-
-
-       $fstab .= "$swapfile none swap sw 0 0\n" if $swapfile;
-
-       $fstab .= "proc /proc proc defaults 0 0\n";
-
-       file_write_all("$targetdir/etc/fstab", $fstab);
-       file_write_all("$targetdir/etc/mtab", "");
-
-       syscmd("cp ${proxmox_libdir}/policy-disable-rc.d $targetdir/usr/sbin/policy-rc.d") == 0 ||
-               die "unable to copy policy-rc.d\n";
-       syscmd("cp ${proxmox_libdir}/fake-start-stop-daemon $targetdir/sbin/") == 0 ||
-               die "unable to copy start-stop-daemon\n";
-
-       diversion_add($targetdir, "/sbin/start-stop-daemon", "/sbin/fake-start-stop-daemon");
-       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;
-       file_write_all("$targetdir/etc/machine-id", $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 = '';
-       foreach my $di (@$bootdevinfo) {
-           $grub_install_devices_txt .= ', ' if $grub_install_devices_txt;
-           $grub_install_devices_txt .= $di->{by_id} || $di->{devname};
-       }
-
-       # Note: keyboard-configuration/xbkb-keymap is used by console-setup
-       my $xkmap = $iso_env->{locales}->{kmap}->{$keymap}->{x11} // 'us';
-
-       debconfig_set ($targetdir, <<_EOD);
-locales locales/default_environment_locale select en_US.UTF-8
-locales locales/locales_to_be_generated select en_US.UTF-8 UTF-8
-samba-common samba-common/dhcp boolean false
-samba-common samba-common/workgroup string WORKGROUP
-postfix postfix/main_mailer_type select No configuration
-keyboard-configuration keyboard-configuration/xkb-keymap select $xkmap
-d-i debian-installer/locale select en_US.UTF-8
-grub-pc grub-pc/install_devices select $grub_install_devices_txt
-_EOD
-
-       my $pkg_count = 0;
-       while (<${proxmox_pkgdir}/*.deb>) { $pkg_count++ };
-
-       # btrfs/dpkg is extremely slow without --force-unsafe-io
-       my $dpkg_opts = $use_btrfs ? "--force-unsafe-io" : "";
-
-       $count = 0;
-       while (<${proxmox_pkgdir}/*.deb>) {
-           chomp;
-           my $path = $_;
-           my ($deb) = $path =~ m/${proxmox_pkgdir}\/(.*\.deb)/;
-           update_progress($count/$pkg_count, 0.5, 0.75, "extracting $deb");
-           print STDERR "extracting: $deb\n";
-           syscmd("chroot $targetdir dpkg $dpkg_opts --force-depends --no-triggers --unpack /tmp/pkg/$deb") == 0
-               || die "installation of package $deb failed\n";
-           update_progress((++$count)/$pkg_count, 0.5, 0.75);
-       }
-
-       # needed for postfix postinst in case no other NIC is active
-       syscmd("chroot $targetdir ifup lo");
-
-       my $cmd = "chroot $targetdir dpkg $dpkg_opts --force-confold --configure -a";
-       $count = 0;
-       run_command($cmd, sub {
-           my $line = shift;
-           if ($line =~ m/Setting up\s+(\S+)/) {
-               update_progress((++$count)/$pkg_count, 0.75, 0.95, "configuring $1");
-           }
-       });
-
-       unlink "$targetdir/etc/mailname";
-       $postfix_main_cf =~ s/__FQDN__/${hostname}.${domain}/;
-       file_write_all("$targetdir/etc/postfix/main.cf", $postfix_main_cf);
-
-       # make sure we have all postfix directories
-       syscmd("chroot $targetdir /usr/sbin/postfix check");
-       # cleanup mail queue
-       syscmd("chroot $targetdir /usr/sbin/postsuper -d ALL");
-       # create /etc/aliases.db (/etc/aliases is shipped in the base squashfs)
-       syscmd("chroot $targetdir /usr/bin/newaliases");
-
-       unlink  "$targetdir/proxmox_install_mode";
-
-       # set timezone
-       unlink ("$targetdir/etc/localtime");
-       symlink ("/usr/share/zoneinfo/$timezone", "$targetdir/etc/localtime");
-       file_write_all("$targetdir/etc/timezone", "$timezone\n");
-
-       # set apt mirror
-       if (my $mirror = $iso_env->{locales}->{country}->{$country}->{mirror}) {
-           my $fn = "$targetdir/etc/apt/sources.list";
-           syscmd("sed -i 's/ftp\\.debian\\.org/$mirror/' '$fn'");
-       }
-
-       # create extended_states for apt (avoid cron job warning if that
-       # file does not exist)
-       file_write_all("$targetdir/var/lib/apt/extended_states", '');
-
-       # allow ssh root login
-       syscmd(['sed', '-i', 's/^#\?PermitRootLogin.*/PermitRootLogin yes/', "$targetdir/etc/ssh/sshd_config"]);
-
-       if ($iso_env->{product} eq 'pmg') {
-           # install initial clamav DB
-           my $srcdir = "${proxmox_cddir}/proxmox/clamav";
-           foreach my $fn ("main.cvd", "bytecode.cvd", "daily.cvd", "safebrowsing.cvd") {
-               syscmd("cp \"$srcdir/$fn\" \"$targetdir/var/lib/clamav\"") == 0 ||
-                   die "installation of clamav db file '$fn' failed\n";
-           }
-           syscmd("chroot $targetdir /bin/chown clamav:clamav -R /var/lib/clamav") == 0 ||
-               die "unable to set owner for clamav database files\n";
-       }
-
-       if ($iso_env->{product} eq 'pve') {
-           # save installer settings
-           my $ucc = uc ($country);
-           debconfig_set($targetdir, "pve-manager pve-manager/country string $ucc\n");
-       }
-
-       update_progress(0.8, 0.95, 1, "make system bootable");
-
-       if ($use_zfs) {
-           # add ZFS options while preserving existing kernel cmdline
-           my $zfs_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs\"";
-           file_write_all("$targetdir/etc/default/grub.d/zfs.cfg", $zfs_snippet);
-
-           file_write_all("$targetdir/etc/kernel/cmdline", "root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs\n");
-
-       }
-
-       diversion_remove($targetdir, "/usr/sbin/update-grub");
-       diversion_remove($targetdir, "/usr/sbin/update-initramfs");
-
-       my $kapi;
-       foreach my $fn (<$targetdir/lib/modules/*>) {
-           if ($fn =~ m!/(\d+\.\d+\.\d+-\d+-pve)$!) {
-               die "found multiple kernels\n" if defined($kapi);
-               $kapi = $1;
-           }
-       }
-       die "unable to detect kernel version\n" if !defined($kapi);
-
-       if (!is_test_mode()) {
-
-           unlink ("$targetdir/etc/mtab");
-           symlink ("/proc/mounts", "$targetdir/etc/mtab");
-           syscmd("mount -n --bind /dev $targetdir/dev");
-
-           my $bootloader_err_list = [];
-           eval {
-               syscmd("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
-                   die "unable to install initramfs\n";
-
-               my $native_4k_disk_bootable = 0;
-               foreach my $di (@$bootdevinfo) {
-                   $native_4k_disk_bootable |= ($di->{logical_bsize} == 4096);
-               }
-
-               foreach my $di (@$bootdevinfo) {
-                   my $dev = $di->{devname};
-                   if ($use_zfs) {
-                       prepare_proxmox_boot_esp($di->{esp}, $targetdir);
-                   } else {
-                       if (!$native_4k_disk_bootable) {
-                           eval {
-                               syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
-                                       die "unable to install the i386-pc boot loader on '$dev'\n";
-                           };
-                           push @$bootloader_err_list, $@ if $@;
-                       }
-
-                       if (my $esp = $di->{esp}) {
-                           eval { prepare_grub_efi_boot_esp($dev, $esp, $targetdir) };
-                           push @$bootloader_err_list, $@ if $@;
-                       }
-                   }
-               }
-
-               syscmd("chroot $targetdir /usr/sbin/update-grub") == 0 ||
-                   die "unable to update boot loader config\n";
-           };
-           push @$bootloader_err_list, $@ if $@;
-
-           if (scalar(@$bootloader_err_list) > 0) {
-               $bootloader_err = "bootloader setup errors:\n";
-               map { $bootloader_err .= "- $_" } @$bootloader_err_list;
-               warn $bootloader_err;
-           }
-
-           syscmd("umount $targetdir/dev");
-       }
-
-       # cleanup
-
-       unlink "$targetdir/usr/sbin/policy-rc.d";
-
-       diversion_remove($targetdir, "/sbin/start-stop-daemon");
-
-       # set root password
-       my $octets = encode("utf-8", $password);
-       run_command("chroot $targetdir /usr/sbin/chpasswd", undef,
-                   "root:$octets\n");
-
-       if ($iso_env->{product} eq 'pmg') {
-           # save admin email
-           file_write_all("$targetdir/etc/pmg/pmg.conf", "section: admin\n\temail ${mailto}\n");
-
-       } elsif ($iso_env->{product} eq 'pve') {
-
-           # create pmxcfs DB
-
-           my $tmpdir = "$targetdir/tmp/pve";
-           mkdir $tmpdir;
-
-           # write vnc keymap to datacenter.cfg
-           my $vnckmap = $iso_env->{locales}->{kmap}->{$keymap}->{kvm} || 'en-us';
-           file_write_all("$tmpdir/datacenter.cfg", "keyboard: $vnckmap\n");
-
-           # save admin email
-           file_write_all("$tmpdir/user.cfg", "user:root\@pam:1:0:::${mailto}::\n");
-
-           # write storage.cfg
-           my $storage_cfg;
-           if ($use_zfs) {
-               $storage_cfg = Proxmox::Install::StorageConfig::get_zfs_config($iso_env);
-           } elsif ($use_btrfs) {
-               $storage_cfg = Proxmox::Install::StorageConfig::get_btrfs_config();
-           } elsif ($datadev) {
-               $storage_cfg = Proxmox::Install::StorageConfig::get_lvm_thin_config();
-           } else {
-               $storage_cfg = Proxmox::Install::StorageConfig::get_local_config();
-           }
-           file_write_all("$tmpdir/storage.cfg", $storage_cfg);
-
-           run_command("chroot $targetdir /usr/bin/create_pmxcfs_db /tmp/pve /var/lib/pve-cluster/config.db");
-
-           syscmd("rm -rf $tmpdir");
-       } elsif ($iso_env->{product} eq 'pbs') {
-           my $base_cfg_path = "/etc/proxmox-backup";
-           mkdir "$targetdir/$base_cfg_path";
-
-           chroot_chown($targetdir, $base_cfg_path, user => 'backup', recursive => 1);
-           chroot_chmod($targetdir, $base_cfg_path, mode => '0700');
-
-           my $user_cfg_fn = "$base_cfg_path/user.cfg";
-           file_write_all("$targetdir/$user_cfg_fn", "user: root\@pam\n\temail ${mailto}\n");
-           chroot_chown($targetdir, $user_cfg_fn, user => 'root', group => 'backup');
-           chroot_chmod($targetdir, $user_cfg_fn, mode => '0640');
-       }
-    };
-
-    my $err = $@;
-
-    update_progress(1, 0, 1, "");
-
-    print STDERR $err if $err && $err ne "\n";
+use Encode;
+use Getopt::Long;
+use IO::File;
+use Glib;
+use Gtk3;
+use Gtk3::WebKit2;
+use POSIX ":sys_wait_h";
+use JSON;
 
-    if (is_test_mode()) {
-       my $elapsed = Time::HiRes::tv_interval($starttime);
-       print STDERR "Elapsed extract time: $elapsed\n";
+use Proxmox::Log;
+Proxmox::Log::init("/tmp/install.log");
 
-       syscmd("chroot $targetdir /usr/bin/dpkg-query -W --showformat='\${package}\n'> final.pkglist");
-    }
+{ # NOTE: order is important here
+    my $test_image;
+    GetOptions(
+       'test-image|t=s' => \$test_image
+    ) or die "usage error\n";
 
-    syscmd("umount $targetdir/run");
-    syscmd("umount $targetdir/mnt/hostrun");
-    syscmd("umount $targetdir/tmp/pkg");
-    syscmd("umount $targetdir/tmp");
-    syscmd("umount $targetdir/proc");
-    syscmd("umount $targetdir/sys/firmware/efi/efivars");
-    syscmd("umount $targetdir/sys");
-    rmdir("$targetdir/mnt/hostrun");
-
-    if ($use_zfs) {
-       syscmd("zfs umount -a") == 0 ||
-           die "unable to unmount zfs\n";
-    } else {
-       syscmd("umount -d $targetdir");
-    }
+    Proxmox::Install::ISOEnv::set_test_image($test_image) if $test_image;
+}
 
-    if (!$err && $use_zfs) {
-       syscmd("zfs set sync=standard $zfs_pool_name") == 0 ||
-           die "unable to set zfs properties\n";
+use Proxmox::Install::ISOEnv;
+use Proxmox::Install::RunEnv;
 
-       syscmd("zfs set mountpoint=/ $zfs_pool_name/ROOT/$zfs_root_volume_name") == 0 ||
-           die "zfs set mountpoint failed\n";
+# init singletons TODO: avoid all global initialization, use single "main" method
+my $iso_env = Proxmox::Install::ISOEnv::get();
 
-       syscmd("zpool set bootfs=$zfs_pool_name/ROOT/$zfs_root_volume_name $zfs_pool_name") == 0 ||
-           die "zpool set bootfs failed\n";
-       syscmd("zpool export $zfs_pool_name");
-    }
+use Proxmox::Install;
+use Proxmox::Install::Config;
 
-    if ($bootloader_err) {
-       $err = $err && $err ne "\n" ? "$err\n$bootloader_err" : $bootloader_err;
-    }
+use Proxmox::Sys::Block qw(get_cached_disks);
+use Proxmox::Sys::Command qw(syscmd);
+use Proxmox::Sys::File qw(file_read_all file_write_all);
+use Proxmox::Sys::Net qw(parse_ip_address parse_ip_mask);
+use Proxmox::UI;
 
-    die $err if $err;
+if (!$ENV{G_SLICE} ||  $ENV{G_SLICE} ne "always-malloc") {
+    die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
 }
 
-my $last_display_change = 0;
-
-my $display_info_counter = 0;
-
-my $display_info_items = [
-    "extract1-license.htm",
-    "extract2-rulesystem.htm",
-    "extract3-spam.htm",
-    "extract4-virus.htm",
-];
+my $step_number = 0; # Init number for global function list
 
-sub display_info {
+my @steps = (
+    {
+       step => 'intro',
+       html => 'license.htm',
+       next_button => 'I a_gree',
+       function => \&create_intro_view,
+    },
+    {
+       step => 'intro',
+       html => 'page1.htm',
+       function => \&create_hdsel_view,
+    },
+    {
+       step => 'country',
+       html => 'country.htm',
+       function => \&create_country_view,
+    },
+    {
+       step => 'password',
+       html => 'passwd.htm',
+       function => \&create_password_view,
+    },
+    {
+       step => 'ipconf',
+       html => 'ipconf.htm',
+       function => \&create_ipconf_view,
+    },
+    {
+       step => 'ack',
+       html => 'ack.htm',
+       next_button => '_Install',
+       function => \&create_ack_view,
+    },
+    {
+       step => 'extract',
+       next_button => '_Reboot',
+       function => \&create_extract_view,
+    },
+);
 
-    my $min_display_time = 15;
+# GUI global variables
+my $gtk_state = {};
 
-    my $ctime = time();
+my $target_hds; # only for the summary view
 
-    return if ($ctime - $last_display_change) < $min_display_time;
+sub app_quit {
+    my ($exit_code) = @_;
 
-    my $page = $display_info_items->[$display_info_counter % scalar(@$display_info_items)];
+    Gtk3->main_quit() if Gtk3->main_level() > 0;
 
-    $display_info_counter++;
-    Proxmox::UI::display_html($page);
-    $last_display_change = time();
+    # reap left over zombie processes
+    while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) {
+       print STDERR "reaped child $child\n";
+    }
+    exit($exit_code);
 }
 
 sub prev_function {
-
     my ($text, $fctn) = @_;
 
     $fctn = $step_number if !$fctn;
@@ -1329,6 +138,7 @@ sub create_main_window {
     my $vbox = Gtk3::Box->new('vertical', 0);
 
     my $logofn = "$iso_env->{product}-banner.png";
+    my $proxmox_libdir = $iso_env->{locations}->{lib};
     my $image = Gtk3::Image->new_from_file("${proxmox_libdir}/$logofn");
 
     my $provider = Gtk3::CssProvider->new();
@@ -1353,18 +163,36 @@ sub create_main_window {
     $vbox->pack_start($cmdbox, 0, 0, 10);
 
     my $next_btn = Gtk3::Button->new('_Next');
-    $next_btn->signal_connect(clicked => sub { $last_display_change = 0; $gtk_state->{next_btn_callback}->(); });
+    $next_btn->signal_connect(clicked => sub {
+       Proxmox::Install::reset_last_display_change();
+       $gtk_state->{next_btn_callback}->();
+    });
     $cmdbox->pack_end($next_btn, 0, 0, 10);
 
     my $prev_btn = Gtk3::Button->new('_Previous');
-    $prev_btn->signal_connect(clicked => sub { $last_display_change = 0; &prev_function (); });
+    $prev_btn->signal_connect(clicked => sub {
+       Proxmox::Install::reset_last_display_change();
+       prev_function();
+    });
     $cmdbox->pack_end($prev_btn, 0, 0, 10);
 
 
     my $abort = Gtk3::Button->new('_Abort');
     $abort->set_can_focus(0);
     $cmdbox->pack_start($abort, 0, 0, 10);
-    $abort->signal_connect(clicked => sub { app_quit(-1); });
+    $abort->signal_connect(clicked => sub {
+       my $msg = 'Abort Installation';
+       my $secondary_text = 'Are you sure you want to abort the installation?';
+       my $dialog = Gtk3::MessageDialog->new($window, 'modal', 'question', 'yes-no', $msg);
+       $dialog->format_secondary_text($secondary_text);
+       $dialog->signal_connect(response => sub {
+           my ($dialog, $response) = @_;
+
+           $dialog->close();
+           app_quit(-1) if $response eq 'yes';
+       });
+       $dialog->present();
+    });
 
     my $vbox2 = Gtk3::Box->new('vertical', 0);
     $hbox->add($vbox2);
@@ -1397,6 +225,8 @@ sub create_main_window {
     $gtk_state->{next_btn} = $next_btn;
     $gtk_state->{progress_bar} = Gtk3::ProgressBar->new();
     $gtk_state->{progress_status} = Gtk3::Label->new('');
+    $gtk_state->{abort_btn} = $abort;
+    $gtk_state->{disk_selection} = {};
 
     Proxmox::UI::init_gtk($gtk_state, $iso_env);
 
@@ -1451,87 +281,109 @@ sub check_number {
 sub create_text_input {
     my ($default, $text) = @_;
 
-    my $hbox = Gtk3::Box->new('horizontal', 0);
-
     my $label = Gtk3::Label->new($text);
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox->pack_start($label, 0, 0, 10);
     my $e1 = Gtk3::Entry->new();
     $e1->set_width_chars(35);
-    $hbox->pack_start($e1, 0, 0, 0);
     $e1->set_text($default);
 
-    return ($hbox, $e1);
+    return ($label, $e1);
 }
 sub create_cidr_inputs {
-    my ($default_ip, $default_mask) = @_;
+    my ($cidr) = @_;
+
+    my ($default_ip, $default_mask) = split('/', $cidr);
 
     my $hbox = Gtk3::Box->new('horizontal', 0);
 
     my $label = Gtk3::Label->new('IP Address (CIDR)');
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox->pack_start($label, 0, 0, 10);
 
     my $ip_el = Gtk3::Entry->new();
     $ip_el->set_width_chars(28);
-    $hbox->pack_start($ip_el, 0, 0, 0);
+    $hbox->pack_start($ip_el, 1, 1, 0);
     $ip_el->set_text($default_ip);
 
-    $label = Gtk3::Label->new('/');
-    $label->set_size_request(10, -1);
-    $hbox->pack_start($label, 0, 0, 2);
+    my $dash_label = Gtk3::Label->new('/');
+    $dash_label->set_size_request(10, -1);
+    $hbox->pack_start($dash_label, 0, 0, 2);
 
     my $cidr_el = Gtk3::Entry->new();
     $cidr_el->set_width_chars(3);
     $hbox->pack_start($cidr_el, 0, 0, 0);
     $cidr_el->set_text($default_mask);
 
-    return ($hbox, $ip_el, $cidr_el);
+    return ($label, $hbox, $ip_el, $cidr_el);
 }
 
 my $ipconf_first_view = 1;
 
+my $create_basic_grid = sub {
+    my $grid =  Gtk3::Grid->new();
+    $grid->set_visible(1);
+    $grid->set_column_spacing(10);
+    $grid->set_row_spacing(10);
+    $grid->set_hexpand(1);
+
+    $grid->set_margin_start(20);
+    $grid->set_margin_end(20);
+    $grid->set_margin_top(10);
+    $grid->set_margin_bottom(10);
+
+    return $grid;
+};
+
 sub create_ipconf_view {
 
     cleanup_view();
     Proxmox::UI::display_html('ipconf.htm');
 
-    my $vcontainer = Gtk3::Box->new('vertical', 0);
-    $gtk_state->{inbox}->pack_start($vcontainer, 1, 0, 0);
-    my $hcontainer =  Gtk3::Box->new('horizontal', 0);
-    $vcontainer->pack_start($hcontainer, 0, 0, 10);
-    my $vbox =  Gtk3::Box->new('vertical', 0);
-    $hcontainer->add($vbox);
+    my $grid = &$create_basic_grid();
+    $grid->set_row_spacing(10);
+    $grid->set_column_spacing(10);
+
+    $gtk_state->{inbox}->pack_start($grid, 0, 0, 0);
 
-    my $ipaddr_text = $config->{ipaddress} // "192.168.100.2";
-    my $netmask_text = $config->{netmask} // "24";
-    my $cidr_box;
-    ($cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) =
-       create_cidr_inputs($ipaddr_text, $netmask_text);
+    my $cidr = Proxmox::Install::Config::get_cidr() // '192.168.100.2/24';
 
-    my $device_cb = Gtk3::ComboBoxText->new();
+    my ($cidr_label, $cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) = create_cidr_inputs($cidr);
+
+    my $device_model = Gtk3::ListStore->new('Glib::String', 'Glib::String');
+    my $device_cb = Gtk3::ComboBox->new_with_model($device_model);
     $device_cb->set_active(0);
     $device_cb->set_visible(1);
 
+    my $icon_cell = Gtk3::CellRendererText->new();
+    $device_cb->pack_start($icon_cell, 0);
+    $device_cb->add_attribute($icon_cell, 'text', 0);
+    $icon_cell->set_property('foreground', 'green');
+
+    my $cell = Gtk3::CellRendererText->new();
+    $device_cb->pack_start($cell, 0);
+    $device_cb->add_attribute($cell, 'text', 1);
+
     my $get_device_desc = sub {
        my $iface = shift;
        return "$iface->{name} - $iface->{mac} ($iface->{driver})";
     };
 
-    my $device_active_map = {};
-    my $device_active_reverse_map = {};
+    my $run_env = Proxmox::Install::RunEnv::get();
+    my $ipconf = $run_env->{ipconf};
+
+    my ($device_active_map, $device_active_reverse_map) = ({}, {});
 
     my $device_change_handler = sub {
        my $current = shift;
 
        my $new = $device_active_map->{$current->get_active()};
-       return if defined($ipconf->{selected}) && $new eq $ipconf->{selected};
+       my $selected = Proxmox::Install::Config::get_mngmt_nic_id();
+       return if defined($selected) && $new eq $selected;
 
-       $ipconf->{selected} = $new;
-       my $iface = $ipconf->{ifaces}->{$ipconf->{selected}};
-       $config->{mngmt_nic} = $iface->{name};
+       Proxmox::Install::Config::set_mngmt_nic_id($new);
+       my $iface = $ipconf->{ifaces}->{$new};
+       Proxmox::Install::Config::set_mngmt_nic($iface->{name});
        $ipconf_entry_addr->set_text($iface->{inet}->{addr} || $iface->{inet6}->{addr})
            if $iface->{inet}->{addr} || $iface->{inet6}->{addr};
        $ipconf_entry_mask->set_text($iface->{inet}->{prefix} || $iface->{inet6}->{prefix})
@@ -1539,10 +391,16 @@ sub create_ipconf_view {
     };
 
     my $i = 0;
-    foreach my $index (sort keys %{$ipconf->{ifaces}}) {
-       $device_cb->append_text(&$get_device_desc($ipconf->{ifaces}->{$index}));
+    for my $index (sort keys $ipconf->{ifaces}->%*) {
+       my $iface = $ipconf->{ifaces}->{$index};
+       my $iter = $device_model->append();
+       my $symbol = "$iface->{state}" eq "UP" ? "\x{25CF}" : ' ';
+       $device_model->set($iter,
+          0 => $symbol,
+          1 => $get_device_desc->($iface),
+       );
        $device_active_map->{$i} = $index;
-       $device_active_reverse_map->{$ipconf->{ifaces}->{$index}->{name}} = $i;
+       $device_active_reverse_map->{$iface->{name}} = $i;
        if ($ipconf_first_view && $index == $ipconf->{default}) {
            $device_cb->set_active($i);
            &$device_change_handler($device_cb);
@@ -1552,94 +410,82 @@ sub create_ipconf_view {
        $i++;
     }
 
-    if (my $nic = $config->{mngmt_nic}) {
+    if (my $nic = Proxmox::Install::Config::get_mngmt_nic()) {
        $device_cb->set_active($device_active_reverse_map->{$nic} // 0);
     } else {
        $device_cb->set_active(0);
     }
 
-    my $devicebox = Gtk3::Box->new('horizontal', 0);
-    my $label = Gtk3::Label->new("Management Interface:");
+    my $label = Gtk3::Label->new("Management Interface");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $devicebox->pack_start($label, 0, 0, 10);
-    $devicebox->pack_start($device_cb, 0, 0, 0);
 
-    $vbox->pack_start($devicebox, 0, 0, 2);
+    $grid->attach($label, 0, 0, 1, 1);
+    $grid->attach($device_cb, 1, 0, 1, 1);
 
-    my $hn = $config->{fqdn} // "$iso_env->{product}." . ($ipconf->{domain} // "example.invalid");
+    my $fqdn = Proxmox::Install::Config::get_fqdn();
+    my $hostname = $run_env->{network}->{hostname} || $iso_env->{product};
+    my $domain = $ipconf->{domain} || "example.invalid";
+    $fqdn //= "$hostname.$domain";
 
-    my ($hostbox, $hostentry) = create_text_input($hn, 'Hostname (FQDN):');
-    $vbox->pack_start($hostbox, 0, 0, 2);
+    my ($host_label, $hostentry) = create_text_input($fqdn, 'Hostname (FQDN)');
+    $grid->attach($host_label, 0, 1, 1, 1);
+    $grid->attach($hostentry, 1, 1, 1, 1);
 
-    $vbox->pack_start($cidr_box, 0, 0, 2);
+    $grid->attach($cidr_label, 0, 2, 1, 1);
+    $grid->attach($cidr_box, 1, 2, 1, 1);
 
-    $gateway = $config->{gateway} // $ipconf->{gateway} || '192.168.100.1';
+    my $cfg_gateway = Proxmox::Install::Config::get_gateway();
+    my $gateway = $cfg_gateway // $ipconf->{gateway} || '192.168.100.1';
 
-    my $gwbox;
-    ($gwbox, $ipconf_entry_gw) =
-       create_text_input($gateway, 'Gateway:');
+    my ($gw_label, $ipconf_entry_gw) = create_text_input($gateway, 'Gateway');
+    $grid->attach($gw_label, 0, 3, 1, 1);
+    $grid->attach($ipconf_entry_gw, 1, 3, 1, 1);
 
-    $vbox->pack_start($gwbox, 0, 0, 2);
+    my $cfg_dns = Proxmox::Install::Config::get_dns();
+    my $dnsserver = $cfg_dns // $ipconf->{dnsserver} || $gateway;
 
-    $dnsserver = $config->{dnsserver} // $ipconf->{dnsserver} || $gateway;
+    my ($dns_label, $ipconf_entry_dns) = create_text_input($dnsserver, 'DNS Server');
 
-    my $dnsbox;
-    ($dnsbox, $ipconf_entry_dns) =
-       create_text_input($dnsserver, 'DNS Server:');
-
-    $vbox->pack_start($dnsbox, 0, 0, 0);
+    $grid->attach($dns_label, 0, 4, 1, 1);
+    $grid->attach($ipconf_entry_dns, 1, 4, 1, 1);
 
     $gtk_state->{inbox}->show_all;
     set_next(undef, sub {
-
        # verify hostname
-
        my $text = $hostentry->get_text();
-
        $text =~ s/^\s+//;
        $text =~ s/\s+$//;
 
-       $config->{fqdn} = $text;
+       my ($hostname, $domainname) = eval { Proxmox::Sys::Net::parse_fqdn($text) };
+       my $err = $@;
 
-       my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
-
-       # Debian does not support purely numeric hostnames
-       if ($text && $text =~ /^[0-9]+(?:\.|$)/) {
-           Proxmox::UI::message("Purely numeric hostnames are not allowed.");
+       if ($err || $text =~ m/.example.invalid$/) {
+           Proxmox::UI::message($err || 'Hostname does not look like a valid fully qualified domain name');
            $hostentry->grab_focus();
            return;
-       }
-
-       if ($text && $text =~ m/^(${namere}\.)*${namere}$/ && $text !~ m/.example.invalid$/ &&
-           $text =~ m/^([^\.]+)\.(\S+)$/) {
-           $hostname = $1;
-           $domain = $2;
        } else {
-           Proxmox::UI::message("Hostname does not look like a fully qualified domain name.");
-           $hostentry->grab_focus();
-           return;
+           Proxmox::Install::Config::set_hostname($hostname);
+           Proxmox::Install::Config::set_domain($domainname);
        }
 
        # verify ip address
        $text = $ipconf_entry_addr->get_text();
-       ($ipaddress, $ipversion) = parse_ip_address($text);
+       my ($ipaddress, $ipversion) = parse_ip_address($text);
        if (!defined($ipaddress)) {
            Proxmox::UI::message("IP address is not valid.");
            $ipconf_entry_addr->grab_focus();
            return;
        }
-       $config->{ipaddress} = $ipaddress;
 
        $text = $ipconf_entry_mask->get_text();
-       $netmask = parse_ip_mask($text, $ipversion);
+       my $netmask = parse_ip_mask($text, $ipversion);
        if (!defined($netmask)) {
            Proxmox::UI::message("Netmask is not valid.");
            $ipconf_entry_mask->grab_focus();
            return;
        }
-       $cidr = "$ipaddress/$netmask";
-       $config->{netmask} = $netmask;
+       Proxmox::Install::Config::set_cidr("$ipaddress/$netmask");
 
        $text = $ipconf_entry_gw->get_text();
        my ($gateway_ip, $gateway_ip_version) = parse_ip_address($text);
@@ -1651,21 +497,21 @@ sub create_ipconf_view {
            $ipconf_entry_gw->grab_focus();
            return;
        }
-       $config->{gateway} = $gateway = $gateway_ip;
+       Proxmox::Install::Config::set_gateway($gateway_ip);
 
        $text = $ipconf_entry_dns->get_text();
        my ($dns_ip, $dns_ip_version) = parse_ip_address($text);
        if (!defined($dns_ip) || $dns_ip_version != $ipversion) {
-           my $msg = defined($gateway_ip)
-               ? "DNS and host IP version must not differ (IPv$gateway_ip_version != IPv$ipversion)."
+           my $msg = defined($dns_ip)
+               ? "DNS and host IP version must not differ (IPv$dns_ip_version != IPv$ipversion)."
                : "DNS IP is not valid.";
            Proxmox::UI::message($msg);
            $ipconf_entry_dns->grab_focus();
            return;
        }
-       $config->{dnsserver} = $dnsserver = $dns_ip;
+       Proxmox::Install::Config::set_dns($dns_ip);
 
-       #print STDERR "TEST $ipaddress $netmask $gateway $dnsserver\n";
+       #print STDERR "TEST $ipaddress/$netmask $gateway_ip $dns_ip\n";
 
        $step_number++;
        create_ack_view();
@@ -1685,34 +531,44 @@ sub create_ack_view {
     $reboot_checkbox->set_active(1);
     $reboot_checkbox->signal_connect ("toggled" => sub {
        my $cb = shift;
-       $config_options->{autoreboot} = $cb->get_active();
+       Proxmox::Install::Config::set_autoreboot(!!$cb->get_active());
     });
     $vbox->pack_start($reboot_checkbox, 0, 0, 2);
 
+    my $proxmox_libdir = $iso_env->{locations}->{lib};
     my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
     my $ack_html = "${proxmox_libdir}/html/$iso_env->{product}/$steps[$step_number]->{html}";
     my $html_data = file_read_all($ack_template);
 
+    my $country = Proxmox::Install::Config::get_country();
+
     my %config_values = (
-       __target_hd__ => join(' | ', @{$config_options->{target_hds}}),
-       __target_fs__ => $config_options->{filesys},
+       __target_hd__ => join(' | ', $target_hds->@*),
+       __target_fs__ => Proxmox::Install::Config::get_filesys(),
        __country__ => $iso_env->{locales}->{country}->{$country}->{name},
-       __timezone__ => $timezone,
-       __keymap__ => $keymap,
-       __mailto__ => $mailto,
-       __interface__ => $ipconf->{ifaces}->{$ipconf->{selected}}->{name},
-       __hostname__ => $hostname,
-       __ip__ => $ipaddress,
-       __cidr__ => $cidr,
-       __netmask__ => $netmask,
-       __gateway__ => $gateway,
-       __dnsserver__ => $dnsserver,
+       __timezone__ => Proxmox::Install::Config::get_timezone(),
+       __keymap__ => Proxmox::Install::Config::get_keymap(),
+       __mailto__ => Proxmox::Install::Config::get_mailto(),
+       __interface__ =>  Proxmox::Install::Config::get_mngmt_nic(),
+       __hostname__ => Proxmox::Install::Config::get_hostname(),
+       __cidr__ => Proxmox::Install::Config::get_cidr(),
+       __gateway__ => Proxmox::Install::Config::get_gateway(),
+       __dnsserver__ => Proxmox::Install::Config::get_dns(),
     );
 
     while (my ($k, $v) = each %config_values) {
        $html_data =~ s/$k/$v/g;
     }
 
+    eval {
+       my $config = Proxmox::Install::Config::get();
+       file_write_all(
+           "$iso_env->{locations}->{run}/config-ack.json",
+           to_json($config, { utf8 => 1, canonical => 1 }) ."\n",
+       );
+    };
+    warn "failed to write config-for-ack -  $@" if $@;
+
     file_write_all($ack_html, $html_data);
 
     Proxmox::UI::display_html('ack.htm');
@@ -1780,18 +636,19 @@ sub update_layout {
 
 my $lastzonecb;
 sub update_zonelist {
-    my ($box, $cc) = @_;
+    my ($grid, $cc) = @_;
 
-    my $sel = $timezone; # initial default
+    my $sel = Proxmox::Install::Config::get_timezone(); # initial default
     if ($lastzonecb) {
        $sel = $lastzonecb->get_active_text();
-       $box->remove($lastzonecb);
+       $grid->remove($lastzonecb);
     }
 
     my $cb = $lastzonecb = Gtk3::ComboBoxText->new();
     $cb->set_size_request(200, -1);
     $cb->signal_connect('changed' => sub {
-       $timezone = $cb->get_active_text();
+       my $timezone = $cb->get_active_text();
+       Proxmox::Install::Config::set_timezone($timezone);
     });
 
     my ($cczones, $zones) = $iso_env->{locales}->@{'cczones', 'zones'};
@@ -1810,54 +667,49 @@ sub update_zonelist {
     $cb->set_active($selected_index || 0);
 
     $cb->show;
-    $box->pack_start($cb, 0, 0, 0);
+    $grid->attach($cb, 1, 1, 1, 1);
 }
 
 sub create_password_view {
 
     cleanup_view();
 
-    my $vbox2 =  Gtk3::Box->new('vertical', 0);
-    $gtk_state->{inbox}->pack_start($vbox2, 1, 0, 0);
-    my $vbox =  Gtk3::Box->new('vertical', 0);
-    $vbox2->pack_start($vbox, 0, 0, 10);
+    my $password = Proxmox::Install::Config::get_password();
+
+    my $grid = &$create_basic_grid();
+    $gtk_state->{inbox}->pack_start($grid, 0, 0, 0);
 
-    my $hbox1 = Gtk3::Box->new('horizontal', 0);
     my $label = Gtk3::Label->new("Password");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox1->pack_start($label, 0, 0, 10);
+    $grid->attach($label, 0, 0, 1, 1);
     my $pwe1 = Gtk3::Entry->new();
     $pwe1->set_visibility(0);
     $pwe1->set_text($password) if $password;
     $pwe1->set_size_request(200, -1);
-    $hbox1->pack_start($pwe1, 0, 0, 0);
+    $grid->attach($pwe1, 1, 0, 1, 1);
 
-    my $hbox2 = Gtk3::Box->new('horizontal', 0);
     $label = Gtk3::Label->new("Confirm");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox2->pack_start($label, 0, 0, 10);
+    $grid->attach($label, 0, 1, 1, 1);
     my $pwe2 = Gtk3::Entry->new();
     $pwe2->set_visibility(0);
     $pwe2->set_text($password) if $password;
     $pwe2->set_size_request(200, -1);
-    $hbox2->pack_start($pwe2, 0, 0, 0);
+    $grid->attach($pwe2, 1, 1, 1, 1);
 
-    my $hbox3 = Gtk3::Box->new('horizontal', 0);
     $label = Gtk3::Label->new("Email");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox3->pack_start($label, 0, 0, 10);
+    $label->set_margin_top(10);
+    $grid->attach($label, 0, 2, 1, 1);
+
     my $eme = Gtk3::Entry->new();
     $eme->set_size_request(200, -1);
-    $eme->set_text($mailto);
-    $hbox3->pack_start($eme, 0, 0, 0);
-
-
-    $vbox->pack_start($hbox1, 0, 0, 5);
-    $vbox->pack_start($hbox2, 0, 0, 5);
-    $vbox->pack_start($hbox3, 0, 0, 15);
+    $eme->set_text(Proxmox::Install::Config::get_mailto());
+    $eme->set_margin_top(10);
+    $grid->attach($eme, 1, 2, 1, 1);
 
     $gtk_state->{inbox}->show_all;
 
@@ -1882,8 +734,7 @@ sub create_password_view {
 
        my $t3 = $eme->get_text;
        if ($t3 !~ m/^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) {
-           Proxmox::UI::message("Email does not look like a valid address" .
-                            " (user\@domain.tld)");
+           Proxmox::UI::message("Email does not look like a valid address (user\@domain.tld)");
            $eme->grab_focus();
            return;
        }
@@ -1894,8 +745,8 @@ sub create_password_view {
            return;
        }
 
-       $password = $t1;
-       $mailto = $t3;
+       Proxmox::Install::Config::set_password($t1);
+       Proxmox::Install::Config::set_mailto($t3);
 
        $step_number++;
        create_ipconf_view();
@@ -1912,10 +763,8 @@ sub create_country_view {
 
     my $locales = $iso_env->{locales};
 
-    my $vbox2 =  Gtk3::Box->new('vertical', 0);
-    $gtk_state->{inbox}->pack_start($vbox2, 1, 0, 0);
-    my $vbox =  Gtk3::Box->new('vertical', 0);
-    $vbox2->pack_start($vbox, 0, 0, 10);
+    my $grid = &$create_basic_grid();
+    $gtk_state->{inbox}->pack_start($grid, 0, 0, 0);
 
     my $w = Gtk3::Entry->new();
     $w->set_size_request(200, -1);
@@ -1926,18 +775,16 @@ sub create_country_view {
     $c->set_popup_set_width(1);
     $c->set_inline_completion(1);
 
-    my $hbox2 = Gtk3::Box->new('horizontal', 0);
     my $label = Gtk3::Label->new("Time zone");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox2->pack_start($label, 0, 0, 10);
-    update_zonelist ($hbox2);
+    $grid->attach($label, 0, 1, 1, 1);
+    update_zonelist ($grid);
 
-    my $hbox3 = Gtk3::Box->new('horizontal', 0);
     $label = Gtk3::Label->new("Keyboard Layout");
     $label->set_size_request(150, -1);
     $label->set_xalign(1.0);
-    $hbox3->pack_start($label, 0, 0, 10);
+    $grid->attach($label, 0, 2, 1, 1);
 
     my $kmapcb = Gtk3::ComboBoxText->new();
     $kmapcb->set_size_request (200, -1);
@@ -1946,7 +793,7 @@ sub create_country_view {
     }
 
     update_layout($kmapcb);
-    $hbox3->pack_start ($kmapcb, 0, 0, 0);
+    $grid->attach($kmapcb, 1, 2, 1, 1);
 
     $kmapcb->signal_connect ('changed' => sub {
        my $sel = $kmapcb->get_active_text();
@@ -1954,14 +801,14 @@ sub create_country_view {
        if (my $kmap = $locales->{kmaphash}->{$sel}) {
            my $xkmap = $locales->{kmap}->{$kmap}->{x11};
            my $xvar = $locales->{kmap}->{$kmap}->{x11var};
-           $keymap = $kmap;
 
-           return if (defined($installer_kmap) && $installer_kmap eq $kmap);
+           Proxmox::Install::Config::set_keymap($kmap);
 
-           $installer_kmap = $keymap;
+           return if (defined($installer_kmap) && $installer_kmap eq $kmap);
+           $installer_kmap = $kmap;
 
            if (!is_test_mode()) {
-               syscmd ("setxkbmap $xkmap $xvar");
+               syscmd("setxkbmap $xkmap $xvar");
 
                my $kbd_config = qq{
                    XKBLAYOUT="$xkmap"
@@ -1983,7 +830,7 @@ sub create_country_view {
        my $text = $entry->get_text;
 
        if (my $cc = $locales->{countryhash}->{lc($text)}) {
-           update_zonelist($hbox2, $cc);
+           update_zonelist($grid, $cc);
            my $kmap = $locales->{country}->{$cc}->{kmap} || 'en-us';
            update_layout($kmapcb, $kmap);
        }
@@ -2043,18 +890,13 @@ sub create_country_view {
 
     $w->set_completion ($c);
 
-    my $hbox =  Gtk3::Box->new('horizontal', 0);
-
     $label = Gtk3::Label->new("Country");
     $label->set_xalign(1.0);
     $label->set_size_request(150, -1);
-    $hbox->pack_start($label, 0, 0, 10);
-    $hbox->pack_start($w, 0, 0, 0);
-
-    $vbox->pack_start($hbox, 0, 0, 5);
-    $vbox->pack_start($hbox2, 0, 0, 5);
-    $vbox->pack_start($hbox3, 0, 0, 5);
+    $grid->attach($label, 0, 0, 1, 1);
+    $grid->attach($w, 1, 0, 1, 1);
 
+    my $country = Proxmox::Install::Config::get_country();
     if ($country && (my $entry = $locales->{country}->{$country})) {
        $w->set_text($entry->{name});
     }
@@ -2067,7 +909,7 @@ sub create_country_view {
        my $text = $w->get_text;
 
        if (my $cc = $locales->{countryhash}->{lc($text)}) {
-           $country = $cc;
+           Proxmox::Install::Config::set_country($cc);
            $step_number++;
            create_password_view();
            return;
@@ -2085,36 +927,30 @@ my $target_hd_label;
 
 my $hdoption_first_setup = 1;
 
-my $create_basic_grid = sub {
-    my $grid =  Gtk3::Grid->new();
-    $grid->set_visible(1);
-    $grid->set_column_spacing(10);
-    $grid->set_row_spacing(10);
-    $grid->set_hexpand(1);
-
-    $grid->set_margin_start(10);
-    $grid->set_margin_end(20);
-    $grid->set_margin_top(5);
-    $grid->set_margin_bottom(5);
-
-    return $grid;
-};
-
+# takes an array ref of rows with [$label_text, $widget, $suffix_label] array refs as columns
+# $suffix_label is optional
 my $create_label_widget_grid = sub {
     my ($labeled_widgets) = @_;
 
     my $grid = &$create_basic_grid();
-    my $row = 0;
 
-    for (my $i = 0; $i < @$labeled_widgets; $i += 2) {
-       my $widget = @$labeled_widgets[$i+1];
-       my $label = Gtk3::Label->new(@$labeled_widgets[$i]);
+    for (my $row = 0; $row < scalar($labeled_widgets->@*); $row++) {
+       my ($label_text, $widget, $suffix_label) = $labeled_widgets->[$row]->@*;
+
+       my $label = Gtk3::Label->new($label_text);
        $label->set_visible(1);
        $label->set_xalign(1.0);
        $grid->attach($label, 0, $row, 1, 1);
+
        $widget->set_visible(1);
        $grid->attach($widget, 1, $row, 1, 1);
-       $row++;
+
+       if ($suffix_label) {
+           my $suffix_label = Gtk3::Label->new($suffix_label);
+           $suffix_label->set_visible(1);
+           $suffix_label->set_xalign(1.0);
+           $grid->attach($suffix_label, 2, $row, 1, 1);
+       }
     }
 
     return $grid;
@@ -2129,13 +965,13 @@ my $get_selected_hdsize = sub {
     my $cached_disks = get_cached_disks();
     my $disk_count = scalar(@$cached_disks);
     for (my $i = 0; $i < $disk_count; $i++) {
-       my $cur_hd = $config_options->{"disksel$i"} // next;
+       my $cur_hd = $gtk_state->{disk_selection}->{$i} // next;
        my $disksize = int(@$cur_hd[2] / (2 * 1024 * 1024.0)); # size in GB
        $hdsize //= $disksize;
        $hdsize = $disksize if $disksize < $hdsize;
     }
 
-    if (my $cfg_hdsize = $config_options->{hdsize}) {
+    if (my $cfg_hdsize = Proxmox::Install::Config::get_hdsize()) {
        # had the dialog open previously and set an even lower size than the disk selection allows
        $hdsize = $cfg_hdsize if $cfg_hdsize < $hdsize;
     }
@@ -2154,8 +990,9 @@ my sub update_hdsize_adjustment {
 my sub create_hdsize_adjustment {
     my ($hdsize) = @_;
     $hdsize = $get_selected_hdsize->($hdsize);
+    my $cfg_hdsize = Proxmox::Install::Config::get_hdsize();
     # params are: initial value, lower, upper, step increment, page increment, page size
-    return Gtk3::Adjustment->new($config_options->{hdsize} || $hdsize, 0, $hdsize+1, 1, 1, 1);
+    return Gtk3::Adjustment->new($cfg_hdsize || $hdsize, 0, $hdsize+1, 1, 1, 1);
 }
 
 my sub get_hdsize_spin_button {
@@ -2167,7 +1004,7 @@ my sub get_hdsize_spin_button {
     my $spinbutton_hdsize = Gtk3::SpinButton->new($hdsize_size_adj, 1, 1);
     $spinbutton_hdsize->set_buffer($hdsize_entry_buffer);
     $spinbutton_hdsize->set_adjustment($hdsize_size_adj);
-    $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
+    $spinbutton_hdsize->set_tooltip_text("only use specified size of the harddisk (rest left unpartitioned)");
     return $spinbutton_hdsize;
 };
 
@@ -2193,7 +1030,7 @@ my $create_raid_disk_grid = sub {
            my $w = shift;
            my $diskid = $w->{pve_disk_id};
            my $a = $w->get_active - 1;
-           $config_options->{"disksel${diskid}"} = ($a >= 0) ? $cached_disks->[$a] : undef;
+           $gtk_state->{disk_selection}->{$diskid} = ($a >= 0) ? $cached_disks->[$a] : undef;
            for my $btn (@$hdsize_buttons) {
                update_hdsize_adjustment($btn->get_adjustment());
            }
@@ -2203,7 +1040,7 @@ my $create_raid_disk_grid = sub {
            $disk_selector->set_active ($i+1) if $cached_disks->[$i];
        } else {
            my $hdind = 0;
-           if (my $cur_hd = $config_options->{"disksel$i"}) {
+           if (my $cur_hd = $gtk_state->{disk_selection}->{$i}) {
                foreach my $hd (@$cached_disks) {
                    if (@$hd[1] eq @$cur_hd[1]) {
                        $disk_selector->set_active($hdind+1);
@@ -2214,7 +1051,7 @@ my $create_raid_disk_grid = sub {
            }
        }
 
-       push @$disk_labeled_widgets, "Harddisk $i", $disk_selector;
+       push @$disk_labeled_widgets, ["Harddisk $i", $disk_selector];
     }
 
     my $clear_all_button = Gtk3::Button->new('_Deselect All');
@@ -2222,8 +1059,7 @@ my $create_raid_disk_grid = sub {
        $clear_all_button->signal_connect('clicked', sub {
            my $is_widget = 0;
            for my $disk_selector (@$disk_labeled_widgets) {
-               $disk_selector->set_active(0) if $is_widget;
-               $is_widget ^= 1;
+               $disk_selector->[1]->set_active(0);
            }
        });
        $clear_all_button->set_visible(1);
@@ -2258,12 +1094,11 @@ my $create_raid_advanced_grid = sub {
     $spinbutton_ashift->set_tooltip_text("zpool ashift property (pool sector size, default 2^12)");
     $spinbutton_ashift->signal_connect ("value-changed" => sub {
        my $w = shift;
-       $config_options->{ashift} = $w->get_value_as_int();
+       Proxmox::Install::Config::set_zfs_opt('ashift', $w->get_value_as_int());
     });
-    $config_options->{ashift} = 12 if ! defined($config_options->{ashift});
-    $spinbutton_ashift->set_value($config_options->{ashift});
-    push @$labeled_widgets, "ashift";
-    push @$labeled_widgets, $spinbutton_ashift;
+    my $ashift = Proxmox::Install::Config::get_zfs_opt('ashift') // 12;
+    $spinbutton_ashift->set_value($ashift);
+    push @$labeled_widgets, ['ashift', $spinbutton_ashift ];
 
     my $combo_compress = Gtk3::ComboBoxText->new();
     $combo_compress->set_tooltip_text("zfs compression algorithm for rpool dataset");
@@ -2271,48 +1106,61 @@ my $create_raid_advanced_grid = sub {
     foreach my $opt (@$comp_opts) {
        $combo_compress->append($opt, $opt);
     }
-    $config_options->{compress} = "on" if !defined($config_options->{compress});
-    $combo_compress->set_active_id($config_options->{compress});
+    my $compress = Proxmox::Install::Config::get_zfs_opt('compress') // 'on';
+    $combo_compress->set_active_id($compress);
     $combo_compress->signal_connect (changed => sub {
        my $w = shift;
-       $config_options->{compress} = $w->get_active_text();
+       Proxmox::Install::Config::set_zfs_opt('compress', $w->get_active_text());
     });
-    push @$labeled_widgets, "compress";
-    push @$labeled_widgets, $combo_compress;
+    push @$labeled_widgets, ['compress', $combo_compress];
 
     my $combo_checksum = Gtk3::ComboBoxText->new();
     $combo_checksum->set_tooltip_text("zfs checksum algorithm for rpool dataset");
-    my $csum_opts = ["on", "off","fletcher2", "fletcher4", "sha256"];
+    my $csum_opts = ["on", "fletcher4", "sha256"];
     foreach my $opt (@$csum_opts) {
        $combo_checksum->append($opt, $opt);
     }
-    $config_options->{checksum} = "on" if !($config_options->{checksum});
-    $combo_checksum->set_active_id($config_options->{checksum});
+    my $checksum = Proxmox::Install::Config::get_zfs_opt('checksum') // 'on';
+    $combo_checksum->set_active_id($checksum);
     $combo_checksum->signal_connect (changed => sub {
        my $w = shift;
-       $config_options->{checksum} = $w->get_active_text();
+       Proxmox::Install::Config::set_zfs_opt('checksum', $w->get_active_text());
     });
-    push @$labeled_widgets, "checksum";
-    push @$labeled_widgets, $combo_checksum;
+    push @$labeled_widgets, ['checksum', $combo_checksum];
 
     my $spinbutton_copies = Gtk3::SpinButton->new_with_range(1,3,1);
     $spinbutton_copies->set_tooltip_text("zfs copies property for rpool dataset (in addition to RAID redundancy!)");
     $spinbutton_copies->signal_connect ("value-changed" => sub {
        my $w = shift;
-       $config_options->{copies} = $w->get_value_as_int();
+       Proxmox::Install::Config::set_zfs_opt('copies', $w->get_value_as_int());
     });
-    $config_options->{copies} = 1 if !defined($config_options->{copies});
-    $spinbutton_copies->set_value($config_options->{copies});
-    push @$labeled_widgets, "copies", $spinbutton_copies;
+    my $copies = Proxmox::Install::Config::get_zfs_opt('copies') // 1;
+    $spinbutton_copies->set_value($copies);
+    push @$labeled_widgets, ['copies', $spinbutton_copies];
+
+    if ($iso_env->{product} eq 'pve') {
+       my $total_memory = Proxmox::Install::RunEnv::get('total_memory');
 
-    push @$labeled_widgets, "hdsize", $hdsize_btn;
+       my $spinbutton_arc_max = Gtk3::SpinButton->new_with_range(
+           $Proxmox::Install::RunEnv::ZFS_ARC_MIN_SIZE_MIB, $total_memory, 1);
+       $spinbutton_arc_max->set_tooltip_text('Maximum ARC size in megabytes');
+       $spinbutton_arc_max->signal_connect('value-changed' => sub {
+           my $w = shift;
+           Proxmox::Install::Config::set_zfs_opt('arc_max', $w->get_value_as_int());
+       });
+       my $arc_max = Proxmox::Install::Config::get_zfs_opt('arc_max');
+       $spinbutton_arc_max->set_value($arc_max);
+       push @$labeled_widgets, ['ARC max size', $spinbutton_arc_max, 'MiB'];
+    }
+
+    push @$labeled_widgets, ['hdsize', $hdsize_btn, 'GB'];
     return $create_label_widget_grid->($labeled_widgets);;
 };
 
 my $create_btrfs_raid_advanced_grid = sub {
     my ($hdsize_btn) = @_;
     my $labeled_widgets = [];
-    push @$labeled_widgets, "hdsize", $hdsize_btn;
+    push @$labeled_widgets, ['hdsize', $hdsize_btn, 'GB'];
     return $create_label_widget_grid->($labeled_widgets);;
 };
 
@@ -2355,10 +1203,11 @@ sub create_hdoption_view {
     push @$fstype, 'btrfs (RAID0)', 'btrfs (RAID1)', 'btrfs (RAID10)'
        if $iso_env->{cfg}->{enable_btrfs};
 
+    my $filesys = Proxmox::Install::Config::get_filesys();
     my $tcount = 0;
     foreach my $tmp (@$fstype) {
        $fstypecb->append_text($tmp);
-       $fstypecb->set_active ($tcount) if $config_options->{filesys} eq $tmp;
+       $fstypecb->set_active ($tcount) if $filesys eq $tmp;
        $tcount++;
     }
 
@@ -2381,8 +1230,8 @@ sub create_hdoption_view {
 
     my $hdsize_labeled_widgets = [];
 
-    # size compute
-    my $hdsize = 0;
+    my $target_hd = Proxmox::Install::Config::get_target_hd();
+    my $hdsize = 0; # size compute
     if ( -b $target_hd) {
        $hdsize = int(Proxmox::Sys::Block::hd_size($target_hd) / (1024 * 1024.0)); # size in GB
     } elsif ($target_hd) {
@@ -2390,36 +1239,43 @@ sub create_hdoption_view {
     }
 
     my $spinbutton_hdsize_nonraid = get_hdsize_spin_button($hdsize);
-    push @$hdsize_labeled_widgets, "hdsize", $spinbutton_hdsize_nonraid;
+    push @$hdsize_labeled_widgets, ['hdsize', $spinbutton_hdsize_nonraid, 'GB'];
     my $spinbutton_hdsize = $spinbutton_hdsize_nonraid;
 
     my $entry_swapsize = Gtk3::Entry->new();
-    $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
+    $entry_swapsize->set_tooltip_text("maximum SWAP size");
     $entry_swapsize->signal_connect (key_press_event => \&check_float);
-    $entry_swapsize->set_text($config_options->{swapsize}) if defined($config_options->{swapsize});
-    push @$hdsize_labeled_widgets, "swapsize", $entry_swapsize;
+    my $swapsize = Proxmox::Install::Config::get_swapsize();
+    $entry_swapsize->set_text($swapsize) if defined($swapsize);
+    push @$hdsize_labeled_widgets, ['swapsize', $entry_swapsize, 'GB'];
 
     my $entry_maxroot = Gtk3::Entry->new();
     if ($iso_env->{product} eq 'pve') {
-       $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
+       $entry_maxroot->set_tooltip_text("maximum size for LVM root volume");
        $entry_maxroot->signal_connect (key_press_event => \&check_float);
-       $entry_maxroot->set_text($config_options->{maxroot}) if $config_options->{maxroot};
-       push @$hdsize_labeled_widgets, "maxroot", $entry_maxroot;
+       if (my $maxroot = Proxmox::Install::Config::get_maxroot()) {
+           $entry_maxroot->set_text($maxroot);
+       }
+       push @$hdsize_labeled_widgets, ['maxroot', $entry_maxroot, 'GB'];
     }
 
     my $entry_minfree = Gtk3::Entry->new();
-    $entry_minfree->set_tooltip_text("minimum free LVM space (GB, required for LVM snapshots)");
+    $entry_minfree->set_tooltip_text("minimum free LVM space (required for LVM snapshots)");
     $entry_minfree->signal_connect (key_press_event => \&check_float);
-    $entry_minfree->set_text($config_options->{minfree}) if defined($config_options->{minfree});
-    push @$hdsize_labeled_widgets, "minfree", $entry_minfree;
+    if (defined(my $minfree = Proxmox::Install::Config::get_minfree())) {
+       $entry_minfree->set_text($minfree);
+    }
+    push @$hdsize_labeled_widgets, ['minfree', $entry_minfree, 'GB'];
 
     my $entry_maxvz;
     if ($iso_env->{product} eq 'pve') {
        $entry_maxvz = Gtk3::Entry->new();
-       $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
+       $entry_maxvz->set_tooltip_text("maximum size for LVM data volume");
        $entry_maxvz->signal_connect (key_press_event => \&check_float);
-       $entry_maxvz->set_text($config_options->{maxvz}) if defined($config_options->{maxvz});
-       push @$hdsize_labeled_widgets, "maxvz", $entry_maxvz;
+       if (defined(my $maxvz = Proxmox::Install::Config::get_maxvz())) {
+           $entry_maxvz->set_text($maxvz);
+       }
+       push @$hdsize_labeled_widgets, ['maxvz', $entry_maxvz, 'GB'];
     }
 
     my $spinbutton_hdsize_zfs = get_hdsize_spin_button($hdsize);
@@ -2445,8 +1301,9 @@ sub create_hdoption_view {
     $hdoption_first_setup = 0;
 
     my $switch_view = sub {
-       my $raid = $config_options->{filesys} =~ m/zfs|btrfs/;
-       my $is_zfs = $config_options->{filesys} =~ m/zfs/;
+       my $filesys = Proxmox::Install::Config::get_filesys();
+       my $raid = $filesys =~ m/zfs|btrfs/;
+       my $is_zfs = $filesys =~ m/zfs/;
 
        $target_hd_combo->set_visible(!$raid);
        $options_stack->get_child_by_name("hdsize")->set_visible(!$raid);
@@ -2464,10 +1321,10 @@ sub create_hdoption_view {
        $options_stack->get_child_by_name("raidzfsadvanced")->set_visible($is_zfs);
        $options_stack->get_child_by_name("raidbtrfsadvanced")->set_visible(!$is_zfs);
        if ($raid) {
-           $target_hd_label->set_text("Target: $config_options->{filesys} ");
+           $target_hd_label->set_text("Target: $filesys ");
            $options_stack->set_visible_child_name("raiddisk");
        } else {
-           $target_hd_label->set_text("Target Harddisk");
+           $target_hd_label->set_text("Target Harddisk");
        }
 
        if ($raid) {
@@ -2485,7 +1342,8 @@ sub create_hdoption_view {
     &$switch_view();
 
     $fstypecb->signal_connect (changed => sub {
-       $config_options->{filesys} = $fstypecb->get_active_text();
+       my $new_filesys = $fstypecb->get_active_text();
+       Proxmox::Install::Config::set_filesys($new_filesys);
        &$switch_view();
     });
 
@@ -2514,154 +1372,44 @@ sub create_hdoption_view {
     my $tmp;
 
     if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
-       $config_options->{hdsize} = $tmp;
+       Proxmox::Install::Config::set_hdsize($tmp);
     } else {
-       delete $config_options->{hdsize};
+       Proxmox::Install::Config::set_hdsize(undef);
     }
 
     if (defined($tmp = &$get_float($entry_swapsize))) {
-       $config_options->{swapsize} = $tmp;
+       Proxmox::Install::Config::set_swapsize($tmp);
     } else {
-       delete $config_options->{swapsize};
+       Proxmox::Install::Config::set_swapsize(undef);
     }
 
     if (defined($tmp = &$get_float($entry_maxroot))) {
-       $config_options->{maxroot} = $tmp;
+       Proxmox::Install::Config::set_maxroot($tmp);
     } else {
-       delete $config_options->{maxroot};
+       Proxmox::Install::Config::set_maxroot(undef);
     }
 
     if (defined($tmp = &$get_float($entry_minfree))) {
-       $config_options->{minfree} = $tmp;
+       Proxmox::Install::Config::set_minfree($tmp);
     } else {
-       delete $config_options->{minfree};
+       Proxmox::Install::Config::set_minfree(undef);
     }
 
     if ($entry_maxvz && defined($tmp = &$get_float($entry_maxvz))) {
-       $config_options->{maxvz} = $tmp;
+       Proxmox::Install::Config::set_maxvz($tmp);
     } else {
-       delete $config_options->{maxvz};
+       Proxmox::Install::Config::set_maxvz(undef);
     }
 
     $dialog->destroy();
 }
 
-my $get_raid_devlist = sub {
-
-    my $dev_name_hash = {};
-
-    my $cached_disks = get_cached_disks();
-    my $devlist = [];
-    for (my $i = 0; $i < @$cached_disks; $i++) {
-       if (my $hd = $config_options->{"disksel$i"}) {
-           my ($disk, $devname, $size, $model, $logical_bsize) = @$hd;
-           die "device '$devname' is used more than once\n"
-               if $dev_name_hash->{$devname};
-           $dev_name_hash->{$devname} = $hd;
-           push @$devlist, $hd;
-       }
-    }
-
-    return $devlist;
-};
-
-sub zfs_mirror_size_check {
-    my ($expected, $actual) = @_;
-
-    die "mirrored disks must have same size\n"
-       if abs($expected - $actual) > $expected / 10;
-}
-
-sub legacy_bios_4k_check {
-    my ($lbs) = @_;
-    die "Booting from 4kn drive in legacy BIOS mode is not supported.\n"
-       if $run_env->{boot_type} ne 'efi' && $lbs == 4096;
-}
-
-sub get_zfs_raid_setup {
-    my $filesys = $config_options->{filesys};
-
-    my $devlist = &$get_raid_devlist();
-
-    my $diskcount = scalar(@$devlist);
-    die "$filesys needs at least one device\n" if $diskcount < 1;
-
-    my $cmd= '';
-    if ($filesys eq 'zfs (RAID0)') {
-       foreach my $hd (@$devlist) {
-           legacy_bios_4k_check(@$hd[4]);
-           $cmd .= " @$hd[1]";
-       }
-    } elsif ($filesys eq 'zfs (RAID1)') {
-       die "zfs (RAID1) needs at least 2 device\n" if $diskcount < 2;
-       $cmd .= ' mirror ';
-       my $hd = @$devlist[0];
-       my $expected_size = @$hd[2]; # all disks need approximately same size
-       foreach my $hd (@$devlist) {
-           zfs_mirror_size_check($expected_size, @$hd[2]);
-           legacy_bios_4k_check(@$hd[4]);
-           $cmd .= " @$hd[1]";
-       }
-    } elsif ($filesys eq 'zfs (RAID10)') {
-       die "zfs (RAID10) needs at least 4 device\n" if $diskcount < 4;
-       die "zfs (RAID10) needs an even number of devices\n" if $diskcount & 1;
-
-       for (my $i = 0; $i < $diskcount; $i+=2) {
-           my $hd1 = @$devlist[$i];
-           my $hd2 = @$devlist[$i+1];
-           zfs_mirror_size_check(@$hd1[2], @$hd2[2]); # pairs need approximately same size
-           legacy_bios_4k_check(@$hd1[4]);
-           legacy_bios_4k_check(@$hd2[4]);
-           $cmd .= ' mirror ' . @$hd1[1] . ' ' . @$hd2[1];
-       }
-
-    } elsif ($filesys =~ m/^zfs \(RAIDZ-([123])\)$/) {
-       my $level = $1;
-       my $mindisks = 2 + $level;
-       die "zfs (RAIDZ-$level) needs at least $mindisks devices\n" if scalar(@$devlist) < $mindisks;
-       my $hd = @$devlist[0];
-       my $expected_size = @$hd[2]; # all disks need approximately same size
-       $cmd .= " raidz$level";
-       foreach my $hd (@$devlist) {
-           zfs_mirror_size_check($expected_size, @$hd[2]);
-           legacy_bios_4k_check(@$hd[4]);
-           $cmd .= " @$hd[1]";
-       }
-    } else {
-       die "unknown zfs mode '$filesys'\n";
-    }
-
-    return ($devlist, $cmd);
-}
-
-sub get_btrfs_raid_setup {
-
-    my $filesys = $config_options->{filesys};
-
-    my $devlist = &$get_raid_devlist();
-
-    my $diskcount = scalar(@$devlist);
-    die "$filesys needs at least one device\n" if $diskcount < 1;
-
-    my $mode;
-
-    if ($diskcount == 1) {
-       $mode = 'single';
-    } else {
-       if ($filesys eq 'btrfs (RAID0)') {
-           $mode = 'raid0';
-       } elsif ($filesys eq 'btrfs (RAID1)') {
-           die "btrfs (RAID1) needs at least 2 device\n" if $diskcount < 2;
-           $mode = 'raid1';
-       } elsif ($filesys eq 'btrfs (RAID10)') {
-           die "btrfs (RAID10) needs at least 4 device\n" if $diskcount < 4;
-           $mode = 'raid10';
-       } else {
-           die "unknown btrfs mode '$filesys'\n";
-       }
+sub apply_raid_disk_selection {
+    Proxmox::Install::Config::set_key('disk_selection', {}); # reset
+    for my $order (sort keys $gtk_state->{disk_selection}->%*) {
+       my $disk = $gtk_state->{disk_selection}->{$order} // next;
+       Proxmox::Install::Config::set_disk_selection($order, $disk->[0]);
     }
-
-    return ($devlist, $mode);
 }
 
 my $last_hd_selected = 0;
@@ -2678,9 +1426,11 @@ sub create_hdsel_view {
 
     my $cached_disks = get_cached_disks();
     my ($disk, $devname, $size, $model, $logical_bsize) = $cached_disks->[0]->@*;
-    $target_hd = $devname if !defined($target_hd);
+    if (!defined(Proxmox::Install::Config::get_target_hd())) {
+       Proxmox::Install::Config::set_target_hd($devname);
+    }
 
-    $target_hd_label = Gtk3::Label->new("Target Harddisk");
+    $target_hd_label = Gtk3::Label->new("Target Harddisk");
     $hbox->pack_start($target_hd_label, 0, 0, 0);
 
     $target_hd_combo = Gtk3::ComboBoxText->new();
@@ -2690,9 +1440,10 @@ sub create_hdsel_view {
        $target_hd_combo->append_text(get_device_desc($devname, $size, $model));
     }
 
-    my $raid = $config_options->{filesys} =~ m/zfs|btrfs/;
+    my $raid = Proxmox::Install::Config::get_filesys() =~ m/zfs|btrfs/;
     if ($raid) {
-       $target_hd_label->set_text("Target: $config_options->{filesys} ");
+       my $filesys = Proxmox::Install::Config::get_filesys();
+       $target_hd_label->set_text("Target: $filesys ");
        $target_hd_combo->set_visible(0);
        $target_hd_combo->set_no_show_all(1);
     }
@@ -2701,7 +1452,7 @@ sub create_hdsel_view {
        $a = shift->get_active;
        my ($disk, $devname) = @{@$cached_disks[$a]};
        $last_hd_selected = $a;
-       $target_hd = $devname;
+       Proxmox::Install::Config::set_target_hd($devname);
     });
 
     $hbox->pack_start($target_hd_combo, 0, 0, 10);
@@ -2716,31 +1467,34 @@ sub create_hdsel_view {
     Proxmox::UI::display_html('page1.htm');
 
     set_next(undef, sub {
-
-       if ($config_options->{filesys} =~ m/zfs/) {
-           my ($devlist) = eval { get_zfs_raid_setup() };
+       my $filesys = Proxmox::Install::Config::get_filesys();
+       if ($filesys =~ m/zfs/) {
+           apply_raid_disk_selection();
+           my ($devlist) = eval { Proxmox::Install::get_zfs_raid_setup() };
            if (my $err = $@) {
                Proxmox::UI::message("Warning: $err\nPlease fix ZFS setup first.");
                return;
            }
-           $config_options->{target_hds} = [ map { $_->[1] } @$devlist ];
-       } elsif ($config_options->{filesys} =~ m/btrfs/) {
-           my ($devlist) = eval { get_btrfs_raid_setup() };
+           $target_hds = [ map { $_->[1] } @$devlist ];
+       } elsif ($filesys =~ m/btrfs/) {
+           apply_raid_disk_selection();
+           my ($devlist) = eval { Proxmox::Install::get_btrfs_raid_setup() };
            if (my $err = $@) {
                Proxmox::UI::message("Warning: $err\nPlease fix BTRFS setup first.");
                return;
            }
-           $config_options->{target_hds} = [ map { $_->[1] } @$devlist ];
+           $target_hds = [ map { $_->[1] } @$devlist ];
        } else {
+           my $target_hd = Proxmox::Install::Config::get_target_hd();
            eval {
                my $target_block_size = Proxmox::Sys::Block::logical_blocksize($target_hd);
-               legacy_bios_4k_check($target_block_size);
+               Proxmox::Install::legacy_bios_4k_check($target_block_size);
            };
            if (my $err = $@) {
                Proxmox::UI::message("Warning: $err\n");
                return;
            }
-           $config_options->{target_hds} = [ $target_hd ];
+           $target_hds = [ $target_hd ];
        }
 
        $step_number++;
@@ -2749,7 +1503,6 @@ sub create_hdsel_view {
 }
 
 sub create_extract_view {
-
     cleanup_view();
 
     Proxmox::Install::display_info();
@@ -2775,32 +1528,35 @@ sub create_extract_view {
 
     $gtk_state->{inbox}->show_all();
 
-    my $tdir = is_test_mode() ? "target" : "/target";
-    mkdir $tdir;
-    my $base = "${proxmox_cddir}/$iso_env->{product}-base.squashfs";
-
-    eval  { extract_data($base, $tdir); };
+    eval  { Proxmox::Install::extract_data() };
     my $err = $@;
 
     $gtk_state->{next_btn}->set_sensitive(1);
 
     set_next("_Reboot", sub { app_quit(0); } );
 
+    my $autoreboot = Proxmox::Install::Config::get_autoreboot();
+    my $autoreboot_seconds = 5;
     my $success_transform = sub {
        my ($raw_html, $iso_env) = @_;
 
-       my $addr = $ipversion == 6 ? "[${ipaddress}]" : "$ipaddress";
+       my $ip_addr = Proxmox::Install::Config::get_ip_addr();
+       my $ip_version = Proxmox::Install::Config::get_ip_version();
+
+       my $addr = $ip_version == 6 ? "[${ip_addr}]" : "$ip_addr";
        $raw_html =~ s/__IPADDR__/$addr/g;
        $raw_html =~ s/__PORT__/$iso_env->{cfg}->{port}/g;
 
-       my $autoreboot_msg = $config_options->{autoreboot}
-           ? "Automatic reboot scheduled in $autoreboot_seconds seconds."
-           : '';
+       my $autoreboot_msg = $autoreboot ? "Automatic reboot scheduled in $autoreboot_seconds seconds." : '';
        $raw_html =~ s/__AUTOREBOOT_MSG__/$autoreboot_msg/;
 
        return $raw_html;
     };
 
+    # It does not make sense to Abort the install at this point, whether it
+    # succeded or failed makes no difference.
+    $gtk_state->{abort_btn}->set_sensitive(0);
+
     if ($err) {
        Proxmox::UI::display_html("fail.htm");
        # suppress "empty" error as we got some case where the user choose to abort on a prompt,
@@ -2810,11 +1566,12 @@ sub create_extract_view {
        cleanup_view();
        Proxmox::UI::display_html("success.htm", $success_transform);
 
-        if ($config_options->{autoreboot}) {
+        if ($autoreboot) {
            Glib::Timeout->add(1000, sub {
                if ($autoreboot_seconds > 0) {
                    $autoreboot_seconds--;
                    Proxmox::UI::display_html("success.htm", $success_transform);
+                   return 1; # re-schedule, undef isn't enough anymore since Bookworm
                } else {
                    app_quit(0);
                }
@@ -2829,24 +1586,23 @@ sub create_intro_view {
 
     cleanup_view();
 
+    my $run_env = Proxmox::Install::RunEnv::get();
     if (int($run_env->{total_memory}) < 1024) {
        Proxmox::UI::error("Less than 1 GiB of usable memory detected, installation will probably fail.\n\n".
            "See 'System Requirements' in the $iso_env->{cfg}->{fullname} documentation.");
     }
 
-    if ($iso_env->{product} eq 'pve') {
-       my $cpuinfo = eval { file_read_all('/proc/cpuinfo') };
-       if (!$cpuinfo || $cpuinfo !~ /^flags\s*:.*(vmx|svm)/m) {
-           Proxmox::UI::error(
-               "No support for hardware-accelerated KVM virtualization detected.\n\n"
-               ."Check BIOS settings for Intel VT / AMD-V / SVM."
-           );
-       }
+    if ($iso_env->{product} eq 'pve' && !$run_env->{hvm_supported}) {
+       Proxmox::UI::error(
+           "No support for hardware-accelerated KVM virtualization detected.\n\n"
+           ."Check BIOS settings for Intel VT / AMD-V / SVM."
+       );
     }
 
     Proxmox::UI::display_html('license.htm', sub {
        my ($raw_html, $iso_env) = @_;
 
+       my $proxmox_cddir = $iso_env->{locations}->{iso};
        my $license = eval { decode('utf8', file_read_all("${proxmox_cddir}/EULA")) };
        if (my $err = $@) {
            die $err if !is_test_mode();
@@ -2863,16 +1619,10 @@ sub create_intro_view {
     set_next("I a_gree", \&create_hdsel_view);
 }
 
-$ipconf = Proxmox::Sys::Net::get_ip_config();
-
-if (!defined($iso_env->{locales}->{country}->{$country})) {
-    log_warn("ignoring detected country '$country', invalid or unknown\n");
-    $country = undef;
-}
-
+log_info("initializing GTK and creating main window...");
 Gtk3::init();
 
-create_main_window ();
+create_main_window();
 
 my $initial_error = 0;
 
@@ -2892,7 +1642,8 @@ my $initial_error = 0;
     }
 }
 
-if (!$initial_error && (scalar keys %{ $ipconf->{ifaces} } == 0)) {
+my $run_env = Proxmox::Install::RunEnv::get();
+if (!$initial_error && (scalar keys $run_env->{ipconf}->{ifaces}->%* == 0)) {
     print STDERR "no network interfaces found\n";
     $initial_error = 1;
     Proxmox::UI::display_html("nonics.htm");