rbalsdon
June 28th, 2008, 09:04 PM
Starting a Desktop Install without GDM
Ubuntu 8.04 Hardy
----
Hi Everyone,
This took me quite a while to get working (I couldn't find anything on the web) so I thought I'd post here. Stopping and starting the X-server is easiest done with the service commands (sudo /etc/init.d/gdm stop) and (sudo /etc/init.d/gdm start) but I would rather be able to choose from grub (when the computer is booting) whether or not to start the graphics.
Intro
"Why would you ever want to do this?" is a very good question which I'll not go into in detail here. I use it on a laptop that I'd like to have start and stop very quickly and with minimal resource use but still have to option of getting into gnome if I want.
Booting into a different runlevel is usually done by adding the number at the end of the kernal command in grub (more on these terms in a few) but this doesn't seem to work in Ubuntu; it will always get into runlevel 2.
Runlevels
A runlevel is used to tell the OS how far up you want it to boot. Generally, we use runlevel 1 for debugging/recovery mode, runlevel 3 for normal text (no graphics mode) and runlevel 5 for normal with graphics. Runlevels 0 and 6 are when the computer is shutting down/restarting. Runlevels 2 and 4 are user-defined and used for doing crazy stuff without modifying the standard 1,3 and 5 runlevels.
Ubuntu uses runlevel 1 for text mode, as expected, but uses runlevel 2 for full graphical mode. This leaves no room in between for the text mode but the runlevels 3 to 5 are still available to us. Relating to the above paragraph: in Ubuntu, runlevels 2 to 5 are all used as runlevel 5.
In a more hands-on explanation, we can say that the different runlevels refer to different folders filled with scripts that are called at boot and start up all the different programs that need to be started. Runlevel 1 will have only a few scripts but runlevel 2 will have all of them.
We have to then modify runlevel 3 to be text-only and update the boot script somehow to point it to runlevel 3 instead of runlevel 2.
Step 1: Changing Runlevel 3 to Text-Only
Load up a terminal/console if one isn't already by clicking on Applications->Accessories->Terminal.
The folders that refer to the different runlevels are called /etc/rcX.d where X is the runlevel so enter and list the runlevel 3 folder by typing in
cd /etc/rc3.d
ls
Look for the script that says gdm, it should be S30gdm. If you're running KDE, this might be S30kdm (untested). Remove this script by calling
sudo rm S30gdm
Step 2: Making Runlevel 3 Accessible from GRUB
I had to modify the rc-default script to do this. This is extremely dangerous and could make your computer "unbootable". An error can be recovered from using the Live CD so it wouldn't be the end of the world but just be careful to copy exactly and you'll be fine.
Open up the rc-default script by typing in
sudo gedit /etc/event.d/rc-default
The script should look like this:
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
If your script doesn't look like above, stop here because I can't guarantee my modifications to work. We're going to add a new elif statement to look for the word text and boot into runlevel 3. Change your script (copy/paste) to look like the following
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif grep -q -w -- "-s\|text\|S" /proc/cmdline; then
telinit 3
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
Double-check that everything's exactly identical and move on.
Step 3a: Booting into Text-Mode Once
Reboot your computer and enter the GRUB menu. This should be done automatically but in some installs, you have to push the ESC key while a timer's counting down.
The GRUB screen will give you a few different options, none of which should have changed. To give you an idea of the screen we're looking for, mine lists the following:
Ubuntu 8.04, kernel 2.6.24-19-generic
Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
Ubuntu 8.04, memtest86+
Highlight the default (should be the very top) option and press the 'e' key for edit (once). Again to make sure we're on the same page, mine lists the following:
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet
Highlight the kernel (second) option and push the 'e' key again. Type in "text" at the end (after splash) so that it looks like this:
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash text
Note that your UUID and kernel version may be different and you should not change it. Just add the word "text" to the end of whatever's there. Press the 'b' key to boot into text mode.
Step 3b: Booting into Text-Mode Always
Load up a terminal/console if one isn't already by clicking on Applications->Accessories->Terminal.
Load up the GRUB config by typing in:
sudo gedit /boot/grub/menu.lst
Near the bottom of this file, you'll see a list of all the different boot options of the GRUB menu. To give a good idea of what you're looking for, one of mine looks like this:
title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet
You might have quite a few of these if you've been following different kernel updates; edit the very top one of these. Add the word "text" to the end of the kernel line, exactly as described in Step 3a so that the above example would look like this:
title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash text
initrd /boot/initrd.img-2.6.24-19-generic
quiet
Step 4: Running the Graphical Interface While in Text-Only Mode
If you're running in text and want to see the graphics stuff again, there are two different ways to go.
To see the nice login screen like Ubuntu normally boots into , type in:
sudo /etc/init.d/gdm start
You may have to swap gdm with kdm if you're using KDE (untested). If you just want to see Gnome/KDE (skipping the login part), type in
startx
RB
Ubuntu 8.04 Hardy
----
Hi Everyone,
This took me quite a while to get working (I couldn't find anything on the web) so I thought I'd post here. Stopping and starting the X-server is easiest done with the service commands (sudo /etc/init.d/gdm stop) and (sudo /etc/init.d/gdm start) but I would rather be able to choose from grub (when the computer is booting) whether or not to start the graphics.
Intro
"Why would you ever want to do this?" is a very good question which I'll not go into in detail here. I use it on a laptop that I'd like to have start and stop very quickly and with minimal resource use but still have to option of getting into gnome if I want.
Booting into a different runlevel is usually done by adding the number at the end of the kernal command in grub (more on these terms in a few) but this doesn't seem to work in Ubuntu; it will always get into runlevel 2.
Runlevels
A runlevel is used to tell the OS how far up you want it to boot. Generally, we use runlevel 1 for debugging/recovery mode, runlevel 3 for normal text (no graphics mode) and runlevel 5 for normal with graphics. Runlevels 0 and 6 are when the computer is shutting down/restarting. Runlevels 2 and 4 are user-defined and used for doing crazy stuff without modifying the standard 1,3 and 5 runlevels.
Ubuntu uses runlevel 1 for text mode, as expected, but uses runlevel 2 for full graphical mode. This leaves no room in between for the text mode but the runlevels 3 to 5 are still available to us. Relating to the above paragraph: in Ubuntu, runlevels 2 to 5 are all used as runlevel 5.
In a more hands-on explanation, we can say that the different runlevels refer to different folders filled with scripts that are called at boot and start up all the different programs that need to be started. Runlevel 1 will have only a few scripts but runlevel 2 will have all of them.
We have to then modify runlevel 3 to be text-only and update the boot script somehow to point it to runlevel 3 instead of runlevel 2.
Step 1: Changing Runlevel 3 to Text-Only
Load up a terminal/console if one isn't already by clicking on Applications->Accessories->Terminal.
The folders that refer to the different runlevels are called /etc/rcX.d where X is the runlevel so enter and list the runlevel 3 folder by typing in
cd /etc/rc3.d
ls
Look for the script that says gdm, it should be S30gdm. If you're running KDE, this might be S30kdm (untested). Remove this script by calling
sudo rm S30gdm
Step 2: Making Runlevel 3 Accessible from GRUB
I had to modify the rc-default script to do this. This is extremely dangerous and could make your computer "unbootable". An error can be recovered from using the Live CD so it wouldn't be the end of the world but just be careful to copy exactly and you'll be fine.
Open up the rc-default script by typing in
sudo gedit /etc/event.d/rc-default
The script should look like this:
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
If your script doesn't look like above, stop here because I can't guarantee my modifications to work. We're going to add a new elif statement to look for the word text and boot into runlevel 3. Change your script (copy/paste) to look like the following
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif grep -q -w -- "-s\|text\|S" /proc/cmdline; then
telinit 3
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
Double-check that everything's exactly identical and move on.
Step 3a: Booting into Text-Mode Once
Reboot your computer and enter the GRUB menu. This should be done automatically but in some installs, you have to push the ESC key while a timer's counting down.
The GRUB screen will give you a few different options, none of which should have changed. To give you an idea of the screen we're looking for, mine lists the following:
Ubuntu 8.04, kernel 2.6.24-19-generic
Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
Ubuntu 8.04, memtest86+
Highlight the default (should be the very top) option and press the 'e' key for edit (once). Again to make sure we're on the same page, mine lists the following:
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet
Highlight the kernel (second) option and push the 'e' key again. Type in "text" at the end (after splash) so that it looks like this:
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash text
Note that your UUID and kernel version may be different and you should not change it. Just add the word "text" to the end of whatever's there. Press the 'b' key to boot into text mode.
Step 3b: Booting into Text-Mode Always
Load up a terminal/console if one isn't already by clicking on Applications->Accessories->Terminal.
Load up the GRUB config by typing in:
sudo gedit /boot/grub/menu.lst
Near the bottom of this file, you'll see a list of all the different boot options of the GRUB menu. To give a good idea of what you're looking for, one of mine looks like this:
title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet
You might have quite a few of these if you've been following different kernel updates; edit the very top one of these. Add the word "text" to the end of the kernel line, exactly as described in Step 3a so that the above example would look like this:
title Ubuntu 8.04, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=21c38426-84f0-4946-bee7-318074de0787 ro quiet splash text
initrd /boot/initrd.img-2.6.24-19-generic
quiet
Step 4: Running the Graphical Interface While in Text-Only Mode
If you're running in text and want to see the graphics stuff again, there are two different ways to go.
To see the nice login screen like Ubuntu normally boots into , type in:
sudo /etc/init.d/gdm start
You may have to swap gdm with kdm if you're using KDE (untested). If you just want to see Gnome/KDE (skipping the login part), type in
startx
RB