I'm asking myself if I can use Grub 2 to tell the Operating System which actions to perform after boot.

I have a HTPC with Debian Wheezy installed. Sometimes I want to use the System as a regular desktop but sometimes I'd just like to have XBMC started.

I tried out a dual boot with OpenElec which wasn't very convenient because I was not able to mount my RAID-1 in OpenElec.

My next attempt would be to use a second minimal Debian installation with XBMC. With this solution I could still choose between regular desktop and HTPC purpose in Grub.

But now I thought this could be a waste of time and disk space, as I have Debian already installed. It would be easier if there was some kind of boot parameter I could use to tell my regular Debian installation

  • "Boot to desktop" or
  • "Boot to XBMC"

Then I would just need a second entry in Grub to handle this boot parameter.

Is this somehow possible?


Any command line parameter to the Linux kernel will show up in /proc/cmdline. You can put anything you like in there (as long it's not a parameter recognised by the kernel or any of the drivers or the initrd system). For instance, you could build it up with fancy grub menus, and then use that in a startup script like /etc/rc.local to decide what to do with it.

For instance add a /etc/grub.d/09-xcmd with:

#! /usr/bin/tail -n+2
menuentry 'XMBC' {
  set xcmd='xcmd=xmbc'
  echo 'Now select a kernel'
  sleep 1

Then add to /etc/default/grub:


Run update-grub.

In /etc/rc.local, you could have:

case $(cat /proc/cmdline) in
  (*xcmd=*) exec sudo -Hu marcel startx;;

And in your ~/.xinitrc:

cmdline=$(cat /proc/cmdline)
case $cmdline in
    xcmd=${xcmd%% *}
    "$xcmd" &
  • looks like a very clean solution! Thank you! – Marcel Mar 31 '13 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.