(Ok, innuendo aside…)
Well, the Christmas/Yule break is over with and it’s time to get cracking. If you were like me this holiday season, you were either placed in the position if needing to do a hard drive upgrade for someone else or you received a new hard drive of your own that warrants upgrading. The CloneZilla site didn’t contain very clear instructions for what to do so I decided to write this howto documenting the process. In this howto, I will cover using the free application “CloneZilla” to perform a hard drive upgrade on a test installation of Windows XP from 4GB to a 10GB drive.
Of course, it’s Christmastime/Yule and I took pity on my girlfriend’s laptop which had two things going against it. Firstly, it had vista and secondly it had a 80GB hard drive. I’m not sure why Toshiba in their infinite wisdom only gave it a 80GB HD, but they did. Thankfully I had just completed an upgrade to another machine and had a 250GB hard drive to spare. So I set out to upgrade her hard drive and fix at least one of the two reasons that her laptop was evil.
A lot of research turned up various solutions however none of them were very viable or were free. Most of them required two hard drives in one computer and although her laptop did have the solder traces for the second SATA hard drive connector I’m not about to take a soldering iron to her laptop, she’d kill me. So with that said and with my head still attached to my body, I kept searching. I found a Live CD application called CloneZilla which had Cloning abilities much like a certain Symantic product but was free and didn’t require extensive configuration to get to work. Unfortunately the instructions were not very clear at all and after spending a nailbiting hour trying to start the copy, I finally got it done and decided to document the process in case someone else got stuck in the same need that I did.
In this HOWTO, I will be upgrading a 4GB Virtual Disk in VMware with that of a 10GB Virtual disk. Aside from the fact that it’s all virtualized, this is indeed a true upgrade and is exactly how you would do an upgrade for a real “physical” computer.
You will need the following items for a successful transfer:
- The CloneZilla CD available from http://clonezilla.org/ I’m using Clonezilla Live version 1.2.2-31.
- A Windows computer that has a hard drive with free space greater than the size of the original disk you are upgrading. (If you’re upgrading a 40GB HD, then this machine must have at least 40GB free on it.) This will be the WIndows Image Server.
- The hard drive to upgrade
- A working network where your machine to upgrade can browse the other windows machine’s file shares. (This is CRITICAL, as the other machine will store your disk image for the upgrade.)
- A case of beer, rum, vodka, etc…
The “other machine” in #2 will be the image server. This is where CloneCD will copy the files to that make up the disk image. I will review how to set up a fileshare in Windows for this however any machine that does SMB filesharing can work. There are other options available however SMB sharing works the easiest.
In this HOWTO, we will be upgrading a Windows XP Virtual Machine with a 4GB HD to a 10 GB HD. Although I’m using VMware Server to capture the screenshots, this same method can be used to upgrade almost any home Windows computer. I’m not sure if Windows 7 or if Windows Server 200* will work but in all theory they should too. The process for upgrading will go something like this:
- Examine the existing system to upgrade and get existing disk size
- Configure Windows Image Server to accomodate images
- Boot system to upgrade with Clonezilla, configure and start copy process
- Swap out hard drives, reboot with Clonezilla and configure to start the restore process
- Take whatever OS steps are needed to take advantage of new space. (OS Dependent)
Step 1: Examine the existing system
This one’s easy. Just fire up the existing machine and take a look at the hard drive. In my example system, there’s only one hard drive. All I did in this screenshot was open My Computer and Right Click on Local Disk C: then go to “Properties”:
If a machine has more than one partition, you might need to go to Local Disk Managment (Start -> Run -> diskmgmt.msc ) Here’s a screenshot of what our test system looks like through Disk managment:
Based on this information and according to disk managment, the minimum free space we need on our windows image server will be 4GB. I would recommend an extra GB just in case. Now that we know how big the disk is and how much space we need, let’s get the image server configured.
Step 2: Configuration of the Windows image server
This section covers how to set up the Windows Image server for the new image. We will need to create a new directory for the image files, create a new user on the server and then assign that user with full permissions to that directory over the network.
Step 2a: Add the user
Right click on the My Computer Icon and go to Manage
This will bring up the Computer Managment Console. Click on the “+” next to “Users and Groups”, then click on Users. This will show you all of the currently installed users on the system and should resemble something like below:
Right click on the right side of the window and click on “New User…”
In the “New User” dialog box that pops up, you want to set the following options: Username = clone Description = CloneZilla user”, Password = clone “User Cannot Change Password” and “Password Never Expires” should both be checked. “Account Is Disabled” and “User Must Change password at next login” should be cleared (unchecked). See below for the reference screenshot:
Click “Create” and then click “Close”. You can see the new user in the screenshot below highlighted in a red box.
Step 2B: Configure the file share and add the user to the share.
Now that we have the user in the system, we need to create the file share. In this case, I’m using a directory inside my “D:” drive to store the images. MAKE SURE THAT WHERE YOU STORE YOUR IMAGES EXCEEDS THE CAPACITY OF THE DRIVE TO BE COPIED! In our case, we found that the system to upgrade is 4GB, so we need at least a 5GB disk to copy to.
Go ahead and locate a suitable place for your clone files. In this case “D:” is completely blank except for the system files that Windows generates for partitions. Right click and create a new folder called “clone”
Right click on the clone folder and go to “Sharing and Security”. Fill out the form and name the share “Clone” however don’t click OK just yet.
We need to make sure that the “clone” user we created earlier has full access permissions to this directory. Click on “Permissions” and add the “clone” user to the directory with full permissions.To do this, click “Add” on the Permissions screen, type in “clone”, type in “Check Names”, then hit OK. In my case, it added “ZEUS\clone” which is still correct. ZEUS is the name of the image server.
Now, I have “clone” added to the permissions window and set the proper access permissions for that username as shown below. Go ahead and click OK to the Permissions window and to the sharing properties window.
If all works well, you should see a “waiter’s hand” appear below the directory icon. This hand icon shows that this directory is shared across the network and is available for access be it read-only or read/write. At this point, we are done with configuring the server. We’ve added the “clone” user to the server, added a suitable “clone” directory for Clonezilla to store and retrieve the disk image’s files from and we have added proper permissions to the directory for the clone user.
Step 2c: Test it out!
Go back to our initial machine to upgrade. You should be able to find your image server by browsing “My Network Places”. In my case, the image server was named “zeus” and showed up only after I clicked on “View Workgroup Computers” as shown in this screenshot. You should get a similar password prompt when you try to access your image server:
Login with the user credentials we created in 2A, (username and password of “clone”) and you should be presented with a directory listing like the one shown below:
We have proven that our clone user works, but let’s test to make sure that we can write to it. Double click on the clone share and try to create a text file. (Right Click -> New -> Text File) If it creates a “New Text File.txt” like shown below, this means that your permissions are correct and you’re good to go. If you get any kind of read/write error, check your permissions on the image server.
If you’ve gotten this far, then congratulations, you’re ready to do the copy. Go ahead and shut down the system you’re upgrading and get ready for the next step:
Step 3: Boot system to upgrade with Clonezilla, configure and start copy process
Go ahead and boot the upgrade system with the CloneZilla CD. You will be presented with a boot menu like the one below. Go ahead and select the first menu option “Clonezilla live (Default Settings, VGA 1024×768)”:
It will then take a bit and flash a lot of linux based stuff at you. Finally you should be directed to choose a language. The prompt should look like this now:
You will then get a prompt about keymaps. When in doubt, just leave it alone.
More console stuff will flash past and then you’ll get the prompt you’ve been waiting for. Unless you’re very very advanced, you will only use the “Start Clonezilla” menu option:
Now we’re at a screen that is really confusing. We want to work with the disks but we also want to work with images to create partitions. In this instance, we’re going from the disk to an image file on our windows image server then back to disk again. In our instance, we will need to use option 1, Device-Image.
In this screen, it’s asking where are we storing the image. The answer is “samba/Network Neighborhood server” however if we needed to, we could use a local SSH server as well.
Now it’s asking how we connect to our network. 99% of the time this will be “dhcp” as you will know if you’re using static for anything. If you have a Linksys router or similar router/firewall device, select DHCP.
After you get a successful IP address, CloneZilla needs to know what IP address your windows image server is. In my example, the windows image server (zeus) is 192.168.0.5.
Next, Clonezilla needs to ask for the Domain. If you are not using a domain, then tab to “Cancel” and hit Enter. I’m not using a domain here, so I just hit Cancel. This is reserved for corporate networks that use a special server called a Domain Controller.
Now Clonezilla needs to know the username of the account to connect to the server. This will be the username and password you created in Step 2 above. For our test, we put clone as the username
Clonezilla prompts us for the location (the share name) of where to put the images. In the steps above, we used “clone” as the share name. This is the location we give to Clonezilla so it can store its images. Be sure to leave the leading / at the beginning of the directory name.
Next, it’s time for the password. When prompted, type in the password. Although this prompt looks different than the others, this is not a sign that something has gone wrong so relax.
If all of the information you entered was correct, you will get a filesystem mount listing similar to what is shown here. If something went wrong, you’ll get an error message outlining the possible error and a chance to re-enter the information. If it doesn’t give you the option to reenter or something isn’t right, just hit the power switch.. In this screenshot, you can see that the last line starting with //192.168.0.5…… is our image server and that it is mounted correctly!
Since we have successfully mounted our image storage as part of the liveCD’s filesystem, it’s time to start the copy. You will be prompted for which mode to run Clonezilla in. I recommend the “Beginner” method as it makes the entire copy easy.
Now we are prompted on what to do. We will start off by selecting the first option “savedisk” as we want to save the existing disk to the image server. We will use “restoredisk” later.
If you are wanting to manage multiple images, you have the option to name them with something more descriptive . For now, I selected the default name which is in YYYY-MM-DD-HH format.
Now we tell CloneCD which hard drive to copy. In most systems, there will only be one hard drive, however make sure you have the right one if not. You can select and deselect by using the space bar to toggle the asterisk. An asterisk in the brackets “[*]” means that the item is selected however the brackets alone “[ ]” means the item is deselected.
One last word from Clonezilla before it starts copying. If we wanted to run in console mode (which I will never do. 😛 ) we could do it all with one command. Just hit enter to get past this prompt and start the copying. This also tells us that it has successfully found and identified the drive we selected to copy and shut down Linux’s logical volume manager to allow direct access to the disk to copy.
One last final confirmation that the information we have entered is correct. Remember that making this image does NOT make any filesystem changes to the original hard drive and in fact, no changes to the original hard drive are ever made. This is especially good in case you need to revert your upgrade, you can just swap out hard drives and you’re back where you started from. If everything is correct in the yellow text, go ahead and type “Y” and hit enter. This will start the copy process.
Finally, the copy begins. Go ahead and grab a soda, watch a movie or something as this will take a considerable amount of time depending on the size of your hard drive. In my test example transferring a 4GB hard drive, it took roughly 16 minutes to complete. My girlfriend’s 80GB hard drive took several hours to copy.
At last, the file copy is complete and we are ready to exit Clonezilla:
Hit “Enter” then hit 0 for power off. After a few seconds, you will get the message “Please remove the disc, close the tray (if any) and press Enter to continue. Hit enter and your computer should now turn off. Go ahead and perform the drive swap now. We’re halfway there!
Step 4: Swap out hard drives, reboot with Clonezilla and configure to start the restore process
Before continuing, you want to make sure that your hard drive is recognized by the BIOS. In my test setup, I have swapped out the original 4GB VMware disk with a 10GB Vmware disk and it is displayed in the BIOS here:
Just like before, we will use the same options to create the disk image to restore the disk image. Use all of the instructions in step 2 all the way until you get to the Mode screen shown below. Instead of selecting “savedisk” like we did at the last screen, we want to use “restoredisk” instead.
Now we select the image to restore to disk. Since we only have one image listed, this is the one we use.
Once we have selected a viable image, now we are prompted to select the target device. Again, it’s the only hard drive, so it’s the device we want:
Just like before, it will tell us that we can rerun this restore using a single command from command mode:
This time, the warning needs to be read. This is just prior to performing any filesystem changes to the new hard drive. If you are absolutely sure, go ahead and answer “y” to start the restore process:
One last time, it asks to make sure you are sure about your restore decision. If everything is correct, answer “Y”.
A good bit of text will go across the screen and you will ultimately end up at a partclone screen like the one below. The text that you saw earlier is the partition application creating the destination partition for the image. Once created, partclone takes over and starts restoring the data from the image. Again, grab another drink, (I’ve got a margarita) and wait a few hours for the image to restore.
Once the restore process completes, you will be prompted to power off. Hit Enter, select option 1 and remove the CD from the CDROM tray when prompted.
Once the system reboots, it should automatically start Windows. If it does, you’re ready to go to the last step!
Step 5: Take whatever OS steps are needed to take advantage of new space. (OS Dependent)
Now these steps depend on which OS you’re using. At this point, we have made an image of the old drive, saved that image to another server and restored it to a new blank drive that is larger than the original image. As shown earlier, we have a 10GB disk in our machine to upgrade and we have just restored our 4GB image to it. We have successfully booted windows however our disk properties show that the disk image is still 4GB. (Ignore the disk space used, as I was shutting down the disk image it decided to install 50 windows updates…)
Here is the same shot of the disk managment window after the upgrade/restore. You can see that it is a 10GB drive, but is still a 4GB partition.
Attention Vista Users!!: If you are running Windows Vista, you can use Disk Managment to expand the disk size. All you have to do is right click on the C: partition shown above then go to “Expand Disk”. This will walk you through the process for expanding the disk to take up the entire space of your new drive. I’ll add new instructions to this as soon as my girlfriend lets me use her laptop again.
For those of you not running Vista, keep reading. At this point, we have validated that our restored image works properly. Now all we need to do is resize the partition to take up the entire disk. Thankfully clonezilla has a solution for that. Reboot using the CloneZilla CD. Answer the same questions regarding keymap like you did before except instead of starting clonezilla, we want to enter the Clonezilla shell.
You will get dropped to a text prompt that presents you with several options. You will want to select option 2, “Enter Command Line Prompt”. Once done, you will be at a user@debian prompt as shown here:
We are going to use the utility “ntfsresize” in order to increase the size of the partition that we restored to the new disk but first we need more information. Before we get started, run the command “su –” to get to the “root” user. This will allow us to modify the drive’s layout. At the above menu prompt, hit the digit 2 for “Enter command line prompt” and then type “su –” at the “user@debian ~$” prompt. The screen should then look like the screen below.
Then we will use “fdisk” to get the disk’s full size. I ran the command “fdisk -l /dev/hda” to get the drive size:
This is important as we are going to delete the partition, then recreate the partition. First off let’s run “fdisk /dev/hda” and use “p” to get the partition size. In this screen, we see that the partition starts at 1 and ends at 521. We want it to extend to the rest of the disk. We’ll start off by using “d” to delete the partition, (FDISK will assume partition 1) and then create a New partition using the defaults as shown below (Use the commands “N” for New partition, “P” for primary partition, and give it partition number 1). Once we have created the new partition, we will need to set the “System” back to HPFS/NTFS otherwise NTFSresize won’t work properly. Below is the FDISK responses to these commands we’ve used so far.
Now that we’ve create the new partition, we have to reset it’s type. Use the “t” command and set it to ID of 7 (HPFS/NTFS) and then use “a” to toggle it’s bootable state. We want to be able to boot into Windows after all. Use the “w” command to write the partition data to the hard drive and exit. Now that we have reset the partition size, we can use NTFSResize to expand the NTFS data. Cross your fingers and run “ntfsresize /dev/hda” and it should produce output like what is shown here. When run with no additional parameters, NTFSResize should automatically find the beginning and the end of the partition and expand the existing NTFS data to take the entire drive as shown:
With our newly resized partition we should be able to reboot and get into our Windows environment. To do that, just type “reboot” and remove the CD when prompted. Note: The above screenshot missed me using the “a” and “w” commands to toggle bootable status. Here’s what it looks like:
Ok, so now that I have fixed my grievous error, it’s time to reboot. With any luck, your computer will boot Windows and go staight into a chkdsk environment. THIS IS OK!, this means that Windows sees the new partition size and that it needs to run a consistency check. DO NOT PANIC!!! Let the consistency check run, then it will reboot your computer again. After it boots for the second time, it might prompt to restart because it found new hardware (the new HD). This is OK as well. Let the windows installation reboot. Once it has completed rebooting for the third time, get your disk properties by right clicking on C: drive and going to Properties. As shown below, we have successfully resized our partition to take up the entire drive and are now sitting at 10GB (well 9.99GB according to windows.):
Here is a screenshot from Windows XP’s Disk managment to show that we used the entire drive:
At this point, we have successfully finished the migration! Here’s a rundown of what all we did in this step:
- We restored the partition to the new drive
- We verified that the restore worked properly when booted into, e.g windows booted properly and without errors.
- We then deleted the existing partition, recreated a new partition and then set the partition type and bootable flag using Linux’s FDISK on the Clonezilla CD.
- We used NTFSResize to expand the NTFS data to take up the entire new resized partition.
- We then booted into Windows and let it do a filesystem check
- When Windows was restarted again, we validated through Properties and “Disk Management” that the new disk was used fully.
This was the most complex part of the migration as CloneZilla only goes about 90% of the way to migrating to a new, larger hard drive. I hope that this howto provides the last 10% that you are looking for. With this howto and a copy of CloneZilla, you can then upgrade almost ANY hard drive that Linux supports and can even go from IDE to SATA or SATA to IDE if need be.
I sincerely hope that this helps someone out there trying to make sense of a hard drive upgrade. I know that I learned a lot about partitions and filesystem structures by attempting an upgrade of my girlfriend’s laptop and this Windows XP installation. I know that working with partitions is a scary thing as you could potentially lose data but keep in mind that your “original” hard drive still has all the original data on it, as does the image that was stored on the windows image server.
The items in this howto can potentially be a life saver especially if you have a family member that keeps messing their computer up. You could create an image after you have performed all needed windows updates and software installations and then retain it for if something goes wrong. Rather than having to manually do an OS reload, you can run though this HOWTO in an hour and have their system up and running again, fully patched and ready to go.
I hope that you had a great Christmas/Yule with your family and look forward to keep going strong in 2010. As always, thank you for your continued patronage, you are always welcome here at YourWarrantyIsVoid.com!