DEV Community

Waylon Walker
Waylon Walker

Posted on • Originally published at waylonwalker.com

A TTY Can Save Your Bacon

I recently was unable to boot into my home Linux Desktop, it got stuck at diskcheck fsck. I found that I was able to get in to a tty through a hotkey.

Did a sudo apt update && upgrade last night, power got tripped off couldnt reboot, had to reinstall my display manager from a tty.

— Waylon Walker 🐍 (@_WaylonWalker) April 8, 2022

What's a TTY?

There's probably more to it, but to me its a full screen terminal with zero gui, not even your gui fonts. It does log into your default shell so if you have a comfy command line setup it will be here for you even though it looks much different without fonts and full colorspace.

Normal setup

Normally you have 6 TTY's running, the first is dedicated to your desktop manager, which is your login screen it might be something like gdm or lightdm.

  • ctrl+alt+F1: login screen
  • ctrl+alt+F2: Desktop
  • ctrl+alt+F3: TTY 3
  • ctrl+alt+F4: TTY 4
  • ctrl+alt+F5: TTY 5
  • ctrl+alt+F6: TTY 6

In my case the desktop manager neverstarted, so ctrl+alt+F1 brought me into a tty.

What happened??

Well after getting back in and having some time to reflect, I think my Desktop manager was installed or just broken, possibly during a update I ran a few days prior.

I tried a bunch of things like switching to lightdm, and manually running startx.

Getting back in

The final commands that ended up getting me back in were installing and starting gdm3.

sudo apt install gdm3 sudo systemctl start gdm3
Enter fullscreen mode Exit fullscreen mode

Discussion (3)

Collapse
gjorgivarelov profile image
gjorgivarelov

You mentioned loss of power during an upgrade, that would trick any Linux into checking the filesystem for errors and loss of data. It wasn't the faulty upgrade, it was that you lost power abruptly during your system's operation.
Did you wait for fsck to finish its work? fsck (filesystem check) isn't a fast utility.
Any Linux system operates on different runlevels: depending on user settings, system resources and seemingly catastrophic occurences, a different set of interactive tools will be made available to you to interact with the system. Every runlevel has a set of sensible defaults and on a normally booted system you can switch between runlevels, or in the new systemd parlance they are called targets, each target depending on the previous one to be loaded to start, which on turn depends on system resources to become available.
Start playing with switching between runlevels/targets on your system while in normal operation so that in case you start thinking that GUI isn't available, you would know how to revert back to GUI. In the incident you described above, GUI wouldn't be available while fsck is running anyway...

Collapse
waylonwalker profile image
Waylon Walker Author

Did you wait for fsck to finish its work?

Ya I put kids to bed and came back hours later to fine id still at 7xxx/7xxx complete. the fsck was complete as far as I could tell.

Collapse
geraldew profile image
geraldew

I'm glad I haven't had to do this kind of thing for a long time. That said, I like this piece as a simple example to show that a broken install or update can be just a single command away from repair and back to normal.

Sorry to nitpick, but perhaps you meant "display manager" rather than desktop manager (although that's probably a better name for it really).