You are not logged in.
I'm thinking of trying to boot a system with just the kernel and maybe a bootloader, and a single process of my own creation. As a first step, I'm just trying to set init for the kernel with
init=/bin/bash
in the bootloader on my current full-fledged system (arch with I think either gummiboot or systemd-boot). Unfortunately I get an error and I can't interact in any way (not even key echoing)
:: running early hook [udev]
Starting version 247.2-1-arch
:: running hook [udev]
:: Triggering uevents...
:: performing fsck on '/dev/nvmc0n1p2'
/dev/nvmc0n1p2: clean, 422674/15564800 files, 47331349/62252544 blocks
:: mounting /dev/nvme0n1p2' on real root
:: running cleanup hook [udev]
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
[root@archlinux /]#
(copied by hand, so it may not be correct character for character)
Searching the internet I found these:
https://lists.gnu.org/archive/html/bug- … 00097.html
https://stackoverflow.com/questions/320 … -ioctl-for (not me, but similar error. I can't even enter a command like it looks like he could)
But it's not clear to me exactly what's going on in my case or how to fix it. Are /dev/console and /dev/tty set up by the kernel or init? Where do the virtual consoles Ctrl-Alt-F# fit into the process? It sounds like init=/bin/bash is a fairly common thing to do, for example to fix a forgotten root password, so I'm wondering if this issue is more with a (usb) keyboard detection or driver. Are the keyboards typically set up with systemd/udev and I'm bypassing that? Do I need to add a keyboard driver to my initramfs?
Does anyone know what's going on? Thank you
Last edited by iith4ahm (2021-01-11 17:38:10)
Offline
https://forums.gentoo.org/viewtopic-t-1 … art-0.html
https://wiki.gentoo.org/wiki/Custom_Ini … ob_control
The input likely fails because no sysfs/dev/devpts is setup (see the init script in the gentoo thread)
Offline
The input likely fails because no sysfs/dev/devpts is setup (see the init script in the gentoo thread)
Thanks Seth. What do you mean by "no sysfs/dev/devpts" is setup? I leaned that I can run commands in the init script and they will show on the screen - I just can't interact with the keyboard. /dev, /sys, and /proc seem to be populated when the script is run. Does that mean they are "set up"?
If I run (from the gentoo script, but I swapped out an echo command for tty)
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export HOME=/root
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev
tty
bash
I get the original output with the addition of
mount: /sys: none already mounted on /proc.
mount: /dev: none already mounted on /proc
not a tty
Running the bash program and redirecting stdin, stdout and stderr to /dev/tty7 got rid of the bash error, but I still could not do anything. I tried doing the same thing and running it in the background with
/bin/bash </dev/tty7 >/dev/tty7 2>&1 &
but that caused a "kernel panic - not syncing: Attempted to kill init!". I'm guessing init is not supposed to finish.
Also, if it could be related to what's going on:
When I boot my system up normally, it doesn't go right into a display manager or a console. It leaves me with the output of the kernel and/or systemd. I can't type anything. If I press Ctl-Alt-1 it does nothing just like when I run my custom init. However, if I first press Ctl-Alt-2 I do get a virtual terminal, and then when I press Ctl-Alt-1 gnome starts up. It's been this way for a while. The difference with my init script is that I can't Ctl-Alt-anything.
Last edited by iith4ahm (2021-01-12 15:47:04)
Offline
What do you mean by "no sysfs/dev/devpts" is setup?
…
/dev, /sys, and /proc seem to be populated when the script is run.
That. Unfortunately.
When I boot my system up normally, it doesn't go right into a display manager or a console. It leaves me with the output of the kernel and/or systemd. I can't type anything. If I press Ctl-Alt-1 it does nothing just like when I run my custom init. However, if I first press Ctl-Alt-2 I do get a virtual terminal, and then when I press Ctl-Alt-1 gnome starts up.
Could be either an entropy issue or the GPU stalls.
Did you try
setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
(do NOT fork the command!)
The important part is setsid and you may have to pass absolute paths.
Offline
#!/bin/bash
setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
gives me
sh-5.1#
with the same unresponsive keyboard. If I try to run that command with init= instead of from a bash script I get
ERROR: Root device mounted successfully, but setsid does not exist.
Bailing out, you are on your own. Good luck.
sh: can't access tty: job control turned off
[rootfs ]# _
Again with no ability to interact. I'm assuming the kernel would have needed a full path name.
Could be either an entropy issue or the GPU stalls.
Do you think this could be the cause of everything? There are a lot of yellow NVIDIA message in journalctl. I will update below:
Extract:
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE) Screen 0 deleted because of no matching config section.
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (II) UnloadModule: "modesetting"
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE) Device(s) detected, but none match those in the config file.
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE)
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: Fatal server error:
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE) no screens found(EE)
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE)
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: Please consult the The X.Org Foundation support
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: at http://wiki.x.org
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: for help.
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE)
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[495]: (EE) Server terminated with error (1). Closing log file.
Jan 13 14:25:36 lava /usr/lib/gdm-x-session[493]: Unable to run X server
Do you think if I sort out these driver/X issues my init=/bin/bash problem will take care of itself?
But why are X and systemd running in the first place? Aren't they in userspace, and I'm bypassing them by passing the init kernel parameter? -Oh, since I'm using systemd-boot, does that let systemd start doing its thing right away and not wait for the kernel to start it? If I switch bootloaders should I get a systemd/X free system, and maybe the kernel will get me a responsive tty?
Last edited by iith4ahm (2021-01-13 21:13:05)
Offline
It should rid you of the error message?
About the keyboard: you could have the script print "lsmod" and compare that to a normal session (in case you rely on some explicitly loaded modules for the keyboard)
Is this an integrated keyboard or an external one? Do you have a replacement option (ie. another keyboard to attach)?
Offline