Using Linux to Upgrade a Windows® Hard Disk
Upgrading the hard disk on an existing Windows installation can be one of the trickiest upgrades to perform. When adding more memory, adding a faster CPU, or even adding an additional (second, third, etc.) hard disk, Windows takes care of most of the work for you by autodetecting the new hardware and integrating it seamlessly. But, when replacing an existing hard disk, probably with a larger or faster one, there are a host of other issues to consider. You probably have a bunch of data on your old hard disk that you want to preserve. Luckily, there are a host of backup options that make that easy to deal with. But, what about the OS installation itself, and the installation and configuration of all your favorite programs? If you want to perform the hard disk replacement, and in one step, have everything (programs, preferences, settings, etc.) exactly how they were, you have a problem. If you have licensed software (e.g. Windows, or other application) that you either don't have the license key for, don't want to have to manually install again, or fear might require you to buy another license for, you have a problem. For example, Microsoft licensing uses a rather complicated scheme of identifying different components within a computer to determine when you've simply made an upgrade, and when you have a new computer (not a black-and-white issue). Changing hardware may trigger their software to require a new license to be purchased. Luckily, there are some options.
First of all, you should always have a good system for backing up your important data, regardless of whether or not you plan on changing out a hard disk. Secondly, before making an upgrade like this, it's wise to try to compile a list of all the license keys for the licensed software you have (and wish to keep using). For some apps, you can recover the license key if you've misplaced it. A good idea is to use a key finder program to recover any lost keys before embarking on a hard disk upgrade. Search for "license key finder" and you'll be presented with many options.
Once you've setup a backup system, and collected your license keys, you're ready to attempt the hard disk upgrade. One option, if you're using Windows Vista, is to use Microsoft's Ximage and Sysprep tools. I considered these for my hard disk upgrade, on a machine that had Vista (no Service Pack) installed. However, I found the process to be overly complicated. It also required installing the WAIK (Windows Automated Installation Kit), which for some odd-reason, can only be installed via a downloaded .iso image, which requires a blank DVD to burn the image. As it turns out, I didn't have a blank DVD available, and needed to get the upgrade completed ASAP. This will usually not be a constraint, however, I also found the rest of the Ximage/Sysprep process to be overly involved. This lead me to Linux, and
To clarify, using Linux and dd does not require you to have Linux installed on any computer, or have some dual-boot configuration on the computer on which you're going to install the new hard disk. What you do need is a linux boot disk (CDROM). Of course, this presents a similar requirement to the WAIK .iso image, but as it turns out, I had several flavors of linux boot disk laying around! For this project, I used an old SuSE linux 8.1 boot disk, because it quickly found the correct drivers for all of my hardware. However, you should be able to similarly complete this process with most types of linux boot CDROMs. It should be noted, however, that you may have trouble with certain distributions not recognizing all of you hardware without manual intervention. Thus, trying a couple distributions may be needed (as it was for me). The important hardware to be recognized would be a network card (if you don't have a spare disk in the computer you are upgrading), and possibly a disk controller (e.g. SCSI) if your hardware uses such a card. In my case, the upgrade involved starting with a 36GB SCSI disk drive, and adding a second identical SCSI drive, making a RAID 0 array. Thus, the old (source) disk, was also part of the new (target) configuration. This meant that I could not directly copy my old hard disk contents to the new hard disk, but instead needed to make a temporary copy of the disk, and then write that copy to the new RAID array. So, this represents one of the most complex disk upgrade scenarios, which is why I'm describing the technique here!
The basics steps are as follows:
linux>> fdisk -l /dev/sda Disk /dev/sda: 255 heads, 63 sectors, 4462 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/sda1 1 16 128488+ 83 Linux /dev/sda2 * 17 4462 35844717 7 HPFS/NTFS
This particular disk has two partitions ... a linux partition used to hold my bootloader (GRUB), and the Vista (NTFS) partition. Next, we need to mount a network drive with space for the backup:
linux>> mkdir /mnt/backup linux>> ifconfig -a eth0 Link encap:Ethernet HWaddr 00:08:74:4F:2A:C6 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0xdcc0 Memory:ff6e0000-0 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) linux>> ifconfig eth0 192.168.0.10 netmask 255.255.255.0 up linux>> ping 192.168.0.44 PING 192.168.0.44 (192.168.0.44) from 192.168.0.10 : 56(84) bytes of data. 64 bytes from 192.168.0.44: icmp_seq=1 ttl=64 time=0.377 ms 64 bytes from 192.168.0.44: icmp_seq=2 ttl=64 time=0.296 ms 64 bytes from 192.168.0.44: icmp_seq=3 ttl=64 time=0.135 ms --- 192.168.0.44 ping statistics --- 3 packets transmitted, 3 received, 0% loss, time 1999ms rtt min/avg/max/mdev = 0.135/0.269/0.377/0.101 ms linux>> mount -t nfs 192.168.0.44:/export/path/ /mnt/backup
linux>> dd if=/dev/sda conv=sync,noerror bs=64k | gzip -c > /mnt/backup/sda.img.gz 560057+1 records in 560058+0 records out
linux>> mkdir /mnt/backup linux>> ifconfig -a linux>> ifconfig eth0 192.168.0.10 netmask 255.255.255.0 up linux>> ping 192.168.0.44 linux>> mount -t nfs 192.168.0.44:/export/path/ /mnt/backup linux>> gzip -cd /mnt/backup/sda.img.gz | dd of=/dev/sda 560058+0 records in 560058+0 records out linux>> fdisk -l /dev/sda Disk /dev/sda: 255 heads, 63 sectors, 8836 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/sda1 1 16 128488+ 83 Linux /dev/sda2 * 17 4462 35844717 7 HPFS/NTFS
At this point, you can reboot your computer, without the linux boot disk. You should be able to get back into Windows, just as before. When, you first open My Computer, you may notice that you seem to have the same sized hard disk as before the upgrade. Presumably, you actually added a larger hard drive. This is not a mistake. You backed up the entire hard disk, which include the partition table that specifies the size of the disk partitions. So, at this point, you probably have a bunch of unused space on your new hard disk (equal to the amount by which the new disk is bigger than the old one). You can either use the linux boot CDROM to resize the partitions (even if they are Windows partitions), or probably easier, just use the Windows Computer Management application.
To use Computer Management, select Start -> Run and type in
So, there you have it. In a limited number of steps, you have made an exact copy of an existing Windows installation, and laid down everything on the new disk as it was on the old. You don't need to manually reinstall the OS, restore a backup, and reinstall applications individually. Since, this is the same computer, you've avoided any unnecessary license repurchase scenarios. Long-live linux!