Ubuntu 16.04.5 default environment.
I want to do some custom job before init. grub.cfg as
linux /boot/vmlinuz ... ro init=/root/init.sh
init.sh:
#!/bin/bash
# do some task
exec init 3
after boot, X started.
if grub
linux /boot/vmlinuz ... ro init=/root/init.sh 3
,can success boot into text mode.
according to https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html , 3 is not a kernel’s command-line parameters, kernel will pass it as an argument to init, here is /root/init.sh.
change /root/init.sh to :
#!/bin/bash
# do some task
echo $1
sleep 3s
exec init 3
I can see the value passed from kernel.
In my submission,no matter what value grub -> kernel -> /root/init.sh , I will discard the value and exec init as runlevel 3. why it doesn't work.