mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-08-15 09:02:07 +00:00
fix #4747: pass kernel cmdline parameters to target system
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>
This commit is contained in:
parent
c1279c8250
commit
a02a78a865
@ -1152,11 +1152,10 @@ _EOD
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_progress(0.8, 0.95, 1, "make system bootable");
|
update_progress(0.8, 0.95, 1, "make system bootable");
|
||||||
my $console_param='';
|
my $target_cmdline='';
|
||||||
if (my $console = Proxmox::Install::Config::get_console()) {
|
if ($target_cmdline = Proxmox::Install::Config::get_target_cmdline()) {
|
||||||
$console_param="console=$console";
|
my $target_cmdline_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $target_cmdline\"";
|
||||||
my $console_snippet = "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $console_param\"";
|
file_write_all("$targetdir/etc/default/grub.d/installer.cfg", $target_cmdline_snippet);
|
||||||
file_write_all("$targetdir/etc/default/grub.d/console.cfg", $console_snippet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_zfs) {
|
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\"";
|
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/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);
|
zfs_setup_module_conf($targetdir);
|
||||||
}
|
}
|
||||||
|
@ -16,36 +16,37 @@ my sub parse_kernel_cmdline {
|
|||||||
|
|
||||||
my $cmdline = Proxmox::Install::RunEnv::get('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;
|
$cfg->{filesys} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmdline =~ m/hdsize=(\d+(\.\d+)?)[\s\n]/i) {
|
if ($cmdline =~ s/\bhdsize=(\d+(\.\d+)?)\s?//i) {
|
||||||
$cfg->{hdsize} = $1;
|
$cfg->{hdsize} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmdline =~ m/swapsize=(\d+(\.\d+)?)[\s\n]/i) {
|
if ($cmdline =~ s/\bswapsize=(\d+(\.\d+)?)\s?//i) {
|
||||||
$cfg->{swapsize} = $1;
|
$cfg->{swapsize} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmdline =~ m/maxroot=(\d+(\.\d+)?)[\s\n]/i) {
|
if ($cmdline =~ s/\bmaxroot=(\d+(\.\d+)?)\s?//i) {
|
||||||
$cfg->{maxroot} = $1;
|
$cfg->{maxroot} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmdline =~ m/minfree=(\d+(\.\d+)?)[\s\n]/i) {
|
if ($cmdline =~ s/\bminfree=(\d+(\.\d+)?)\s?//i) {
|
||||||
$cfg->{minfree} = $1;
|
$cfg->{minfree} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $iso_env = Proxmox::Install::ISOEnv::get();
|
my $iso_env = Proxmox::Install::ISOEnv::get();
|
||||||
if ($iso_env->{product} eq 'pve') {
|
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;
|
$cfg->{maxvz} = $1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmdline =~ m/console=(\S+)[\s\n]?/i) {
|
$cmdline =~ s/(?:BOOT_IMAGE|root|ramdisk_size|splash|vga)=\S+\s?//gi;
|
||||||
$cfg->{console} = $1;
|
$cmdline =~ s/ro|rw|quiet|proxdebug|proxtui|nomodeset//gi;
|
||||||
}
|
|
||||||
|
$cfg->{target_cmdline}= $cmdline;
|
||||||
|
|
||||||
return $cfg;
|
return $cfg;
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ my sub init_cfg {
|
|||||||
cidr => undef,
|
cidr => undef,
|
||||||
gateway => undef,
|
gateway => undef,
|
||||||
dns => undef,
|
dns => undef,
|
||||||
console => undef,
|
target_cmdline => undef,
|
||||||
};
|
};
|
||||||
|
|
||||||
$initial = parse_kernel_cmdline($initial);
|
$initial = parse_kernel_cmdline($initial);
|
||||||
@ -235,8 +236,8 @@ sub get_gateway { return get('gateway'); }
|
|||||||
sub set_dns { set_key('dns', $_[0]); }
|
sub set_dns { set_key('dns', $_[0]); }
|
||||||
sub get_dns { return get('dns'); }
|
sub get_dns { return get('dns'); }
|
||||||
|
|
||||||
sub set_console { set_key('console', $_[0]); }
|
sub set_target_cmdline { set_key('target_cmdline', $_[0]); }
|
||||||
sub get_console { return get('console'); }
|
sub get_target_cmdline { return get('target_cmdline'); }
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user