Migrate to a virtual Linux environment with Clonezilla

Standard

From: Migrate to a virtual Linux environment with Clonezilla.

Migrate to a virtual Linux environment with Clonezilla

How to convert a physical server to a virtual one using the open source tool Clonezilla Live

Ting Li, Software Engineer, IBM

Summary: Learn how to use the open source Clonezilla Live cloning software to convert your physical server to a virtual one. Specifically, see how to perform a physical-to-virtual system migration using an image-based method.

Date: 21 Apr 2009
Level: Intermediate
Also available in: Russian Japanese Portuguese Spanish

Thanks to two concepts driving the data center today—economy and green computing—server virtualization is a hot topic in the IT world and a lot of hardware and software vendors are offering solutions. Virtualization solutions can have several benefits: they can let you easily migrate a virtual machine from one server to another, and let you provision a virtual as a reproducible clone image for, say,software development and testing.

The process for achieving virtualized server consolidation depends on your starting point:

  • If you are designing your system from scratch, you will likely implement virtualization from the ground up.
  • If your system already exists in the physical state, you will probably want to migrate from the physical environment to the virtual one.

I refer to the second process as physical-to-virtual migration, or P2V, and it’s the subject of this article. Several methods, manual and automatic, are generally available to facilitate P2V migration. I’ll talk about those methods and show you how to convert a physical server to a virtual machine using Clonezilla Live, a cloning-based solution.

With Clonezilla Live, you first create a system image from the physical server, then use the boot CD to restore the image onto the virtual machine’s hard disk. It’s simple and fast, and it should be useful for software developers, system administrators, and support engineers who want to analyze a system copy while maintaining the original one unchanged (and avoid possible hardware mismatch challenges).

Note: Virtual and physical systems hardware and software span a broad range, so the procedures in this article are meant as a reference guide. You may have to do some things differently to get them to work for your migration project.

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 a combination of Debian Live and Clonezilla; it has the following features and benefits:

  • It clones only the used blocks on the hard disk.
  • It provides multiple file system and even LVM support, including ext2, ext3, xfs, jfs, and LVM2 under GNU/Linux; FAT, NTFS under Microsoft Windows; and HFS+ under Mac OS.
  • You don’t need a diskless remote boot server (Diskless Remote Boot in Linux, DRBL) in Linux to set it up, as you do with Clonezilla SE.
  • CD/DVD, USB flash/hard drives, and PXE boots are supported.
  • It has a customized capability for boot and recovery procedure.

Clonezilla Live uses such existing tools as Partition Image,

,

, and

to clone the partition or disk. For unlisted file systems, Clonezilla uses

to copy all used and unused blocks.


Virtualization and system migration tools

When migrating a physical server to a virtual machine, you may run into the same limitations as when migrating one physical sever to another. For example, you can not move a 64-bit system image to a 32-bit platform. You are also most likely to encounter Hardware Abstract Layer (HAL) issues when restoring a Windows image onto the virtual machine.

Many free and commercial tools can help with system migration between the physical and virtual worlds (PlateSpin PowerConvert, VMware Convert, Microsoft® Virtual Server Migration Tookit and the cloning software); these migration tools can also solve the potential problems brought by the hardware mismatch between the physical server and the virtual machine. One of their roles is to pass the necessary drivers to the operating system kernel and initialize the drivers properly during the system boot phase. Of course, most of these P2V tools are more than you need for single-machine migration.

VMware Server is a free proprietary platform that provides support for multiple guest operating system types (from Windows, Linux, Solaris, etc.) on both Linux and Windows hosts. As a full virtualization solution, the virtual machine monitors (VMMs) running on the hypervisor provide the virtual machines with all the available types of hardware resources, including the virtual BIOS, virtual memory, virtual SCSI controller, virtual network card, etc. Because the guest operating systems are fully separated from the underlying hardware, they can run unmodified.

Now let’s look at P2V migration using Clonezilla Live to clone a Windows system image onto the virtual machine hosted by VMware Server.


Step 1. Cloning a system partition

Clonezilla tips

