\begin{exe} {Recovering from Partition Table Corruption}

   \begin{important}
      This exercise is dangerous and could leave to an
      unusable system.  Make sure you really understand things
      before doing it
   \end{important}

   \begin{info}
      The following instructions for an \textbf{MBR} system.
      if you have \textbf{GPT} you need to use \textbf{sgdisk}
      with the \verb?--backup-file? and \verb?--load-backup?
      options as discussed in the partitioning chapter
   \end{info}

   \begin{enumerate}
      \item
      Login as root and save your \textbf{MBR}:
      \begin{cmd}
$ dd if=/dev/sda of=/root/mbrsave bs=446 count=1
      \end{cmd}
      \begin{response}
 1+0 records in
 1+0 records out
 446 bytes (446 B) copied, 0.00976759 s, 45.7 kB/s
      \end{response}
      Be careful: make sure you issue the exact command
      above and that the file saved has the right length:
      \begin{cmd}
 $ sudo ls -l /root/mbrsave
      \end{cmd}
      \begin{response}
-rw-r--r-- 1 root root 446 Nov 12 07:54 mbrsave
      \end{response}
      \item
      Now we are going to obliterate the \textbf{MBR} with:
      \begin{cmd}
$ dd if=/dev/zero of=/dev/sda bs=446 count=1
      \end{cmd}
      \begin{response}
1+0 records in
1+0 records out
446 bytes (446 B) copied, 0.000124091 s, 3.6 MB/s
      \end{response}
      \item
      Reboot the system; it should fail.
      \item
      Reboot into the rescue environment and restore the
      \textbf{MBR}:
      \begin{cmd}
$ dd if=/mnt/sysimage/root/mbrsave of=/dev/sda bs=446 count=1
      \end{cmd}
      \item
      Exit from the rescue environment and reboot.  The
      system should boot properly now.
   \end{enumerate}
\end{exe}

