Create your own rescue partition, with easy restore option (at no costs)

When you are a bit handy with computers, you soon become a kind of computer god to your family and friends and if you don’t watch out, you get overloaded with questions and problems. If that is not enough you find yourself (re)installing each computer over and over again. Wouldn’t it be nice, if they can help there selves and you are just needed once in a (long) while?

image

Lots of computer manufactures, deliver there systems with a so called rescue partition or CD/DVD. Which can restore the system in its original state. With this option they hope to give there customers a easy way to “fix” there computer. Even if you have such an option I still recommend to create your own option, cause most of those “restore” actions not only restore the OS, but also all the software you (probably) don’t need. Also after a couple of months you probably need to install tons of OS updates after a restore.

Before you start, it is good to know that some of the actions are quite risky and may destroy your installation or partition table. So watch out and test(or practice) in an “test” environment. If you don’t have the hardware for testing, then a Virtual environment, like VMWare, VirtualPC, Virtualbox, etc. is very handy.

Let’s start!
The idea is simple, we create an extra partition on the hard drive, which is going to store the rescue image (sort of packed installation of an OS). We add a boot menu to the boot order, which gives us the opportunity to boot into the extra partition. After booting in this extra partition it shows us a menu, which gives us the option to restore the system or to create a new image.

We need the following software, a boot manager and a small Linux distribution. In this post I use Plop Linux and Plop bootmanager. Which both can be found here. Thanks to Elmar for creating this excellent free tools! (For this test I use Windows XP as the “primary” installation, but you can use any OS you like*)

* If they need another file system, you need to edit the rescue script.

Step 1 – Downloading the tools
For this blog I use version 4.1.1 test 3 of Plop Linux cause 4.1.1 was giving some problems.
If you are testing on a physical system burn the ISO to a CD.

Step 2 – Prepare the system (Partitioning and Installing Windows)
I just assume, you didn’t install any OS yet. So we can delete and create partitions without being afraid of losing some data. If you already have an OS running and do not have some spare space for a rescue partition, you need a partition manager which is capable of resizing and creating partitions without losing any data. For now we just use the Windows XP installation for partitioning the system.

Start the installation and make just one partitions (not the whole disk!) for the actual Windows installation, the rest of the space is needed for the rescue partition. I normally make the rescue partition at least the same size or a bit bigger then the “primary” partition. (Sorry a bit Dutch ;-))

We don’t care about the second partition for now.  Just install Windows.

Step 3 – Creating the rescue partition
After the install of Windows boot from the Plop CD (or image).

image

With the command fdisk –l, you can check the connected disks and the available partitions.

image
Start fdisk with the right harddisk to create the “rescue” partition.
In my case, the commando is. “fdisk /dev/hda”

In the menu press “n” for creating a new partition and press “p” for making it a primary partition. In our case it is partition 2 and it uses the full size (enter twice). If you press “p” you see, what the partition table looks like if you write it to disk.

image

If you are ok with it, press “w” to write the partition table.

Reboot the system from CD to make sure the partition table is correctly loaded.
When running fdisk –l again it should show something like the picture below.

image

Now we can install Plop.
For this, type “installplop”.
Make sure you enter the right destination drive, in our case “/dev/hda2” and also make sure you don’t write anything to the MBR. Do not run “plpinstall.sh” !

image

We need to make some slight enhancements to the installation script. You can edit the script, by typing “nano /tmp/plpinstall.sh”. Find the lines:

prompt
timeout=20
default=ploplinux
boot=/dev/hda2
map=/boot/map
lba32
vga=1
compact

And change them to.

#prompt
#timeout=20
default=ploplinux
boot=/dev/hda2
map=/boot/map
lba32
vga=0x317
compact

Save the file and exit nano (CTRL+X).
Now we’re ready to install Plop, by typing “/tmp/plpinstall.sh”.

image

Now it is save to reboot and continue with step 3.

Remark
If you get some errors like:
imageYou also need the change the line “chroot $MNT lilo” to “chroot $MNT lilo –P ignore” and run the installscript again.

Step 3 – Creating the boot Menu
Boot your system from the Plop Linux CD (or by mounting the ISO).

image
Choose the option “plop boot manager installer”.
Make sure that you install the boot manager to the correct hard disk (option 7), after this you can install the boot manager, option 1.

image

That’s it, the boot manager is installed.
Reboot the system, so we can configure the boot manager.

image

I usually make the menu plain and simple, so that there are only two options, the “default” which will start after a certain amount of time and the “rescue” option.

Go to setup –> bootmanager and make the following settings.

boot countdown: yes
edit boot countdown: 5 seconds
select at start: default profile
show floppy boot: no
show cdrom boot: no
show usb boot: no

image
Now the menu is simple, we create the two profiles.
Go to settings – profiles, select the first profile and press enter.
Edit the label to something useful like “Windows XP”.

