]> git.proxmox.com Git - pve-installer.git/commitdiff
fix #4747: pass kernel cmdline parameters to target system
authorStoiko Ivanov <s.ivanov@proxmox.com>
Thu, 16 Nov 2023 15:00:38 +0000 (16:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 Nov 2023 15:29:20 +0000 (16:29 +0100)
Parameters needed for booting during installation are best preserved
in the target cmdline as well - e.g. if you need a particular
cmdline switch for your system to boot at all - not having to add it
for the first boot of the installed system and manually adding it to
the bootloader config is an improvement.

This additionally enables us to drop the console parameter handling
for serial consoles (it is just one of the parameters to pass along).

Finally it fixes the regular expressions for the installer settings we
read from the cmdline (swapsize, maxroot,...) which were broken if
added as last entry.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Proxmox/Install.pm
Proxmox/Install/Config.pm

index 66adb2dc5f262faac895c17c6da693d928e59c84..c8689927808e95e6f40844d9d8fe6745cc675245 100644 (file)
@@ -1152,11 +1152,10 @@ _EOD
        }
 
        update_progress(0.8, 0.95, 1, "make system bootable");
-       my $console_param='';
-       if (my $console = Proxmox::Install::Config::get_console()) {
-           $console_param="console=$console";
-           my $console_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $console_param\"";
-           file_write_all("$targetdir/etc/default/grub.d/console.cfg", $console_snippet);
+       my $target_cmdline='';
+       if ($target_cmdline = Proxmox::Install::Config::get_target_cmdline()) {
+           my $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) {
@@ -1164,7 +1163,7 @@ _EOD
            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 $console_param\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);
        }
index 5e8025542d3c71a9e8be8cb586e5a6c019546f43..b1acebc57a5585a2462d62cb014af913621c9bf4 100644 (file)
@@ -16,36 +16,37 @@ my sub parse_kernel_cmdline {
 
     my $cmdline = Proxmox::Install::RunEnv::get('kernel_cmdline');
 
-    if ($cmdline =~ m/\s(ext4|xfs)(\s.*)?$/) {
+    if ($cmdline =~ s/\b(ext4|xfs)\s?//i) {
        $cfg->{filesys} = $1;
     }
 
-    if ($cmdline =~ m/hdsize=(\d+(\.\d+)?)[\s\n]/i) {
+    if ($cmdline =~ s/\bhdsize=(\d+(\.\d+)?)\s?//i) {
        $cfg->{hdsize} = $1;
     }
 
-    if ($cmdline =~ m/swapsize=(\d+(\.\d+)?)[\s\n]/i) {
+    if ($cmdline =~ s/\bswapsize=(\d+(\.\d+)?)\s?//i) {
        $cfg->{swapsize} = $1;
     }
 
-    if ($cmdline =~ m/maxroot=(\d+(\.\d+)?)[\s\n]/i) {
+    if ($cmdline =~ s/\bmaxroot=(\d+(\.\d+)?)\s?//i) {
        $cfg->{maxroot} = $1;
     }
 
-    if ($cmdline =~ m/minfree=(\d+(\.\d+)?)[\s\n]/i) {
+    if ($cmdline =~ s/\bminfree=(\d+(\.\d+)?)\s?//i) {
        $cfg->{minfree} = $1;
     }
 
     my $iso_env = Proxmox::Install::ISOEnv::get();
     if ($iso_env->{product} eq 'pve') {
-       if ($cmdline =~ m/maxvz=(\d+(\.\d+)?)[\s\n]/i) {
+       if ($cmdline =~ s/\bmaxvz=(\d+(\.\d+)?)\s?//i) {
            $cfg->{maxvz} = $1;
        }
     }
 
-    if ($cmdline =~ m/console=(\S+)[\s\n]?/i) {
-           $cfg->{console} = $1;
-    }
+    $cmdline =~ s/(?:BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+\s?//gi;
+    $cmdline =~ s/ro|rw|quiet|proxdebug|proxtui|nomodeset//gi;
+
+    $cfg->{target_cmdline}= $cmdline;
 
     return $cfg;
 }
@@ -101,7 +102,7 @@ my sub init_cfg {
        cidr => undef,
        gateway => undef,
        dns => undef,
-       console => undef,
+       target_cmdline => undef,
     };
 
     $initial = parse_kernel_cmdline($initial);
@@ -235,8 +236,8 @@ sub get_gateway { return get('gateway'); }
 sub set_dns { set_key('dns', $_[0]); }
 sub get_dns { return get('dns'); }
 
-sub set_console { set_key('console', $_[0]); }
-sub get_console { return get('console'); }
+sub set_target_cmdline { set_key('target_cmdline', $_[0]); }
+sub get_target_cmdline { return get('target_cmdline'); }
 
 
 1;