Configure Linux to boot without a monitor - gHacks Tech News

Configure Linux to boot without a monitor

Many administrators/users prefer to set up their servers as headless machines. If you're not sure what a headless machine is - it's a PC without a monitor. This is an outstanding way to use Linux as a server as typically people install Linux servers sans GUIs. Thing is, a problem has arisen with recent iterations of Linux distributions. In recent releases (especially with Ubuntu) the distributions do not use an X configuration. This is great for end-users on desktops because the operating auto-detects the graphics chip and monitor for auto-X configuration. This is a problem for a headless server as there will be monitor attached. When Ubuntu >= 10.04 gets to the monitor detection it will freeze and your headless server is worthless.

You could work around this by plugging in a monitor, mouse, and keyboard and letting the OS boot and then removing the monitor when the boot process has finished. This is a far from ideal solution. Fortunately the Linux community has come up with a temporary work around for this issue (I'm confident the distribution developers will come up with a much better solution soon). Let's take a look at the solution.

Warnings

This solution requires that you create an /etc/X11/xorg.conf configuration file. I assume that anyone wanting to set up a headless server isn't afraid of manually creating/editing the xorg.conf file. If you are, make sure you back up any pre-existing xorg.conf file that might live in /etc/X11.

This guide also assumes that you already have a working server installation that you can successfully boot with an attached monitor. I will also assume you know what graphics card is in your server. You will need this information momentarily (so if you don't know it, dig around and find out what card you are using). With that being said, let's get on with it.

xorg.conf

The first thing you need to do is to set up the xorg.conf configuration. If one already exists, copy it to /etc/X11/xorg.conf.OLD and then erase the contents of the /etc/X11/xorg.conf file. The new contents of that file will be:

Section "Device"
Identifier "VNC Device"
Driver "vesa"
EndSection

Section "Screen"
Identifier "VNC Screen"
Device "VNC Device"
Monitor "VNC Monitor"
SubSection "Display"
Modes "1024x768"
EndSubSection
EndSection

Section "Monitor"
Identifier "VNC Monitor"
HorizSync 30-70
VertRefresh 50-75
EndSection

Once you have saved and closed that file you now need to edit the /etc/default/grub file and add the following line:

GRUB_CMDLINE_LINUX="nomodeset"

You can take this one step further and disable the splash screen for the boot process by setting the line:

GRUB_CMDLINE_LINUX_DEFAULT=

to "quiet" instead of "quiet splash"

Save the /etc/default/grub file and then issue the command sudo update-grub to rebuilt grub.

To test this setup go ahead and boot the machine without the monitor attached. Once you have given it plenty of time to boot you can either VNC or ssh into the machine. If you get a successful connection you are good to go. If you do not get a successful connection plug the monitor back in and see where in the process it stopped. If you have a black screen revisit the configuration and make sure everything is correct. To further troubleshoot boot the machine with the monitor plugged in and check the /var/log/Xorg.0.log file for any errors. Hopefully you will find the setup above works like a champ.

Advertisement

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:


Previous Post: «
Next Post: »

Comments

  1. The Mighty Buzzard said on November 28, 2010 at 8:55 pm
    Reply

    Or you could be smart and not use a desktop distro on a server. Any distro that you can’t tell not to even try starting a display manager and X on with one setting change is instant fail in evaluating distros for a server. For that matter, a server shouldn’t even have the packages needed to launch gdm or your display manager of choice installed.

  2. tantris said on November 29, 2010 at 4:54 am
    Reply

    And before you do any of this: Enable ssh! Just in case not even your console works afterwards, so you can still get in to move xorg.conf back.

  3. Paul W. Frields said on November 29, 2010 at 2:08 pm
    Reply

    The Fedora distribution serves as an upstream for Red Hat Enterprise Linux and other server oriented distros. It is well suited for people who want to try the newest free software, but can live without a long maintenance lifecycle. If you need a server distribution that has a much longer lifecycle of updates, but don’t want to pay for support, try CentOS. If you’re doing this professionally for a server at work, you probably want Red Hat Enterprise Linux with genuine support.

  4. Francisco said on November 30, 2010 at 5:10 am
    Reply

    Hello Jack Wallen, hope you come up with a much better solution soon, and when you now anything about this please tell me. I use a headless linux but need to have a monitor connected to him because of this ‘bug’.

    Already subscribe this topic so I can know when you have news.

    Thanks for helping!

    Sincerely, Francisco.

    1. zub said on November 30, 2010 at 2:32 pm
      Reply

      Why not just remove X? What do you need X for on a server, especially a headless one?

  5. Soumen said on May 3, 2011 at 4:59 pm
    Reply

    Great. Works fine for me. Ubuntu 10.04 LTS

  6. stefan said on January 30, 2013 at 12:14 pm
    Reply

    Great guide, any ideea on how to make it a widescreen ?
    If I plug my widescreen monitor into the machine it works ok, vnc connects in widescreen mode, and all is ok, on reboot with no monitor… it will revert to 4:3, probably vesta’s fault.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.