HOWTO: Boot Debian Linux 3.1 without Graphical User Interface

Emmanuel KARTMANN (emmanuel@kartmann.org)

My Linux box hates me (The black screen of death)!

I'm new to Linux. I'm a rookie. I tried to install Debian Linux 3.1 (codename "sarge") on a Desktop PC with Windows XP Pro already installed on it...

And I messed up!

Big time. I tried to configure the X11/X-Windows graphical user interface in order to get a good resolution (1280x1024 pixels, 24 bits, nothing too fancy, no OpenGL or 3DFX...).

Since I don't know much about Linux, I just searched on the Web (thanks Google!) - and found a very buggy configuration file (XF86Config-4) with perfect match for my configuration (video card: ATI Radeon 9800 Pro, display Dell LCD E171FP). I tried to use this configuration... and Linux didn't boot anymore. All I had was a black screen (the black screen of death?)... No error message, no crash, nothing!

I couldn't find any place on the Web with a simple "HOW TO" boot Linux without Graphical User Interface (something very basic, with lots of explanations and reference documentation)... So I decided to write my own...

GRUB

GRUB (GRand Unified Bootloader) is the default boot loader for Debian Linux 3.1 (sarge). A boot loader is the first program launched when a computer starts; it's in charge of loading the operating system (e.g. Linux Debian), starting with the kernel.

Debian GRUB comes from the GNU project, and is very powerful... and thus complex! First, you should check the existing parameters for booting your Linux kernel; GRUB starts in menu interface mode, where you can choose an operating system with arrow keys, or the defaut operating system will be started:

You should see a GRUB prompt:
  grub> 

You can look for a specific kernel (e.g. Linux) with command find

  grub> find /vmlinuz
  (hd1,0)

There's only one Linux kernel available and it's on hard drive 1 (2nd drive since drive numbering starts at 0), partition 0 (first partition - watch out since many boot loaders start numbering partitions at 1!).

In order to boot a Multiboot-compliant operating system like Debian Linux, you have to:

  1. Set GRUB's root device to the drive where the OS images are stored with the command root.
  2. Load the kernel image with the command kernel.
  3. Create a RAM disk with the command initrd.
  4. Run the command boot.

Debian/Linux installs kernel and RAM disk images in "/boot" directory. However, it creates a symbolic link from "/vmlinuz" to the appropriate kernel (something like "/boot/vmlinuz-2.6.2-2-386") and another symbolic link from "/initrd.img" to the real RAM disk image (something like "/boot/initrd.img-2.6.8-2-386"). If you don't plan on booting with another kernel, there's no need to know (and to type !) the full file names: use the link names instead ("/vmlinuz" and "/initrd.img"), as shown below.

Kernel Parameters

The boot process consist in loading the kernel - and after that the operating system itself. Most kernels supports parameters in order to adapt the boot process.

On a working Debian Linux installation, you can learn about kernel parameters via man:

mycomputer:~# man bootparam
BOOTPARAM(7)               Linux Programmer's Manual              BOOTPARAM(7)

NAME
       bootparam - Introduction to boot time parameters of the Linux kernel

DESCRIPTION
...

A more detailed (and Debian-specific) documentation of kernel parameter can be downloaded on a running Linux machine by issues apt-get commands (for a kernel version 2.6.8):

mycomputer:~# apt-get install kernel-doc-2.6.8
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  kernel-doc-2.6.8
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 6175kB of archives.
After unpacking 16.1MB of additional disk space will be used.
Get:1 ftp://ftp.fr.debian.org stable/main kernel-doc-2.6.8 2.6.8-16 [6175kB]
Fetched 6175kB in 11s (519kB/s)
Selecting previously deselected package kernel-doc-2.6.8.
(Reading database ... 95290 files and directories currently installed.)
Unpacking kernel-doc-2.6.8 (from .../kernel-doc-2.6.8_2.6.8-16_all.deb) ...
Setting up kernel-doc-2.6.8 (2.6.8-16) ...

mycomputer:~# ls /usr/share/doc/kernel-doc-2.6.8/
Buildinfo.gz         copyright      Kconfig.collected.gz
changelog.Debian.gz  Documentation  README.Debian.gz

In particular, the "ro", "root=", "single" and "vga=" options are described in this package:

kernel-parameters.txt
	ro		[KNL] Mount root device read-only on boot

	root=		[KNL] Root filesystem

  S    [KNL] Run init in single mode

  vga= [BOOT,IA-32] Select a particular video mode
      See Documentation/i386/boot.txt and Documentation/svga.txt.
      Use vga=ask for menu.
      This is actually a boot loader parameter; the value is
      passed to the kernel using a special protocol.

	initrd=		[BOOT] Specify the location of the initial ramdisk

  initrd=
	An initrd should be loaded.  The meaning of  is
	obviously bootloader-dependent, and some boot loaders
	(e.g. LILO) do not have such a command.

In order to boot and login without a graphical user interface, you simply have to boot in single user mode (parameter "S" or "single") - which doesn't include the graphical user interface. Adding another parameter ("vga") also ensures that Linux won't use a video mode not supported by your video card or display.

My step by step solution

This section describes the step by step solution to my problem on my computer; you may have to adapt commands and parameter to acheive the same effect on your computer...

Use root command with kernel found previously by the find command

  grub> root (hd1,0)
  Filesystem type is ext2fs, partition type 0x83

Use kernel command with kernel found previously by the find command


  grub> kernel /vmlinuz root=/dev/hdb1 ro single vga=normal
  [Linux-bzImage, setup=0x1400, size=0x10a8cb]

Use initrd command to create a RAM Disk for loading Linux

  grub> initrd /initrd.img
  [Linux-initrd @ 0x37bd1000, 0x41e000 bytes]

Use boot command to load kernel:

  grub> boot

...

Give root password for maintenance 
(or type Control-D to continue): *********
mycomputer:~# 

Here I am, logged in as root with no graphical user interface, and ready to fix my X11 configuration file.

The Interactive Alternative

Alternatively, you can pass "vga=ask" as a kernel parameter, and then Linux will ask you, interactively, which resolution you want to use...

  Press <RETURN> to see video modes available, <SPACE> to continue or wait for 30 secs
  [RETURN]
  Mode:        COLSxROWS:
  0             80x25
  ...
  9            132x44
  Enter mode number or 'scan': 0

Type 'scan' if you want to try the auto-detection system (not very efficient - it didn't detect the right hardware for me).

Linux with no GUI

Since I had a copy of the original (working) X11 configuration file, I just had to copy it back so that Linux uses it instead of the buggy one I've tried to twitch...

mycomputer:~# cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.buggy
mycomputer:~# cp /etc/X11/XF86Config-4.orig /etc/X11/XF86Config-4
mycomputer:~# reboot
INIT: Sending processes the TERM signal
...

And here I am, with working Linux with Graphical User Inteface again, in a very solid and ugly... 800x600 pixels resolution! Hurray!!!

Reference Documentation


Author: Emmanuel KARTMANN (emmanuel@kartmann.org)
I'm a senior software engineer specialized in Web Technologies. I've been making freeware, I've been involved in several startup companies (some are still alive, most are dead and gone), and I'm making software for a living.

Comments on this article are most welcome !