For a successful migration, keep these tips in mind as you follow the steps in this article, and refer back to them as a summary.

  1. Make sure the image repository has enough free space to store the data within the partition.
  2. You can split images into multiple volume files to avoid maximum file-size limits.
  3. Clonezilla won’t support restoring an image from a large hard disk or partition to a smaller one.
  4. If Clonezilla Live won’t support the SCSI disk for all VMware versions, use the IDE type for VM creation.
  5. To restore the image under the Clonezilla Live shell, you have to be logged in as root.
  6. To restore the cloned partition image, the destination virtual disk has to be presented to Clonezilla as formatted.
  7. For successful Windows® migrations, you need solid knowledge of HAL and tools like sysprep.

First, boot the physical server from the Clonezilla Live CD.

Clonezilla provides several boot choices. For example, you can select the To RAM option to load Debian Live with Clonezilla into memory and leave the CD-ROM available for other uses. Select the default, and you will get the language and keyboard layout settings. Leave the default as is.

Next, choose whether to use a GUI-based backup and restore wizard or a Debian shell for advanced access and operation. Use the Start_Clonezilla option unless you are an experienced user. You’ll see how to use the shell under Restoring the image onto the virtual machine.

Now, there are two options listed regarding the cloning types:

  • device-device is for device-to-device direct cloning.
  • device-image is for device-to-image backup.

Because you are converting a physical system to a virtual machine, the device-image type is the better choice.

Next, you have to select the image directory where the backup image writes to or restores from, as shown in Figure 1. The ssh-server, samba-server, and nfs-server options are useful when you have a network connected, and local disk free space or a backup image is not available. In our case, we will clone the system partition and save it onto another partition within the same hard disk. If you select the local_dev, you have the opportunity to choose the USB device as the Clonezilla image repository.
Figure 1. Image repository choice
Image repository choice

Depending on the internal and external (USB) inserted disks, you are now asked to select the place that will be linked to the image repository, /home/partimag. An image actually is a directory under /home/partimag with all the image-related information and data files. In this example, the system partition /dev/sda1 will be saved as the image put onto /dev/sda5. Thus, sda5 is selected to be mounted as /home/partimag/ as shown in Figure 2.
Figure 2. Image partition
Image partition

Figure 2 also shows additional command information to mount the image device and the current file system layout with the free space usage report on /home/partimag. Make sure that the image repository has enough free space to store the data within the system partition.

As shown in Figure 3, you can confirm the home directory for the Clonezilla image within the image device.
Figure 3. Clonezilla mode
Clonezilla mode

After this step, choose the mode that you are planning to use in Clonezilla Live. You can choose to save or restore the whole local disk or an individual partition. Select the third item, saveparts, for the partition backup.

After selecting the mode, you are asked to enter the image name (Sys01-2009-02-23-img) and the source device (/dev/sda1) to back up. The next several figures show advanced options for the image-creation process. Because Clonezilla supports various file system formats and is integrated with partition cloning tools such as ntfsclone, partclone, partimage, and dd, the priority order of the tools to use can be set for the current file system. Leave the default settings if you are not familiar with the file system to be cloned. The default setting of

is best suited to our NTFS-based backup.

Figure 4 shows other parameters that you can set to optimize cloning.
Figure 4. Clonezilla advanced extra parameters: clone
Clonezilla advanced extra parameters: clone

For a Windows system image, the option

saves backup and restore time by excluding the swap and hibernation files. The

or

options are recommended if you want to transfer the saved image to another place and need to check image integrity when you restore the image.

Clonezilla Live also allows you to choose the compression method with efficiency and duration considerations. Some file systems do not support files larger than 2GB, so there is an option to set the maximum file size by splitting the image into multiple volume files.

Finally, you can designate an action with the

parameter to indicate what to do after the cloning process finishes.

With your settings chosen, it’s now time to review the operation and confirm your choices. The backup and restore processes both use the ocs-sr tool; after completing the settings through the Clonezilla GUI wizard, the tool shows you the

command with the necessary parameters for achieving the same result from the command line. It also creates a temporary file containing the command, saved under the /tmp directory.

Now, sit back and wait for the backup to be completed. After it’s done and the server boots up, transfer the image directory from the physical server to the place you will use as the restoration source for the virtual machine.


Step 2. Preparing the virtual machine

From here 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 cloned physical server 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 equal to or larger in size than the partition where the original cloned system resides; Clonezilla does not support restoring an image from a larger 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
Specifying virtual machine's disk capacity