To make sure Windows doesn’t see, the “rescue” partition, we need to go to “linked partitions”.

Make sure the first partition is set to “boot partition”, this can be done by pressing “b”.
Set the rest of the partitions to “clear”, this makes the partition(s) invisible to Windows.

image

Next we create the “rescue” profile, so go to settings – profiles and press the down key once. This selects the second profile, even if it is empty, press enter, to configure this profile.

Type a name, like “rescue” and set visibility in the menu to “yes”.

image

Go to linked partitions and make sure both partitions are visible. Also make sure that the second partition is the boot partition, you can accomplish this by pressing the “b”.

image

Test it, by going to the menu and boot Windows and the second time boot the Rescue profile. If they both work you can continue with step 4.

Step 4 – Making the “rescue” / image script
Now we can boot into Windows and a small Linux distribution it is time to create the “rescue” script. We don’t want a user to worry about Linux commands it is just a simple restore. First of all I’m not a BASH guru, so probably not everything is done in the most efficient way.

In order to make the rescue process possible, we need to create two directories.

mkdir /mnt/images
mkdir /mnt/script

The first directory is going to store the created images and the second one stores the script. Now we make the script.

nano /mnt/script/rescue.sh

Fill in the code below for a basic “script”.

You can exit the script by pressing CTRL+X.
Now we need to make the script executable, this can be done by: chmod +x /mnt/script/rescue.sh

You can test the script by typing “/mnt/script/rescue.sh”.

image

The password in the script is “the password”, the disk which gets imaged is the disk which shows in the output of “fdisk –l”, “ntfs”. This probably gives error if you have more then one NTFS partition.

The last step is to automatically start the menu, when the user boots into “rescue” mode.

For this open the rc.local in nano or vi and add “/mnt/script/rescue.sh”, just before “exit 0”.

nano /etc/rc.localimage

Final note

This is just a simple start, to create the bare minimum, since it is all “open” it is easy to extend, modify,etc. This is just a blog post, which might gets you started.

For example, if you are in a business environment, think about booting from PXE and image over the network. We use this for our “thin” clients, which run on Windows XP Embedded.

I always find it nice to hear improvements, different thoughts, etc.

UPDATE 2011-04-20
Made some minor changes, like adding chmod+x and changes /mnt to $MNT.

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

9 thoughts on “Create your own rescue partition, with easy restore option (at no costs)

  1. I have followed the script and when i run it, i receive the following error ‘CheckPassword (){

    please can you help

  2. Hawes29 :
    I have followed the script and when i run it, i receive the following error ‘CheckPassword (){
    please can you help

    At least I can try, do you get this error immediately or does this “error” appear after making a choice?

    Do you have any further details or perhaps a screenshot?
    I’ll try to run the script today, to see if I made some copy/paste mistakes.

    edit; I tried the script, but it seems working fine, could you please send me some more details so we can fix this problem? Thanks in advance.

  3. Sorry I’ve not emailed sooner; I copied the script from
    Above and just pasted it. I receive the error at the beginning and can’t get past it. Did you copy the script from the site?

    I really appreciate the help

    Cheers

  4. Hi Rob

    I have started from scratch and I have copied your script from above. When i try to execute it with the follow command;

    bash /mnt/script/rescue.sh
    ‘mnt/script/rescue.sh: line 10: syntax error near unexpected token ‘{
    ‘mnt/script/rescue.sh: line 10: ‘CheckPassword(){

    Do I need to add some parameters?

    Thanks again

  5. @Hawes29
    Did you got my mail, I tried to sent the script, perhaps it is blocked by the mail provider.
    An additional note,which I seemed to forgot in the blog post, it is important to make the file executable. This can be done with the following command:

    chmod +x /mnt/script/rescue.sh

    Hope this helps, please let me know.

  6. Morning Rob

    I have run the command like you suggested but i still get the error

    ‘mnt/script/rescue.sh: line 10: syntax error near unexpected token ‘{
    ‘mnt/script/rescue.sh: line 10: ‘CheckPassword(){

    please can you change the extention of the script and email it to hawes29@hotmail.com

    I would really like to get this crack.

    Thanks again

  7. Hi – i’m a colleague of Hawes29 – We’ve managed to get the script to work – the only problem is that when we edit /etc/rc.local it doesn’t appear to automatically call the /mnt/script/rescue.sh script. it loads through and gives an error about 32-bit not being supported in legacy.
    any ideas what the problem could be ? .. i can run the script successfully and also i can run rc.local and this also loads up the menu – i just cant get it to automatically load into the menu.
    thanks for all your help so far
    Jordy

  8. @Jordy
    Can you tell me what you changed in the script, just curious and maybe it can be helpful for others.

    About the 32-bit legacy problem, is there any chance you used the 64bit version of Plop Linux?

Leave a Reply

Your email address will not be published. Required fields are marked *

*