diff --git a/lib/backend.py b/lib/backend.py
index d71574060dcfb0a2711e3815ec96966cdd638c93..65135b71c42348ab549ce0c458657fbd3c0c5d26 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -812,6 +812,7 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
     utils.RemoveFile(new_name)
   return True
 
+
 def _ErrnoOrStr(err):
   """Format an EnvironmentError exception.
 
@@ -871,6 +872,7 @@ def _OSOndiskVersion(name, os_dir=None):
 
   return api_version
 
+
 def DiagnoseOS(top_dir=None):
   """Compute the validity for all OSes.
 
@@ -922,7 +924,7 @@ def OSFromDisk(name, os_dir=None):
                            % (api_version, constants.OS_API_VERSION))
 
   # OS Scripts dictionary, we will populate it with the actual script names
-  os_scripts = {'create': '', 'export': '', 'import': ''}
+  os_scripts = {'create': '', 'export': '', 'import': '', 'rename': ''}
 
   for script in os_scripts:
     os_scripts[script] = os.path.sep.join([os_dir, script])
@@ -944,6 +946,7 @@ def OSFromDisk(name, os_dir=None):
                     create_script=os_scripts['create'],
                     export_script=os_scripts['export'],
                     import_script=os_scripts['import'],
+                    rename_script=os_scripts['rename'],
                     api_version=api_version)
 
 
diff --git a/lib/constants.py b/lib/constants.py
index 246136aa4cdba57cbd293b7e26883bc7968f4bf3..6e327093b11a0f9707d8ea2801511a284e7cb15e 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -27,7 +27,7 @@ from ganeti import _autoconf
 CONFIG_VERSION = 3
 PROTOCOL_VERSION = 2
 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
-OS_API_VERSION = 4
+OS_API_VERSION = 5
 EXPORT_VERSION = 0
 
 
diff --git a/lib/objects.py b/lib/objects.py
index de33eb8eb69c9578e3e4639152f3faf03deaf31a..0d409cc5c8751781b3af1767835346edb050ee6d 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -400,7 +400,8 @@ class OS(ConfigObject):
     "api_version",
     "create_script",
     "export_script",
-    "import_script"
+    "import_script",
+    "rename_script",
     ]
 
 
diff --git a/man/ganeti-os-interface.sgml b/man/ganeti-os-interface.sgml
index f3f6717dd5a81a8488d05c5be992f4ee6824cff6..6d3a56f0ab4c274f1971e74bedc96c1721d67b1f 100644
--- a/man/ganeti-os-interface.sgml
+++ b/man/ganeti-os-interface.sgml
@@ -53,10 +53,10 @@
     <title>REFERENCE</title>
 
     <para>
-      There are four required files: <filename>create</filename>,
-      <filename>import</filename>, <filename>export</filename>
-      (executables) and <filename>ganeti_api_version</filename> (text
-      file).
+      There are five required files: <filename>create</filename>,
+      <filename>import</filename>, <filename>export</filename>,
+      <filename>rename</filename> (executables) and
+      <filename>ganeti_api_version</filename> (text file).
     </para>
 
     <refsect2>
@@ -81,7 +81,7 @@
       denote the block devices which will be visible in the instance
       as <emphasis>sda</emphasis> and <emphasis>sdb</emphasis>. The
       <emphasis>sda</emphasis> block device should be used for the
-      root disk (and will be passed as the root device for linux
+      root disk (and will be passed as the root device for Linux
       kernels). The <emphasis>sdb</emphasis> device should be setup
       for swap usage.</para>
 
@@ -131,14 +131,48 @@
 
     </refsect2>
 
+    <refsect2>
+      <title>rename</title>
+      <cmdsynopsis>
+        <command>rename</command>
+        <arg choice="req">-o <replaceable>old_name</replaceable></arg>
+        <arg choice="req">-n <replaceable>new_name</replaceable></arg>
+        <arg choice="req">-b <replaceable>blockdev_sda</replaceable></arg>
+        <arg choice="req">-s <replaceable>blockdev_sdb</replaceable></arg>
+      </cmdsynopsis>
+
+      <para>
+        This command is used in order to perform a rename at the
+        instance OS level, after the instance has been renamed in
+        Ganeti. The command should do whatever steps are required to
+        ensure that the instance is updated to use the new name, if
+        the operating system supports it.
+      </para>
+
+      <para>
+        Note that it is acceptable for the rename script to do nothing
+        at all, however be warned that in this case, there will be a
+        desynchronization between what <computeroutput>gnt-instance
+        list</computeroutput> shows you and the actual hostname of the
+        instance.
+      </para>
+
+      <para>
+        A very simple rename script should at least change the
+        hostname and IP address of the instance, leaving the
+        administrator to update the other services.
+        </screen>
+      </para>
+    </refsect2>
+
     <refsect2>
       <title>ganeti_api_version</title>
       <para>
         The <filename>ganeti_api_version</filename> file is a plain
         text file containing the version of the guest OS api that this
         OS definition complies with. The version documented by this
-        man page is 4, so this file must contain 4 followed by a
-        newline.
+        man page is 5, so this file must contain the number 5 followed
+        by a newline.
       </para>
     </refsect2>
 
@@ -154,12 +188,36 @@
 
     </refsect2>
 
+    <refsect2>
+      <title>Upgrading from old versions</title>
+      <refsect3>
+        <title>Version 4 to 5</title>
+        <para>
+          The <filename>rename</filename> script has been added. If
+          you don't want to do any changes on the instances after a
+          rename, you can migrate the OS definition to version 5 by
+          creating the <filename>rename</filename> script simply as:
+          <screen>
+#!/bin/sh
+
+exit 0
+          </screen>
+        </para>
+
+        <para>Note that the script must be executable.</para>
+      </refsect3>
+    </refsect2>
+
     <!--
     <refsect2>
 
       <title>Export/import format</title>
 
-      <para>It is up to the export and import scripts to define the format they use. It is only required for these two to work together. It is not recommended that </para>
+      <para>
+        It is up to the export and import scripts to define the format
+        they use. It is only required for these two to work
+        together. It is not recommended that
+      </para>
 
     </refsect2>
     -->