Me and U(buntu)

My Ubuntu Experience!

Changing system configuration: switchconf

Posted by Jason on May 7, 2008

As I haven’t found the perfect configuration for my system (yet), I sometimes want to use different configuration files, like selecting a different xorg.conf.

My previous method had been to keep the various configuration files in /etc/X11, and then copy the desired one over xorg.conf and re-start X. This isn’t really a bad solution, but I thought I might look into an alternative way: select the xorg.conf I want at boot.

This is a pretty simple process:

Get the tool

You need to install switchconf first. It is in repositories, so:

$sudo apt-get install switchconf

Create your configurations

This is pretty simple once you understand what to do: First, create a directory with the name of the configuration. Then, create a path of directories to the desired config file that “mirrors” the “real” path and put the desired file there.

For example: One configuration I want is going to be called “xinerama”, and I want it to use a specific xorg.conf that runs xinerama across all three monitors.

First, then, create the directory /etc/switchconf/xinerama, and then “underneath” this directory, you will create /etc/X11 and place the desired xorg.conf file. The resulting complete file name with path, then will be:

/etc/switchconf/xinerama/etc/X11/xorg.conf

You can see how the portion after the configuration name (xinerama), mirrors the path to the “real” xorg.conf.

Since I want to have 3 different configurations to choose from I repeat this process, ending up with:

/etc/switchconf/xinerama/etc/X11/xorg.conf
/etc/switchconf/single/etc/X11/xorg.conf
/etc/switchconf/twinplus/etc/X11/xorg.conf

You can obviously see how to add multiple files to a specific configuration by following the “mirroring” path process. The man page suggests that if you set up a file in one configuration you do so in all configurations, to prevent one configuration’s files getting mixed up with another’s.

Check your work

See what the resulting available configurations are:

$switchconf -list
single
twinplus
xinerama

Call the configuration at boot time

Although it doesn’t seem to be documented in the man page for switchconf, you can use a kernel option at boot time to call the configuration.

So, the relevant portions of my edited /boot/grub/menu.lst looks like:

title		Ubuntu 8.04, kernel 2.6.24-17-rt (TWINPLUS)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.24-17-rt root=UUID=d2b5a184-9104-4aff-8011-cb50d784afb9 ro quiet splash switchconf=twinplus
initrd		/boot/initrd.img-2.6.24-17-rt
quiet

title		Ubuntu 8.04, kernel 2.6.24-17-rt (XINERAMA)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.24-17-rt root=UUID=d2b5a184-9104-4aff-8011-cb50d784afb9 ro quiet splash switchconf=xinerama
initrd		/boot/initrd.img-2.6.24-17-rt
quiet

title		Ubuntu 8.04, kernel 2.6.24-17-rt (SINGLE)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.24-17-rt root=UUID=d2b5a184-9104-4aff-8011-cb50d784afb9 ro quiet splash switchconf=single
initrd		/boot/initrd.img-2.6.24-17-rt
quiet

title		Ubuntu 8.04, kernel 2.6.24-17-rt (recovery mode)
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.24-17-rt root=UUID=d2b5a184-9104-4aff-8011-cb50d784afb9 ro single
initrd		/boot/initrd.img-2.6.24-17-rt

Note the “switchconf=configuration name” at the end of each “kernel” line. Set the one you want as your default at the top of the list.

2008.05.08 Edited To Add:
Don’t use “SINGLE” as a name, because it will cause friendly-recovery to activate at boot – I guess it picks up on the word and thinks you are trying to do something in single user and starts up. I tried to find where to report this as a bug, but gave up. I just changed it to “MIDDLEONLY” (along with the corresponding changes in the kernel option and switchconf directory, and it cleared the problem.

That’s it! Now you can pick your desired xorg.conf at boot! (Or even a more customized configuration!) I will give this a try for a bit and see how it works – if you try it or if you have a better way let me know!

(I would really like to be able to select the xorg.conf from the login screen and just have it re-start X, since this would be much quicker than a reboot.)

3 Responses to “Changing system configuration: switchconf”

  1. Lantesh said

    Thank you for this quick tutorial. It was exactly what I needed as it gave me the ability to set up different configurations for when I just using my Monitor, and when I need my TV as well. Hats off to you!

  2. Guest said

    This was most helpful. Thank you.

  3. J Telusto said

    Will this work with an encrypted LVM setup?

Sorry, the comment form is closed at this time.

 
Follow

Get every new post delivered to your Inbox.