all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: trim /etc/kernel/cmdline before appending
@ 2021-11-10 14:15 Stoiko Ivanov
  2021-11-10 14:28 ` Dominik Csapak
  0 siblings, 1 reply; 3+ messages in thread
From: Stoiko Ivanov @ 2021-11-10 14:15 UTC (permalink / raw)
  To: pve-devel

following the commit of removing the wrong indentation of the linux
and initrd lines - this commit strips empty lines (and leading
trailing whitespace) in /etc/kernel/cmdline.

I managed to reproduce the issue reported in the forum [0] by adding
empty lines to /etc/kernel/cmdline) - without this - systemd-boot
booted quite happily even with the indentation.

quickly tested on a VM.

[0]: https://forum.proxmox.com/threads/problem-with-proxmox-boot-tool.99043/

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 proxmox-boot/zz-proxmox-boot | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot
index 52171b2..2356c74 100755
--- a/proxmox-boot/zz-proxmox-boot
+++ b/proxmox-boot/zz-proxmox-boot
@@ -50,7 +50,7 @@ update_esps() {
 	    exit 0
 	fi
 	if [ -f /etc/kernel/cmdline ]; then
-		CMDLINE="$(cat /etc/kernel/cmdline)"
+		CMDLINE="$(sed -re '/^\s*$/d;s/^\s+(\S*)\s+$/\1/g' /etc/kernel/cmdline)"
 	else
 		warn "No /etc/kernel/cmdline found - falling back to /proc/cmdline"
 		# remove initrd entries
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: trim /etc/kernel/cmdline before appending
  2021-11-10 14:15 [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: trim /etc/kernel/cmdline before appending Stoiko Ivanov
@ 2021-11-10 14:28 ` Dominik Csapak
  2021-11-10 14:48   ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2021-11-10 14:28 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stoiko Ivanov

comment inline

On 11/10/21 15:15, Stoiko Ivanov wrote:
> following the commit of removing the wrong indentation of the linux
> and initrd lines - this commit strips empty lines (and leading
> trailing whitespace) in /etc/kernel/cmdline.
> 
> I managed to reproduce the issue reported in the forum [0] by adding
> empty lines to /etc/kernel/cmdline) - without this - systemd-boot
> booted quite happily even with the indentation.
> 
> quickly tested on a VM.
> 
> [0]: https://forum.proxmox.com/threads/problem-with-proxmox-boot-tool.99043/
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>   proxmox-boot/zz-proxmox-boot | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot
> index 52171b2..2356c74 100755
> --- a/proxmox-boot/zz-proxmox-boot
> +++ b/proxmox-boot/zz-proxmox-boot
> @@ -50,7 +50,7 @@ update_esps() {
>   	    exit 0
>   	fi
>   	if [ -f /etc/kernel/cmdline ]; then
> -		CMDLINE="$(cat /etc/kernel/cmdline)"
> +		CMDLINE="$(sed -re '/^\s*$/d;s/^\s+(\S*)\s+$/\1/g' /etc/kernel/cmdline)"

while the first  part of the regex looks good (delete all lines that 
only contain whitespace (or nothing), the second part will often not 
trigger since there is not *only* non-whitespace in the middle?

should it not be more like:

'^\s+(.*?)\s+$/\1/g' ?



>   	else
>   		warn "No /etc/kernel/cmdline found - falling back to /proc/cmdline"
>   		# remove initrd entries
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: trim /etc/kernel/cmdline before appending
  2021-11-10 14:28 ` Dominik Csapak
@ 2021-11-10 14:48   ` Thomas Lamprecht
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-11-10 14:48 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak, Stoiko Ivanov

On 10.11.21 15:28, Dominik Csapak wrote:
> comment inline
> 
> On 11/10/21 15:15, Stoiko Ivanov wrote:
>> following the commit of removing the wrong indentation of the linux
>> and initrd lines - this commit strips empty lines (and leading
>> trailing whitespace) in /etc/kernel/cmdline.
>>
>> I managed to reproduce the issue reported in the forum [0] by adding
>> empty lines to /etc/kernel/cmdline) - without this - systemd-boot
>> booted quite happily even with the indentation.
>>
>> quickly tested on a VM.
>>
>> [0]: https://forum.proxmox.com/threads/problem-with-proxmox-boot-tool.99043/
>>
>> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
>> ---
>>   proxmox-boot/zz-proxmox-boot | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot
>> index 52171b2..2356c74 100755
>> --- a/proxmox-boot/zz-proxmox-boot
>> +++ b/proxmox-boot/zz-proxmox-boot
>> @@ -50,7 +50,7 @@ update_esps() {
>>           exit 0
>>       fi
>>       if [ -f /etc/kernel/cmdline ]; then
>> -        CMDLINE="$(cat /etc/kernel/cmdline)"
>> +        CMDLINE="$(sed -re '/^\s*$/d;s/^\s+(\S*)\s+$/\1/g' /etc/kernel/cmdline)"
> 
> while the first  part of the regex looks good (delete all lines that only contain whitespace (or nothing), the second part will often not trigger since there is not *only* non-whitespace in the middle?
> 
> should it not be more like:
> 
> '^\s+(.*?)\s+$/\1/g' ?

or just care for trailing whitespaces, i.e. use `head -n 1 /etc/kernel/cmdline` ?

Or alternatively using read should work too:
read -r CMDLINE < /etc/kernel/cmdline 

Important in general is that we only get a single line to not break tools that expect
that during the boot process.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-10 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 14:15 [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: trim /etc/kernel/cmdline before appending Stoiko Ivanov
2021-11-10 14:28 ` Dominik Csapak
2021-11-10 14:48   ` Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal