Migrate to a virtual Linux environment with Clonezilla

Introducing Clonezilla Live

Clonezilla is an open source (GPL) Norton Ghost-like duplication and clone solution that you can use to clone a particular partition or entire disk. There are two releases: Clonezilla SE (server edition) and Clonezilla Live. Clonezilla SE is best suited for backup and restoring multiple servers simultaneously across the network. Clonezilla Live is a more lightweight build for single-machine cloning.

Clonezilla Live is the combination of Debian Live and Clonezilla; it has the following features and benefits:

Clonezilla Live uses such existing tools as Partition Image, ntfsclone, partclone, and dd to clone the partition or disk. For unlisted file systems, Clonezilla uses dd to copy all used and unused blocks.

From now on, we'll be creating a virtual machine within VMware Server as the destination for system migration. Make sure that the host environment complies with the VMware Server and guest operating system requirements and limitations. Because the virtual machine will use the same processor as the host as a baseline, it requires that the host environment and the physical server we cloned have compatible types of processors.

First, use the VMware New Virtual Machine Wizard to create the virtual machine. During the process, select the operating system version that matches the cloned one from the physical server. Also, you have to create a virtual disk with the size equal to or larger than the partition where the original cloned system resides, because Clonezilla does not support restoring an image from a large hard disk or partition to a smaller one. During the Clonezilla Live restoration process, however, you are able to restore the image to a large hard disk according to the original disk layout.

Figure 5. Specifying the virtual machine's disk capacity

Note: The Clonezilla Live kernel might not support the SCSI disk for the earlier VMware Server versions. In this case, when you create the virtual machine, use the IDE type for the virtual disks.

Second, change the virtual CD-ROM device as using the Clonezilla Live ISO image for the virtual machine, as shown in Figure 6.

Figure 6. Using Clonezilla Live ISO image in VM

Third, put the system image files from the previous section under the host server's second disk, the Partition 0 of PhysicalDrive 1. Because the VMware Server supports the pass-through SCSI drive access on the host system, add another hard disk for the virtual machine with the Partition 0 of PhysicalDrive 1 directly attached in VMware. At the restore phase, this device will be presented to the /home/partimag.


Figure 7. Attaching the partition with system image

Now that you have a compact virtual machine created, it's time to boot the virtual machine from the Clonezilla Live.

Step 3. Restoring the image onto the virtual machine

After the virtual machine boots up from the Clonezilla Live image, Clonezilla Live has the same GUI-based wizard interface for restoration as for backup until you choose the mode. In this example, we will enter the Debian-based Clonezilla Live shell directly to select a manual restoration.


Figure 8. Clonezilla Live shell

To restore the image under the Clonezilla Live shell, you must log on with the root role; then you have full access on the Clonezilla.


Listing 1. Becoming root user
user@debian:~$ sudo su -
debian:~#

Now you need to determine the destination disk for restoration and the disk where the source image is to be placed. Listing 2 shows two local hard disks.


Listing 2. Viewing disk information
debian:~# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sda doesn't contain a valid partition table

Disk /dev/sdb: 160.0 GB, 160039272960 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa0bea0be

Device Boot         Start       End      Blocks       Id    System
/dev/sdb1            1            19457   156288321   7      HPFS/NTFS

The /dev/sda is the virtual disk we created as the restoration destination; it is unformatted. The /dev/sdb is the PhysicalDrive 1 of the host server that we attached to the virtual machine directly in the form of a pass-through SCSI device; we have the cloned system image on it.

To restore the cloned partition image, the destination virtual disk has to be presented to Clonezilla as formatted. You can use the fdisk tool to write the label onto the virtual disk. This procedure is shown in Listing 3.


Listing 3. Format the destination disk
# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xee2955bc.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5221, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-5221, default 5221): 
Using default value 5221

Command (m for help):
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
[ 866.679048] sd 0:0:0:0: [sda] 83886080 512-byte hardware sectors (42950 MB)
[ 866.682658] sd 0:0:0:0: [sda] Write Protect is off
[ 866.683795] sd 0:0:0:0: [sda] Cache data unavailable
[ 866.683822] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 866.686443]  sda: sda1
[ 866.695530] sd 0:0:0:0: [sda] 83886080 512-byte hardware sectors (42950 MB)
[ 866.698278] sd 0:0:0:0: [sda] Write Protect is off
[ 866.699422] sd 0:0:0:0: [sda] Cache data unavailable
[ 866.699495] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 868.702058]  sda: sda1 
Syncing disks.

We can accept the default values in Listing 3. The partition type is not a concern at this time because it will be re-created by Clonezilla during the image restoration.

As with the backup procedure, you must mount a writable device or space as /home/partimag, then Clonezilla will search the cloned image directory under /home/partimag. To prepare the restoration from the image on the partition /dev/sdb1 to the newly created partition /dev/sda1, first mount the /dev/sdb1 to /home/partimag with the writable privilege. Note that here /dev/sdb1 is an NTFS file system on the host server, and it may be open, so a force option might be required to mount it successfully. See Listing 4.


Listing 4. Mounting the image device to /home/partimag
debian:~# mount -t ntfs-3g /dev/sdb1 /home/partimag -o force
debian:~# ls /home/partimag
Sys01-2009-02-23-img

When the /home/partimag and the destination partition are ready, you have to choose the best way to restore the image for your environment. As for backup, Clonezilla also provides a variety of advanced and flexible options for image restoration. See Figure 9 for the restoration parameters and their meanings.


