1

I am just getting started in Kernel hacking and want to build a kernel that will not launch an OS GUI but instead just go to a terminal command prompt. This is an attempt to debug an issue I'm having. I'm not sure what configuration settings I should be looking at to try and do this. I've been unable to find this info on my own, could someone please point me in the right direction? Also, tips on grepping through the Kconfig files to try and find this info on my own in the future would also be appreciated.

Thank you.

  • Are you using grub? What init system are you using (sysvinit, upstart, systemd)? – Mark Plotnick Feb 23 '16 at 15:20
  • I am using Fedora 23, which I understand uses grub2 and systemd I believe. I will attempt the suggestions below later today, thank you. – Tyler Feb 23 '16 at 16:50
  • Fedora 23 has a recovery option in GRUB, boot into that and ask to get to a root shell. – Naftuli Kay Feb 23 '16 at 19:31
1

This isn't determined by the kernel. It's a boot option. If your system is using systemd, use the systemctl command to set the boot target. Don't circumvent the proper systemd command and make modifications to the file system to accomplish this. Instead, as root, use:

systemctl set-default multi-user.target

You can revert back to your GUI target with:

systemctl set-default graphical.target
  • Thank you very much. Your further explanation on safe procedures and ways to revert the changes were appreciated. Following these directions I was able to successfully boot to a shell. – Tyler Feb 24 '16 at 3:26
6

Which GUI is started at boot is not dependent on the kernel build, any kernel can do this. Depending on your distribution the GUI enviornment is loaded by some service manager or a set of init scripts.

In case of systemd you can remove /usr/lib/systemd/system/multi-user.target link and you will be loaded into a so called shell enviornment at boot.

3

A complementary answer if you're using systemd (many recent distributions do):

ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target

multi-user means you'll get an environment with login terminals and most services (so SSH logins are possible), just without graphical server. It's a close equivalent of runlevel 3 in sysvinit-based systems

1

In order to accomplish this, you need to set your initdefault to run level 3. You can do it as follows:

cp /etc/inittab /etc/inittab.bak #good idea to make a backup of /etc/inittab  
sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab
1

Try adding the kernel command line argument init=/bin/bash and see what happens ... (you will probably need to use the edit command in grub, by typing e at the right time during boot - when it displays the grub menu)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.