Don't worry if you lose your boot menu or partition name – we can help…

All this messing around with partitions and boot blocks can cause problems. So it's worth remembering that even if things look bad, there is usually something you can do to recover lost data.

If you realise you've made a mistake in re-partitioning a drive before you get to the point where those partitions are formatted, for instance, there may be a way to save your data. When a new partition table is written to your drive, none of the data is affected; only the part of the disk that indicates which partitions are where. There are a few tools than be used to trawl through this data and can recognise and log the changes between your files and the previous partitions boundaries.

Emergency recovery

We've found the best tool for the job is called TestDisk, which can usually be installed through your distribution's package manager, and on the command line with apt-get install testdisk on Debian and Ubuntu systems. Typing sudo testdisk on the command line will launch the menu-driven utility, and you'll need to select the log option you need followed by Proceed on the partition you're interested in.

The tool will run its magic. Then select Write and give a few confirmations that you're happy with the potential hazards that the tools could reap upon your data. But with a bit of luck, a single reboot later should see your partition table restored, along with your dual-boot abilities.

Come back Grub!

Similarly, losing your Grub menu can feel equally catastrophic, but you should be able to restore your system to full working order. For pre-Grub 2 installation of around a year old, boot the machine off an older live CD, open a command line and type sudo grub.

This will drop you into the command line mode of the Grub boot loader, and from there you need to type find /boot/grub/stage1.

The returned output will show you the location of your boot partition, and you'll need to replace hd0 with your own drive in the following commands – root(hd0,0) and setup (hd). Finally, type quit and reboot your system. You should find Grub re-installed.

For Grub 2-based systems, you should be able to just boot off a live CD and type sudo update-grub to restore the boot loader and get your system running again. This should leave you with all bases covered.

You can create partitions with confidence, install Linux alongside Windows and other Linux installations, and troubleshoot all the most common problems if anything untoward should happen. You can now sit back and enjoy the benefits of your new multi-booting system.

-------------------------------------------------------------------------------------------------------

First published in Linux Format Issue 133

Liked this? Then check out How to run Linux in a virtual machine

Sign up for TechRadar's free Weird Week in Tech newsletter
Get the oddest tech stories of the week, plus the most popular news and reviews delivered straight to your inbox. Sign up at http://www.techradar.com/register

Follow TechRadar on Twitter * Find us on Facebook