RMPrepUSB Blog - please leave a comment or feedback on RMPrepUSB or this Tutorial (please mention Tutorial number).
If you want to make a bootable external USB Hard disk so that you can create or restore backups, see Tutorial 118.
This tutorial allows you to add some boot menu options to create a partition backup and restore option for your existing Windows hard disk. You do not have to re-format and re-install Windows to add a recovery partition.
Once set up, all the user has to do is press F4 for an automatic restore (with just one confirmation prompt only - but this can be removed if you prefer a fully automatic restore).
It uses CloneZilla and is based on a version posted by ndog37 on reboot.pro here. With this tutorial, you can quickly backup your copy of Windows at any time and then later restore any of the previous backup images. An XP backup takes approximately 5 minutes. Restoring an XP image takes approximately 1 to 5 minutes. Windows 7/8 will obviously take longer!.
The backup is made on the hard disk, so it is not suitable for off-line backups. The backup and restore options can also be fully automated so even your granny could restore Windows if it went wrong!
This tutorial assumes that your Windows OS is installed onto the first hard disk in your system, is the only copy of Windows on that hard disk and you have a backup partition on the first hard disk that has some free space to store the backup images in. If you have more than one partition containing Windows (e.g. dual-boot), then this tutorial will not work correctly and you will need to modify the menu.lst file substantially.
Because this method installs grub4dos, you will need to ensure your computer boots from the Master Boot Record. If your Windows 7 or Windows 8 system uses UEFI booting, you will need to change the BIOS to CSM/MBR mode.
v1 2012-10-24 - First release - no Auto-Backup\Restore option
v2 2012-10-25 - 2nd version - added Auto-Backup\Restore option, split up long command line using grub4dos environment variables for easier editing\viewing, suppress keymap menu
v3 2012-11-01 - Added hotkey to menu, F4 for Restore from any Image, F6 for Auto-Restore
What we are going to do is to place a copy of Clonezilla on a spare backup partition on your hard disk, add some files and then install the grub4dos bootloader onto your hard disk.
After this has been done, your system will boot to a new grub4dos menu, as shown below (in this example we have a Windows XP system, so the menu shows Windows XP).
The menu.lst will automatically work out what partition is your Windows partition and what partition is the backup partition. When the menu is displayed, you will see which partition has been picked by the menu because the names listed in the menu will be changed automatically - e.g. sda1, sda2, etc. Thus it does not matter what partition arrangement you have as long as both the Windows and Clonezilla partitions are on the first disk (i.e. they can be in any order).
Linux disk notation:
sda1 = First hard disk (a), first partition (1)
sda2 = First hard disk (a), second partition (2)
sdb5 = Second hard disk (b), first Logical partition (5) - 1 to 4 are the primary partitions.
This is the grub4dos boot menu - after a 10 seconds countdown it will boot to Windows unless a key is pressed.
1. First we need to ensure that you have a spare partition on your hard disk that we can use to store the backup files and CloneZilla. This will appear on your system as D: and you will need to ensure that you have at least several gigabytes of spare space available on it. If you do not have a 2nd partition or you need to create a larger partition then you can use Windows Vista or 7 Disk Manager to delete, extend or shrink partitions. The Backup partition can be NTFS (preferred) or FAT32 and it can be a primary basic partition or a logical partition.
>>> Before you proceed, check that the target system is a standard Windows system with two or more partitions
and check that the backup partition (e.g. D:) has lots of spare space.
PLEASE NOTE: The menu.lst will only detect the BACKUP partition if it is on the first, second, third or fourth internal hard drive (partitions 1-7). You can edit the menu.lst if it does not detect the backup drive.
GPT disks: Clonezilla does not recognise GPT partitions. If your disk previously contained GPT partitions, CloneZilla may not work even though you delete all partitions and create new MBR partitions using Windows Setup. For this reason, it is highly recommended to use Windows DiskPart from a command shell to wipe the disk before you install a fresh copy of Windows. Typical commands are: SELECT DISK 0 - CLEAN - CONVERT MBR. Thanks to 'James' for this tip!
2. We need some tools, so on any Windows system (it does not need to be the target system), download the zip file CloneZillaBackup.zip from the bottom of this page and extract the contents to a new folder on your hard disk (I will call this new folder c:\xxx).
3. Download the CloneZilla ISO file from here - I used clonezilla-live-20120620-precise.iso. Use 7Zip or some other utility to extract the \live folder from inside the iso and copy it to the C:\xxx\clonezilla folder. Only three files are actually needed but you can copy the whole live folder if you like.
4. You should now have a folder structure like this (where xxx can be any name you choose):
Installing the CloneZilla files onto a target system:
5. Now copy the the xxx folder contents(via a USB drive or via the network) to the backup partition (D: usually) of your target system - you should now have this folder structure (assuming D: is your backup volume)
6. To install grub4dos onto your target internal hard disk, double-click on the file D:\clonezilla\InstallGrub4dos.cmd - If you receive no error message then press Y and hit the <Enter> key.
7. It is time to reboot your system and check that you get the new menu and that you can still boot to Windows. Restart Windows and you should see the new boot menu, if you wait 10 seconds, it should then boot to Windows as normal. You can simply hit <Enter> to avoid the 10 second wait.
Note: If you are just dropped to a grub> command prompt, then try typing the following commands:
find --set-root /menu.lst
If you need to type this on every boot, then copy the menu.lst file from the backup D:\ drive to the root of the C:\ drive.
Note: If, in future, you change this C:\menu.lst file, remember to save a copy of it on your backup drive D: also, in case the C: copy gets deleted.
If your system does not show the menu (or indeed any change) then it may be that the system is set up for UEFI booting. In which case you will need to change the BIOS settings for CMS\MBR booting.
8. When the system has rebooted to Windows, double-click on the file D:\Hide.cmd to hide the \clonezilla folder and a few of the grub4dos files - only the D:\UnHide.cmd file should now be visible in Windows Explorer (unless you have changed the Folder View default options).
Create a Windows Backup Image
9. Finally, we need to create a Windows Backup Image - reboot the Windows system and when you see the grub4dos boot menu, choose '2 Create Backup Image' (press 2 and the <Enter> or use the Down or Right cursor keys). You will see a blank screen with a flashing cursor for a few seconds and then some linux boot progress text. The current menu does not allow you to select a keymap, if you delete the preseed option (see below) then you will then see a 'Configuring console-data' screen heading and be able to choose a keyboard type.
This menu is only seen if you delete live_keymap="NONE" in the menu.lst file.
If all is well, you should eventually now be offered a file name to use for the backup that you are about to make - e.g. 2012-20-23-12-img - you can change this name if you like and then click on OK to continue.
Clonezilla should then automatically backup your Windows volume (usually sda1) and then reboot.
If you want to have a simple single-backup option, use the 4 Auto-Backup menu - this is fully automated and always backs up to the file IMG.
Restore from a Backup Image
To restore a previous Windows backup image, reboot and select the '1 Restore Backup Image' option. You will be able to select one of any of the previous backups that you have made and restore that image. When complete Clonezilla will reboot the system automatically.
Tip: to quickly check that the image backup/restore is working, make a backup and then change your Desktop wallpaper and then reboot and restore the original image - your wallpaper should now be changed back again.
The 3 F6 Auto-Restore menu is fully automated and will restore the backup (IMG) made by Auto-Backup (option 4). This means you could remove all other menu options and just leave the F6 menu so that the user could restore the IMG image. If you also deleted the -c option from the menu, the image restore would be completely automatic with no user prompts whatsoever (and all new user data would be lost!). Note that if no IMG backup already exists, it will report an error and reboot.
If Clonezilla does not boot on your system - try the x64 version here.
If you are stuck at a grub4dos prompt and you get no menu and it won't boot to Windows, to boot to Windows, type:
Tweaking the system
The text file menu.lst controls the menu appearance and the backup/restore optons:
1. If you want to change the background image, use an 800x600 24-bit or 32-bit colour bitmap and change the name in the menu.lst file (see 'How it Works' below).
2. If you don't see a nice bitmap background on the boot menu, it is probably because your system does not support 800x600x32 graphics mode. Please refer to the grub4dos tutorial for information about high-resolution background images and how to make it work for your system. Use the UnHide.cmd batch file to unhide all the files on the D: volume so that you can easily alter them. Typically you will need to run vbeprobe inside the grub4dos console shell (press c in the boot menu) to see what graphics modes you have available, then find a suitable bitmap of matching resolution (e.g. 1024x768x24 colours) and then edit the menu.lst file to change to the correct graphics mode and display the correct bitmap.
3. The current menu will not prompt the user to select a keymap, this can be added if you delete the text ocs_live_keymap="NONE" from the kernel parameter list in the menu entries.
4. You can delete the 'Auto-Backup' and 'Auto-Restore' menus (starting at title) or you can delete the 'Restore Backup' and 'Create Backup' options or the manual menu, as you wish. Simply edit the menu.lst file using Notepad.
5. To not prompt the user before an auto-backup or auto-restore is actually performed (i.e. fully automated backup/restore), remove the -c option from the middle of the RUN1 parameters in the menu.lst file.
6. The latest version has the hotkey grub4dos utility added. This allows the user to press a function key to execute a menu item. You can change the function key number by editing the menu. See Tutorial 57 for more details.
7. If you want to protect a menu with a password to prevent unauthorised use, add a single new line immediately below the each title line to set a password like this:
How it works
Once grub4dos is installed the boot sequence is as follows:
BIOS boots from first sector of Hard Disk 0 -> grub4dos code runs and looks for a grldr file on any partition on hd0 -> grldr loads and looks for a menu.lst on the same partition that grldr was found -> menu is displayed to the user.
The menu.lst file is shown below with extra comments in colour (note: some long lines may be wrapped over onto the next line!):
# next line loads the hotkey utility so the menu will respond to hotkeys
# allow vbeprobe command to output text
# list all available BIOS modes
vbeprobe > (md)0x220+5
# turn off text output from future commands
# clear the display to keep it clean!
# look for 800x600 modes
#This text tries to detect what graphics mode are available and sets a GM variable
# --batch - automate run
# -c check - asks user before completing action - Are you sure you want to continue ? (y/n)
# -e1auto - Automatically adjust filesystem geometry for a NTFS boot partition if exists
# -t - Client does not restore the MBR (Master Boot Record)
# -gauto - Reinstall grub in client disk MBR (only if grub config exists)
# -e1auto - Automatically adjust filesystem geometry for a NTFS boot partition if exists
# -e2 - sfdisk uses CHS of hard drive from EDD (for non-grub boot loader)
# -u - Asks the user for the image name (could be set in config too).
# restoredisk or savedisk - Which mode to run, store, restore, partition or hard-drive
# ask_user - requests name from user.
# sdax – Which hard-drive should be written or read.
# -q2 – Use “partclone".
# -z1p – Use gzip-compression (with multicore)
# -i 2048 – Split filesize in megabyte (Split every 2GB a new file for the backup - use if FAT32 backup ptn.)
# -ppoweroff - power off after successfully running the script.
# -rm-win-swap-hib Removes the page and hibernation files in Win if exists
# -sc - suppress verify check after backup
Setting a pre-boot silent splash screen
If you want the user to see a splash screen but no menu at all, the user will then have no idea that the backup/restore menu exists. After 10 seconds the splash screen will disappear and the system will boot to Windows as normal. However, if the user hits a function key, the appropriate menu will be activated. This can be accomplished by adding the 8 blue lines of text below to the top of the menu.lst file:
find --set-root /clonezilla/menusetting.gz # display the heading and cover up grub4dos version text
#set black text on black background so user will not see countdown timer or menu text
# The command parameters 0 0 0 0 0 0 0 0 sets a 0 size border (i.e. no border around menu)
/clonezilla/menusetting.gz 0 0 0 0 0 0 0 0
To remove the various grub4dos start-up boot messages that appear before grub4dos loads the menu, download the grub4dos patch file PatchMe. Copy it to the D:\clonezilla folder. Boot to the grub4dos menu and press c to get to the command console. Then type:
find --set-root /grldr /clonezilla/patchme
This will patch the boot code and grldr file. Once patched, the PatchMe file is no longer required and can be deleted if you wish.
The user will just see the wallpaper image with no text or highlight line at all - if he presses F4 or F6 then the menu entry chosen will be executed immediately. To shorten the timeout - just change the text 'timeout 10' to 'timeout 1' for a 1 seconds timeout.
Adding audio/video aids for the partially sighted
If you need a beep to know when to press the function key, you can add the following line of code to the top of the menu.lst file:
color standard 0xF1 && clear && call Fn.2 7 && call Fn.2 7 && call Fn.2 7 && color standard 0xf && clear
This sets blue text on a white background - clears the screen so it is all white - beeps 3 times (if your hardware supports it) - sets white text on a black background - clears the screen so it is all black. Once the beeps have finished you can press a function key within the specified timeout period.
If in graphics mode, you will need to use the bios grub4dos utility to beep the speaker once - e.g.
call /bios int=0x10 eax=0xe07 > nul
Removing the grub4dos bootloader
If you want to return to a normal booting system and remove the grub4dos bootloader and menu system, run RMPrepUSB hit Ctrl+F5, select the HDD and then hit Ctrl+B. This changes the Settings to ALL DRIVES mode, so that the hard disk will appear in the drive list and then installs a standard bootloader using the Bootloaders - Install STD Mbr option. You can then delete the menu.lst files and the backups and files on drive D: if you wish.