Note: The Clonezilla Live kernel might not support the SCSI disk for 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 to use the Clonezilla Live ISO image for the virtual machine, as shown in Figure 6.
Figure 6. Using Clonezilla Live ISO image in VM
Using Clonezilla Live ISO image in VM

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

Now that you have a compact virtual machine created, it’s time to boot the virtual machine from 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, as shown in Figure 8. In this example, we will enter the Debian-based Clonezilla Live shell directly to select a manual restoration.
Figure 8. Clonezilla Live shell
Clonezilla Live shell

To restore the image under the Clonezilla Live shell, you must log on as root, as in Listing 1; this gives you full access to Clonezilla.
Listing 1. Becoming root user

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

/dev/sda is the virtual disk we created as the restoration destination; it is unformatted. /dev/sdb is 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

tool to write the label onto the virtual disk. This procedure is shown in Listing 3.
Listing 3. Formatting the destination disk

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 /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

When /home/partimag and the destination partition are ready, you have to choose the best way to restore the image for your environment. Just as for backup, Clonezilla 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
Clonezilla advanced extra parameters: restore

For Windows system image restoration, the boot header has to be written to the destination disk. To achieve this, use

(use dd to create partition table) and

(client restores the prebuilt MBR from syslinux). The

(

is 0 or 1) option is good for ensuring 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

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 the command line to restore the image

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
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.


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.

811 total views, no views today

Physical to Virtual in VirtualBox – VirtualBox P2V

Standard

From: Physical to Virtual in VirtualBox – VirtualBox P2V.

VirtualBox P2V Physical to Virtual in VirtualBox

This article explains how you can do VirtualBox P2V convert physical machine to virtual machine in Sun VirtualBox. It’s not straight forward method since there no tools available for VirtualBox P2V Physical to Virtual conversion. But still it’s possible with free VMware tool.

Before start the procedures, let me tell you how it’s going to work.

VirtualBox P2V

We will use a free VMware converter tool to convert physical  to virtual machine which will create VMX and VMDK files according to physical computer and disks configuration.

Then import the created VMDK file to VirtualBox as hard disk, create a virtual machine and boot from VMDK file hard disk. That’s it. It will work fine.

Don’t waste your time to search a tool VirtualBox P2V convert Physical to Virtual in VirtualBox directl, its not available till today if I’m not wrong.  If you are a VirtualBox fan and you want to try P2V and run in Sun VirtualBox, then this is the only VirtualBox P2V option available.

Physical to Virtual in VirtualBox – VirtualBox P2V – Step by step methods

1)      Download VMware Converter here

2)      Convert your physical computer to virtual using free VMware vCentre converter as mentioned here. Make sure you select correct physical partitions, processors and memory size for new virtual  machine. Don’t split the virtual disks during the conversion.

3)      Once successfully created, locate the VMX and VMDK files. Don’t bother about VMX files.

4)      Now add the newly created vmdk file to VirtualBox media manager as shown below.

VirtualBox P2V

5)      Read more about adding and accessing vmdk disk files in sun VirtualBox here. This article explains how you can access vmdk disk file as partition in side virtual machine in sun VirtualBox. We don’t require that much now. Just to know how to add vmdk file to sun VirtualBox media manger.

6)      After successfully added vmdk disk file, create a new virtual machine in VirtualBox. Select the correct guest OS, processor type and memory size. In virtual hard disk box  select ‘Use existing Hard Disk’ and browse the disk you added by vmdk file in VirtualBox media manager. So your new virtual machine will boot from vmdk disk which we converted from physical to virtual.

Physical to Virtual VirtualBox P2V

7)      That’s it. Boot the virtual machine now. It will be booting and working fine. Sometimes it may install additional required drivers on sun virtual machine. Let it complete and install the Sun guest additions  to get better display performance with additional features.

8)      You must see your physical computer on Sun VirtualBox as virtual machine now. This is the easiest method to convert Physical to Virtual in VirtualBox – VirtualBox P2V with free tool.

9)      If you are still interested in running pure sun VirtualBox machine with VDI files, you can convert your newly created VMDK files to VDI format with free tool as mentioned here. After created vdi file add it to media manager and boot virtual machine from vdi files.

If you face any problem let me know, we can solve it together. if I’m wrong about VirtualBox P2V tools tell me where I can download  it and do P2V in Sun VirtualBox in one shot.

Physical to Virtual VirtualBox P2V

980 total views, 1 views today