Here are a series of commands to get Ubuntu 18.04 to boot into terminal mode, with various extras on how to get an automatic menu on boot up.
Skipping Graphical Boot
If you want to skip the graphical login screen, hit [Shift] or [Esc] before you see the grub menu to get to the grub menu. Add these features to the linux command:
systemd.unit=multi-user.target
Then hit Ctrl-X.
Changing the Default Boot Target
Become root. In /lib/systemd/system, change the default.target symlink:
# rm default.target; ln -s multi-user.target default.target # systemctl daemon-reload
Checking the Filesystem Every Boot
If you do the first command above with a semicolon, you can still use tab-completion. Next, we go to /etc/default and update the grub settings:
# cd /etc/default # vim grub Change GRUB_CMDLINE_LINUX_DEFAULT to this value: "fsck.mode=force fsck.repair=yes"
Run update-grub2:
# update-grub2
Reinforce this behavior by using tune2fs to make each file system run a check each boot. What file systems are you running?
# lsblk -o NAME,MOUNTPOINT # will produce output kinda like: sda sda1 /boot sda2 / sda3 [SWAP] sda4 /home
Running these command will make sda1, sda2, sda4 all check every mount:
# tune2fs -c1 /dev/sda1 # tune2fs -c1 /dev/sda2 # tune2fs -c1 /dev/sda4
Reboot:
# reboot
That shouldn’t take too long. You have a tty login now.
Creating an Automatic Menu
I’m disabling a few things:
systemctl disable snapd.service wpa_supplicant.service unattended-upgrades.service cups-browserd.service cups.service systemctl daemon-reload
There will be lots of snaps you don’t want:
snap list --all | awk '/gnome|gtk/{print $1, $2}' | while read snapname snaprevision; do snap remove "$snapname" --revision="$snaprevision"; done This didn't work well, maybe snap remove "$snapname" is enough
You are logged in on tty1 by default. (I don't know why tty0 exists.) Following this guide, create this directory: # cd /etc/systemd/system # mkdir getty@tty1.service.d # cd getty@tty1.service.d # vim override.conf [Service] ExecStart= ExecStart=-/root/onboot.bash StandardInput=tty StandardOutput=tty
# vim /root/onboot.bash #!/bin/bash echo "This is a sound recorder appliance. Hit a key to start recording." RECORDING=0 while true; do read -sn1 KEY if [[ $RECORDING = 0 ]]; then RECORDING=1 echo "Now recording" /root/start-recording.bash else RECORDING=0 echo "Recording stopped" /root/stop-recording.bash fi done
# chmod +x /root/onboot.bash # systemd daemon-reload # reboot
All you have to do then is record things with the start-recording.bash and stop-recording.bash scripts.