Figure 9. Clonezilla advanced extra parameters: restore

For Windows system image restoration, the boot header has to be written to the destination disk. To achieve this, -j0 (use dd to create partition table) and -t1 (client restores the prebuilt MBR from syslinux) are recommended. The hnX PC (X is 0 or 1) option is good to ensure that your environment has a unique Windows machine name. In case you don't want to keep your current destination partition layout, you also can try -k1 or another partition-relation parameter to create another partition table.

Listing 5 restores the image Sys01-2009-02-23-img from /home/partimag (/dev/sdb1) to the destination device /dev/sda1.


Listing 5. Using command line to restore the image
debian:~# /opt/drbl/sbin/ocs-sr -e1 auto -c -t1 -r -j3 -cm -j0 -p reboot restoreparts
             "Sys01-2009-02-23-img" "sda1"

Figure 10 shows the summary and progress updates you'll receive after you confirm the choice. After that, you have your cloned system on a virtual machine.


Figure 10. Clonezilla restore summary and progress

When the restoration is done, you can watch your system boot up from the virtual machine. To get better performance, install the VMware Tools for the virtual operating system.

To ensure a successful migration experience for Windows, you should have solid knowledge of HAL and be able to use tools like sysprep to prepare your physical server to support the virtual machine environment.

Conclusion

This article has shown you how to complete a physical-to-virtual system migration using an image-based method and open source tools. Remember to use the steps here as a reference; due to differences in environments, your system and migration experience may be different from what you read here.

Resources

Learn
Get products and technologies

[Apr 2, 2009] Will SLES Make Virtualization Ubiquitous

With SLES it is offering "a baseline image" so software vendors can easily build appliances. The concept is something know as a JeOS (Just enough Operating System) and has been trumpeted by Novell as the future of operating systems," InternetNews.com reports

Even more revealing is Vice President of Solution and Product Marketing Justin Steinman's comment to InternetNews.com, "We designed SLES 11 to be ubiquitous, to run in physical, virtual and cloud models."

This approach is very different from the one that its chief competitor, Red Hat, is taking. Last month, Red Hat released a stand-alone virtualization hypervisor based on KVM (Kernel Virtual Machine) as well as a new hypervisor for Red Hat Enterprise Linux. It also unveiled Red Hat Enterprise Virtualization Manager for Servers, an open source virtualization management suite to facilitate fully integrated management across virtual servers and desktops.

Red Hat is in many ways hedging its bets, updating its operating system as well as releasing its own hypervisor.

Let's face it, though, there are three hypervisors out the that merit consideration.

[Mar 01, 2009] Microsoft's Ballmer On Windows Server, Yahoo, Linux

InformationWeek

InformationWeek: I think you see VMware aggressively courting virtualization customers. Customers that I've spoken with are saying Microsoft is definitely coming from behind here. You mentioned it on stage here. There's Hyper-V's delay. Does Microsoft's entrance now into the virtualization space put it at a disadvantage in the virtualization world?

Ballmer: The choice is, you know, to be first to have share or not. I guess I prefer to be first to have share. Now, you've got to remember, this market has barely been scratched, less probably in the install base -- less than 5% of all systems run virtually. Virtualization is way too complicated, way too expensive today for people to take advantage of it, and it's way too isolated from the rest of everything that happens in application development to data center deployment and operations. That's not my way of criticizing, it's just if we're going to get -- if the phenomenon is going to fully take effect, then we've got to democratize it. That might be VMware, [but] they haven't shown moves in that direction. Somebody could argue it might be one of the open source alternatives. I like what we've got. I think we pay out on those problems.

That doesn't mean the other guys are going to go away. Obviously we recognize that fact and we provide good interoperability with VMware's virtual machine. But I don't think -- there's a simplicity with performance, with management, integrated management, with everything else, I think we're going to make a real difference. Sure, I wish we had everything we're announcing now and shipping this year a year ago, sure. Two years ago? Sure. But, believe me. We're going to make a big difference.

Comments

The fact of the matter is Linux isn't much cheaper to use than Microsoft, in terms of initial expense, continued support, or even in terms of development.

What Linux excels in is its large community of free, and sometimes paid developers to fix problems corrected more quickly than a single company can possible achieve. When you take Linus' recent comments into account, about him never caring or running a Linux server, only being focused on the desktop, one has to really wonder what how it can possibly compete with commercial giants like Sun and Microsoft.

What Microsoft excels in is their world-class support and a quality product at a reasonable price with an enormous ecosystem and unlimited developmental budget.

The commercial Linux vendors, Red Hat and Suse, can't offer the ecosystem Microsoft does, nor the leverage it has with its developers or vendors. The non-commercial Linux distributions are fun to play with, but totally impractical for business use.

The war goes on... Linux and most significantly Solaris are taking a bad beating. Once MS goes full bore in the virtualization space, it's going to blow Linux, Solaris and WMWare out of the market entirely, because of its massive commitment in research and functionality.

Finally, if MS doesn't like how its being treated in the US or Europe for that matter, it might just decide to stop selling to those markets -- where would that leave customers?

... ... ...

Ballmer: "I used to always joke with IBM, you know, we were opening up the desktop to them, and they were opening up the mainframe and the data center to us. And who out-hustled who is a big deal in terms of who wins."