From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 1/4] fix #4747: pass kernel cmdline parameters to target system
Date: Thu, 16 Nov 2023 16:00:38 +0100 [thread overview]
Message-ID: <20231116150041.1089432-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20231116150041.1089432-1-s.ivanov@proxmox.com>
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 | 11 +++++------
Proxmox/Install/Config.pm | 25 +++++++++++++------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
index 66adb2d..c868992 100644
--- a/Proxmox/Install.pm
+++ b/Proxmox/Install.pm
@@ -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);
}
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index 5e80255..b1acebc 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -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;
--
2.39.2
next prev parent reply other threads:[~2023-11-16 15:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-16 15:00 [pve-devel] [PATCH installer 0/4] adaptation to kernel cmdline handling and 2 small ZFS related improvements Stoiko Ivanov
2023-11-16 15:00 ` Stoiko Ivanov [this message]
2023-11-16 15:00 ` [pve-devel] [PATCH installer 2/4] unconfigured.sh: set serial to a number to prevent warning Stoiko Ivanov
2023-11-16 15:00 ` [pve-devel] [PATCH installer 3/4] fix #1410: zfs: create /var/lib/vz as separate dataset Stoiko Ivanov
2023-11-16 16:31 ` Stoiko Ivanov
2023-11-16 15:00 ` [pve-devel] [PATCH installer 4/4] zfs: set acltype=posix for root-dataset Stoiko Ivanov
2023-11-16 16:46 ` [pve-devel] applied-series: [PATCH installer 0/4] adaptation to kernel cmdline handling and 2 small ZFS related improvements Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231116150041.1089432-2-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox