syscmd("zfs create $pool_name/ROOT") == 0 || die "unable to create zfs $pool_name/ROOT 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";
+
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 -o mountpoint=/$pool_name/ROOT/$root_volume_name/var/lib/vz $pool_name/var-lib-vz") == 0 ||
+ die "unable to create zfs $pool_name/var-lib-vz 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";
$value = $zfs_opts->{copies} // 1;
syscmd("zfs set copies=$value $pool_name") if defined($value) && $value != 1;
+
+ syscmd("zfs set acltype=posix $pool_name/ROOT/$root_volume_name");
}
my $get_raid_devlist = sub {
my $cached_disks = get_cached_disks();
my $devlist = [];
for (my $i = 0; $i < @$cached_disks; $i++) {
- next if !Proxmox::Install::Config::get_disk_selection($i);
+ my $disk_id = Proxmox::Install::Config::get_disk_selection($i) // next;
- my $hd = $cached_disks->[$i];
+ my $hd = $cached_disks->[$disk_id];
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;
return ($devlist, $cmd);
}
+# If the maximum ARC size for ZFS was explicitly changed by the user, applies
+# it to the new system by setting the `zfs_arc_max` module parameter in /etc/modprobe.d/zfs.conf
+my sub zfs_setup_module_conf {
+ my ($targetdir) = @_;
+
+ my $arc_max_mib = Proxmox::Install::Config::get_zfs_opt('arc_max');
+ my $arc_max = Proxmox::Install::RunEnv::clamp_zfs_arc_max($arc_max_mib) * 1024 * 1024;
+
+ if ($arc_max > 0) {
+ file_write_all("$targetdir/etc/modprobe.d/zfs.conf", "options zfs zfs_arc_max=$arc_max\n")
+ }
+}
+
sub get_btrfs_raid_setup {
my $filesys = Proxmox::Install::Config::get_filesys();
my $diskcount = scalar(@$devlist);
die "$filesys needs at least one device\n" if $diskcount < 1;
+ foreach my $hd (@$devlist) {
+ legacy_bios_4k_check(@$hd[4]);
+ }
+
my $mode;
if ($diskcount == 1) {
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;
+ $rootsize_mb = ($rest_mb - 4) & ~3;
} elsif ($rest_mb < 48 * 1024) {
my $masked = int($rest_mb / 2) & ~3; # align down to 4 MB
$rootsize_mb = $masked;
$rootsize_mb = $maxroot_mb if $rootsize_mb > $maxroot_mb;
$rootsize = int($rootsize_mb * 1024);
+ $rootsize &= ~0xFFF; # align down to 4 MB boundaries
$rest -= $rootsize; # in KB
die "unable to create root volume\n";
if ($datasize > 4 * 1024 * 1024) {
- my $metadatasize = $datasize/100; # default 1% of data
+ my $metadatasize = int($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
+ $metadatasize &= ~0xFFF; # align down to 4 MB boundaries
# otherwise the metadata is taken out of $minfree
$datasize -= 2 * $metadatasize;
chomp;
my $path = $_;
my ($deb) = $path =~ m/${proxmox_pkgdir}\/(.*\.deb)/;
+
+ # the grub-pc/grub-efi-amd64 packages (w/o -bin) are the ones actually updating grub
+ # upon upgrade - and conflict with each other - install the fitting one only
+ next if ($deb =~ /grub-pc_/ && $run_env->{boot_type} ne 'bios');
+ next if ($deb =~ /grub-efi-amd64_/ && $run_env->{boot_type} ne 'efi');
+
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
}
syscmd("chroot $targetdir /bin/chown clamav:clamav -R /var/lib/clamav") == 0 ||
die "unable to set owner for clamav database files\n";
+
+ # on-access scanner (blocks file access if it thinks file is bad) needs to be explicit
+ # configured by the user, otherwise it fails, and it doesn't make sense for most users.
+ unlink "$targetdir/etc/systemd/system/multi-user.target.wants/clamav-clamonacc.service"
+ or warn "failed to disable clamav-clamonacc.service - $!";
}
if ($iso_env->{product} eq 'pve') {
}
update_progress(0.8, 0.95, 1, "make system bootable");
+ my $target_cmdline='';
+ if ($target_cmdline = Proxmox::Install::Config::get_target_cmdline()) {
+ my $target_cmdline_snippet = '';
+ if ($target_cmdline =~ /console=ttyS(\d+),(\d+)/) {
+ $target_cmdline_snippet .= "GRUB_TERMINAL_INPUT=\"console serial\"\n";
+ $target_cmdline_snippet .= "GRUB_TERMINAL_OUTPUT=\"gfxterm serial\"\n";
+ $target_cmdline_snippet .= "GRUB_SERIAL_COMMAND=\"serial --unit=$1 --speed=$2\"\n";
+ }
+ $target_cmdline_snippet .= "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $target_cmdline\"";
+ file_write_all("$targetdir/etc/default/grub.d/installer.cfg", $target_cmdline_snippet);
+ }
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");
+ file_write_all("$targetdir/etc/kernel/cmdline", "root=ZFS=$zfs_pool_name/ROOT/$zfs_root_volume_name boot=zfs $target_cmdline\n");
+ zfs_setup_module_conf($targetdir);
}
diversion_remove($targetdir, "/usr/sbin/update-grub");
syscmd("zfs set mountpoint=/ $zfs_pool_name/ROOT/$zfs_root_volume_name") == 0 ||
die "zfs set mountpoint failed\n";
+ if ($iso_env->{product} eq 'pve') {
+ syscmd("zfs set mountpoint=/var/lib/vz $zfs_pool_name/var-lib-vz") == 0 ||
+ die "zfs set mountpoint for var-lib-vz failed\n";
+ }
+
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");