(WARNING you need to take great care in this process and know which is your original disk. This example assumes the /dev/sda is the disk with your working operating system and data on and /dev/sdb is the one that is going to be the new one).
Partition 1 - Windows
Other partitions are Linux based file systems.
Most sites will tell you that you can't just move Windows from one disk to another without having to do an ASR (Automated Systems Recovery), well that's just a load of BS and comes from a bunch of I.T. people that really don't understand computer systems properly.
So here is how it's done without having to do anything apart from move the partitions from one disk to another using a real tool.
Preparing the disk
- First acquire a copy of Linux. Any one will do that will allow you to boot a command line via a rescue system. I used Fedora 12 DVD
- Boot the Fedora 12 DVD with only your main drive (still in the system) attached
- At the options menu select the Rescue option, but press the TAB key and delete the entire line
- Replace the line with linux rescue and press enter
- Accept the language you need and the keyboard layout
- Say no to the network being started
- Do not mount or search for existing systems
- Select the Shell option
- You will now have a bash Linux command line and some lovely utilities
- Plug in your external drive that will be your new O/S disk
- Use fdisk to set up the partitions, ensuring that the sizes are exactly the same between the disks. Use the fdisk -l option to list the disks and see the partition information for both disks. Keep typing fdisk -l until you see /dev/sda and /dev/sdb or at least 2 disks
- Your primary disk (the one with the operating system on it currently) should be /dev/sda if it's a SATA drive like mine. And the USB external drive will be /dev/sdb (if there are no other disks in your system)
- Type fdisk /dev/sdb to modify the layout of the external disk
d will delete a partition
n will create a new partition
p will print the partition table
w will save the partition table
a will allow you to set the active boot partition - You will need all of the above commands to set up your disk to be the new O/S disk
- Delete any partitions that are on the new disk (/dev/sdb)
- Hopefully the geometry of the disks will be similar so that when you create a new partition you should be able to use the same Start and End cylinders as the old disk. You can check by the number of blocks, which should be the same for each corresponding file system e.g.
/dev/sda1 1 1912 15358108+ 7 HPFS/NTFS
/dev/sdb1 1 1912 15358108+ 7 HPFS/NTFS - Once you have set all of the partitions to their correct size and marked the relevant partition as the active boot (you can identify this by looking for the * against the device) then we can start copying the partitions between the disks
Copying the partitions
- We will use a command called dd to copy the partitions. This is a byte copying utility that does not care what your data is, it just does the job, unlike these Windows command tools which clearly don't.
- To copy the first partition type
dd if=/dev/sda1 of=/dev/sdb1 - Wait for the command prompt to come back. There is no information displayed on the screen during the copy, but you can tell it to show information
- To see progress of the dd command press ATL+F2 to move to the secondary terminal window
- Type
ps -ef | grep dd - Identify the dd if=/dev.... process ID (PID)
- Type
kill -USR1 PIDfromStep6 - Press ALT+F1 to return to the original screen where dd is running and notice the information on the screen. It will tell you how much has been transferred so far and how fast the transfer is going.
- Repeat the above steps for every partition on the original O/S drive
When the process of copying all the partitions has finished carefully swap the hard disks over. When you start your system you will only need to start it with the new disk.
Starting the system (if you have dual boot)
- Boot from the Fedora DVD
- Select the Linux rescue
- This time follow the instruction and tell it to search for the Linux system
- Tell it to mount the found Linux system to /mnt/sysimage
- Type
cd /mnt/sysimage - Type
chroot /mnt/sysimage - Now we need to ensure that the MBR is correctly written to the disk, so type
grub-install /dev/sda - Type
reboot
Your system can now be started without the DVD and will boot to GRUB, from their you can then choose your operating systems as normal.
If Windows then the system should just boot with no further modifications.
This is all based on the size of your partitions being identical between both disks (even if the sizes of the physical disk are different).