UPDATED: Windows XP Recovery Partition 4: Install Clonezilla (and Parted Magic) to Boot From Hard Drive

This was originally written in 2010 as “Windows XP Recovery Partition 4: Install Clonezilla“.  Somewhere between Ubuntu 9.x and 11.x, however, something changed and Clonezilla was no longer booting using those instructions.

In the meantime, however, I also saw some value (maybe not a great amount, but some) in being able to boot into Parted Magic as well.  In addition, I found some utilities that made handling Grub2 a little easier. However, until very recently, I hadn’t come across anything that would actually address the boot issue I was having.

So, continuing on with how to create a Windows XP recovery partition using Ubuntu and Clonezilla, we now come to the meat of it: instaling Clonezilla and modifying the GRUB loader to boot into it.

Again, I’m going to hit the highlights. In addition, I’m going to point you to other documentation rather than repeat all of it here.  It is assumed that you have done all the steps in “Windows XP Recovery Partition 3: Install Ubuntu” already and now having a working Ubuntu partition.

1. Before making any changes, be sure to backup all of the GRUB files.  It is easy enough to do by creating an “old” directory and then copying the original files into it:

$sudo mkdir /etc/grub.d/old
$sudo cp /etc/grub.d/* /etc/grub.d/old
$sudo cp /etc/default/grub /etc/grub.d/old

2. Next, I downloaded the Clonezilla ISO and the Parted Magic ISO on another machine.  Then, I wrote a script and put it on the same USB stick that I used to install Ubuntu in the “post-install” directory and named the script “post-install.sh”.  Then, I created a subdirectory called “isos” and placed both ISO files into it.

Special note: Parted Magic is free, but the official download is $4.99, which helps to support the site.  You can get it for free if you look for it, though.

The script installs Gparted  grub-customizer and grub-imageboot and then places the ISO files into the correct directory.  It then uses sed to comment out the entry that hides the menu.  Finally, it runs update-grub to finish up.  It requires executable permissions, so you may have to do it from your desktop or other place on your hard drive, and it must be run with administrator, “sudo”, privileges.  It is a bit rough, but here it is:

#!/bin/bash
# Post install script to fix grub so Parted Magic and Clonezilla
# can boot under Linux
echo You MUST run this as sudo!
read -p "Continue (Y/n)?" yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ] || [ "$yn" == "" ]
then
apt-get install gparted
add-apt-repository ppa:danielrichter2007/grub-customizer
apt-get update
apt-get install grub-customizer
apt-get install grub-imageboot
mkdir /boot/images/
cp ./isos/*.iso /boot/images/
mv /etc/default/grub /etc/default/grub.old
cat /etc/default/grub.old | sed s/GRUB_HIDDEN_TIMEOUT=0/#GRUB_HIDDEN_TIMEOUT=0/ > /etc/default/grub update-grub
fi

3. Create a directory to place your backups in:

$sudo mkdir /backups

4. Now, test GRUB by booting the machine and inspecting the menu.  If it doesn’t work, then go back and copy your backups back into place and run “sudo update-grub” to get back to the original.

5. Once it is working, use grub-customizer to prune down the entries, if desired, and set the default.  Since these instructions are assuming this is a recovery/utility partition, the default should be set to the Windows partition and be set short (or you can even hide the menu if you wish, just be sure to set the timeout sufficiently to give time to press [Esc] to bring the menu up).

6. Test again to see if Clonezilla and Parted Magic come up.  During my tests, Parted Magic comes up, but it is very slow, so that’s something to keep in mind.

7. Boot into Windows.  If it doesn’t automatically run chkdsk, I recommend manually running it.

8. Finally, boot into Clonezilla and do a test of the backup.  This will ensure you have enough space to do the backup and restore and that everything works.  Be sure to set the directory to the /backups directory.  Be sure to cleanup your test backups, though, as that will waste space and be confusing.

If this is for an enduser, you will probably want to go ahead and do the steps in “Windows XP Recovery Partition 5: Prepare For Distribution with Sysprep“.  Otherwise, make sure all the security updates are in place before doing a final recovery backup.