diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 366e646bf06148d2532a05fa68dfd143fa9777c6..f5a26f386b017bdcb404b615adb277e3bd03c890 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -1887,6 +1887,20 @@ class LUReinstallInstance(LogicalUnit):
       raise errors.OpPrereqError, ("Instance '%s' is running on the node %s" %
                                    (self.op.instance_name,
                                     instance.primary_node))
+
+    self.op.os_type = getattr(self.op, "os_type", None)
+    if self.op.os_type is not None:
+      # OS verification
+      pnode = self.cfg.GetNodeInfo(
+        self.cfg.ExpandNodeName(instance.primary_node))
+      if pnode is None:
+        raise errors.OpPrereqError, ("Primary node '%s' is unknown" %
+                                     self.op.pnode)
+      os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name]
+      if not isinstance(os_obj, objects.OS):
+        raise errors.OpPrereqError, ("OS '%s' not in supported OS list for"
+                                     " primary node"  % self.op.os_type)
+
     self.instance = instance
 
   def Exec(self, feedback_fn):
@@ -1895,6 +1909,11 @@ class LUReinstallInstance(LogicalUnit):
     """
     inst = self.instance
 
+    if self.op.os_type is not None:
+      feedback_fn("Changing OS to '%s'..." % self.op.os_type)
+      inst.os = self.op.os_type
+      self.cfg.AddInstance(inst)
+
     _StartInstanceDisks(self.cfg, inst, None)
     try:
       feedback_fn("Running the instance OS create scripts...")
diff --git a/lib/opcodes.py b/lib/opcodes.py
index dd1d7a8d8a5487abf814f34847ffdf163e6fa5d5..106839ae0825521e4bdc7d2d3fde288fb0c8ffa1 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -142,7 +142,7 @@ class OpCreateInstance(OpCode):
 class OpReinstallInstance(OpCode):
   """Reinstall an instance."""
   OP_ID = "OP_INSTANCE_REINSTALL"
-  __slots__ = ["instance_name"]
+  __slots__ = ["instance_name", "os_type"]
 
 
 class OpRemoveInstance(OpCode):
diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml
index e5895d70cbf9e5fe5e3b8378e4a6a41627c91e33..c3f17ee4acaeda74b923f9cb5c2df015c92f9e2f 100644
--- a/man/gnt-instance.sgml
+++ b/man/gnt-instance.sgml
@@ -377,6 +377,24 @@
         </para>
       </refsect3>
 
+      <refsect3>
+        <title>REINSTALL</title>
+
+        <cmdsynopsis>
+          <command>reinstall</command>
+          <arg choice="opt">-o <replaceable>os-type</replaceable></arg>
+          <arg choice="opt">-f <replaceable>force</replaceable></arg>
+          <arg choice="req"><replaceable>instance</replaceable></arg>
+        </cmdsynopsis>
+
+        <para>
+          Reinstalls the operating system on the given instance. The instance
+          must be stopped when running this command. If the
+          <option>--os-type</option> is specified, the operating system is
+          changed.
+        </para>
+      </refsect3>
+
     </refsect2>
 
     <refsect2>
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index e9dbc522ec76719b399dce275fc749539b1fbadb..867e0d57332d9b3da005a0b567644d45877353df 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -111,7 +111,8 @@ def ReinstallInstance(opts, args):
     if not opts._ask_user(usertext):
       return 1
 
-  op = opcodes.OpReinstallInstance(instance_name=instance_name)
+  op = opcodes.OpReinstallInstance(instance_name=instance_name,
+                                   os_type=opts.os)
   SubmitOpCode(op)
 
   return 0
@@ -421,6 +422,9 @@ def SetInstanceParms(opts, args):
 node_opt = make_option("-n", "--node", dest="node", help="Target node",
                        metavar="<node>")
 
+os_opt = cli_option("-o", "--os-type", dest="os", help="What OS to run",
+                    metavar="<os>"),
+
 # this is defined separately due to readability only
 add_opts = [
   DEBUG_OPT,
@@ -429,8 +433,7 @@ add_opts = [
              default=20 * 1024, type="unit", metavar="<size>"),
   cli_option("--swap-size", dest="swap", help="Swap size",
              default=4 * 1024, type="unit", metavar="<size>"),
-  cli_option("-o", "--os-type", dest="os", help="What OS to run",
-             metavar="<os>"),
+  os_opt,
   cli_option("-m", "--memory", dest="mem", help="Memory size",
               default=128, type="unit", metavar="<mem>"),
   make_option("-p", "--cpu", dest="vcpus", help="Number of virtual CPUs",
@@ -480,7 +483,7 @@ commands = {
   'list': (ListInstances, ARGS_NONE,
            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
            "", "Lists the instances and their status"),
-  'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
+  'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
                 "[-f] <instance>", "Reinstall the instance"),
   'remove': (RemoveInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
              "[-f] <instance>", "Shuts down the instance and removes it"),