1. Field of the Invention
The present invention generally relates to drive cloning, and more particularly to a method and system of cloning the source drive to the target drive with the partitions being adaptively resized.
2. Description of Related Art
Drive cloning (or disk cloning) is a process of copying the contents of a hard disk drive (HDD) of a computer to another disk drive, which may be another HDD or a solid state drive (SSD). The drive cloning has many usages. For example, a user may use the drive cloning to upgrade the HDD to a faster drive such as SSD. The drive cloning may be used instead to create a backup of the HDD in the computer, and the backup may later be used to recover the computer.
Conventional drive cloning software is usually not user-friendly, and generally needs a lot of user interaction which might cause confusion for the user. For example, in order to begin the cloning, the user should first open a boot menu, for example, by pressing a function key, and then select a boot device from the boot menu.
Furthermore, the conventional drive cloning software performs the drive cloning by duplicating not only the contents of the source drive, but also replicating the partition information such as the partition size of the source drive. As a destination drive may commonly have a size different from the source drive, the drive cloning therefore cannot be performed effectively. For example, space is wasted on the destination drive if the destination drive has a size substantially greater than the source drive; or the contents to be cloned cannot be entirely cloned to the destination drive if the destination drive has a size substantially smaller than the source drive.
Although the conventional drive cloning software may have provided some means for the user to manually set the size of each partition, such means, however, normally creates confusion rather than convenience for an average user being not acquainted with related acknowledge.
For the reason that conventional drive cloning software could not provide the user with convenience and facilitation, a need has arisen to propose an unsophisticated novel scheme for cloning a drive for the average user.
In view of the foregoing, it is an object of embodiments of the present invention to provide a method and system for cloning a source drive to a target drive with partitions being dynamically and automatically resized.
According to one embodiment, a cloning program launches in a host device, and an amount of partitions and a size of each said partition of the source drive are obtained. The size of each corresponding partition in the target drive is adaptively determined according to a size of the source drive and a size of the target drive. After rebooting the host device, contents of the source drive are copied to the target drive. In one embodiment, at least one of the partitions of the target drive has a size greater than the corresponding partition of the source drive when the size of the target drive is greater than the size of the source drive; and at least one of the partitions of the target drive has a size smaller than the corresponding partition of the source drive when the size of the target drive is smaller than the size of the source drive.
(HDD) in a computer 100, and the target drive 12 may be, but is not limited to, a solid state drive (SSD), a Universal Serial Bus (USB) drive or a USB flash drive. The cloning system 1 of the embodiment may, but not exclusively, be utilized to upgrade the source drive 10 to the target drive 12. In another embodiment, the cloning system 1 may be utilized, for example, to restore a computer to its original configuration or to create a comprehensive backup of an operating system (OS) and installed software of a computer.
Subsequently, in step 22, the amount of partitions and the size of each partition in the source drive 10 are obtained, for example, according to a Master Boot Record (MBR) 13. The MBR 13 is the first sector (or boot sector) of the first cylinder in the source drive 10. The MBR 13 contains, among other things, a partition table (or partition record) that records the start address and end address of each partition. Based on the partition information obtained from step 22, the size of each corresponding partition in the target drive 12 is adaptively determined (step 23). In the embodiment, the partitions of the target drive 12 are adaptively determined to match the size of the target drive 12 by taking into consideration both the size of the source drive 10 and the size of the target drive 12. For example, in the case that the target drive 12 has a size (e.g., 500 GB) greater than the size (e.g., 250 GB) of the source drive 10, one or more partitions of the target drive 12 should have a partition size greater than the corresponding partition of the source drive 10. Taking an opposite example, in the case that the target drive 12 has a size (e.g., 150 GB) smaller than the size (e.g., 250 GB) of the source drive 10, one or more partitions of the target drive 12 should have a partition size smaller than the corresponding partition of the source drive 10. In other words, the partition(s) are grown to match a larger target drive 12, and are shrunk to match a smaller target drive 12. The growing or shrinking ratio is commonly determined according to the size of the source drive 10, the size of the target drive 12 and the amount of partitions.
Afterwards, in step 24, a modified MBR for booting into the target drive 12 is provided according to the sizes of the partitions determined in step 23. Subsequently, in step 25, the computer 100 is rebooted into another environment such as Linux compliant with the target drive 12, and, in step 26, the contents of the source drive 10 are copied (or cloned) to the target drive.
According to embodiments discussed above, the cloning process (i.e., steps 21 through 27) dynamically resizes the source drive 10 to fit into the target drive 12. For a larger target drive 12, the cloning process will dynamically grow the partitions proportionately to use all the available space on the target drive 12. For a smaller target drive 12, the cloning process will dynamically shrink the partitions proportionately to fit onto the smaller target drive 12. In the embodiment, the cloning process (i.e., steps 21-27) automatically performs without the user's intervention. That is, the user simply presses the start button (
Although specific embodiments have been illustrated and described, it will be appreciated by those skilled in the art that various modifications may be made without departing from the scope of the present invention, which is intended to be limited solely by the appended claims.