Migrate Windows systems to new disks through Linux systems

Source: Internet
Author: User
Tags hex code

1. Overview

This article will show you how to copy the installed version of Windows to a new disk (the new disk is greater than or equal to the window mirror size) under the Linux system.

2. Tools to use

The LiveCD tool, which can be a CD or USB boot, requires tools DD, Fdisk, and Ntfsresize.

In this example, use the following assumption:

/DEV/SDC (New Hard drive)

/DEV/SDB (old hard Drive, installed window version data in/DEV/SDB1 partition)

= Format new Disk (/DEV/SDC) =

Using the root user, do the following partition operations

The code is as follows:

[Root@centos6 ~]# FDISK/DEV/SDC

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to

Switch off "mode" (Command ' C ') and change display units to

Sectors (Command ' u ').

Command (M for help): N

Command Action

E Extended

P primary partition (1-4)

P

Partition number (1-4): 1

The cylinder (1-2088, default 1):

Using Default value 1

Last cylinder, +cylinders or +size{k,m,g} (1-2088, default 2088):

Using Default Value 2088

Command (M for help): P

disk/dev/sdc:17.2 GB, 17179869184 bytes

255 heads, Sectors/track, 2088 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0xa1c3a1c3

Device Boot Start End Blocks Id System

/DEV/SDC1 1 2088 16771828+ Linux

Before completing, we must set the boot flag and partition system ID, and the partition system ID must be windows, with an ID value of 7.

The code is as follows:

Command (M for help): A

Partition number (1-4): 1

Command (M for help): t

Selected partition 1

Hex code (type L to list codes): 7

Changed system type of partition 1 to 7 (HPFS/NTFS)

Command (M for help): P

disk/dev/sdc:17.2 GB, 17179869184 bytes

255 heads, Sectors/track, 2088 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0xa1c3a1c3

Device Boot Start End Blocks Id System

/DEV/SDC1 * 1 2088 16771828+ 7 hpfs/ntfs

Command (M for help): W

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Syncing disks.

= Copy MBR =

In order for the new disk to boot, we must copy the boot code from the master Boot Record (MBR) to the new disk

The MBR is in the first sector of the disk, consisting of 3 parts:

The code is as follows:

Boot Code (446 bytes)

Partition Table (bytes)

Boot Code Signature = 55AA (2 bytes)

We just need to copy the boot code, starting with the 446 bytes. Use the DD tool to copy:

The code is as follows:

# dd If=/dev/sdb OF=/DEV/SDC bs=446 count=1

1+0 Records in

1+0 Records out

446 bytes transferred in 0.026312 seconds (16950 bytes/sec)

= Copy partition =

The next task is to copy the file system from one disk to another disk. Here we use the Ntfsclone tool to copy the NTFS file system

The code is as follows:

[Root@centos6 ~]# Ntfsclone--OVERWRITE/DEV/SDC1/DEV/SDB1

< p> Ntfsclone v2013.1.13 (libntfs-3g)

NTFS Volume version:3.1

Cluster size:4096 bytes

Current volume size:10725732352 bytes (10726 MB)

Current device size:10725732864 bytes (10726 MB)

Scanning volume ...

100.00 percent completed

Accounting clusters ...

Space in use:7565 MB (70.5%)

Cloning NTFS ...

100.00 percent completed

Syncing ...

If there is a bad sector on the source disk, you need to add the--rescue option

The code is as follows:

# Ntfsclone--rescue--OVERWRITE/DEV/SDC1/DEV/SDB1

Note: The source disk is the last parameter (/DEV/SDB1)

3. Change the partition size

In the case where the new disk is larger than the source disk, we need to change the partition size to use all the space, where we use the ntfsresize command

The code is as follows:

[Root@centos6 ~]# NTFSRESIZE/DEV/SDC1

< p> ntfsresize v2013.1.13 (libntfs-3g)

Device Name:/DEV/SDC1

NTFS Volume version:3.1

Cluster size:4096 bytes

Current volume size:10725732864 bytes (10726 MB)

Current device size:17174352384 bytes (17175 MB)

New Volume size:17174348288 bytes (17175 MB)

Checking FileSystem Consistency ...

100.00 percent completed

Accounting clusters ...

Space in use:7565 MB (70.5%)

Collecting resizing constraints ...

Warning:every sanity check passed and only the dangerous operations left.

Make sure that important data has been backed up! Power outage or computer

Crash may result major data loss!

Are you sure your want to proceed (y/[n)? Y

Schedule chkdsk for NTFS consistency check in Windows boot time ...

Resetting $LogFile ... (This might take a while)

Updating $BadClust file ...

Updating $Bitmap file ...

Updating Boot record ...

Syncing device ...

Successfully resized NTFS on device '/DEV/SDC1 '.

4. Reboot the system with a new disk

After restarting, Windows automatically checks the file system as follows (because of the size of the partition), and automatically restarts when the check is complete to enter the Windows system.

5. Summary

Of course, the copy of this way is operated on the same server (drive unchanged), if a clean Windows naked system installed in this way to different models of the server, there will be a driver problem, how to solve, please see Let's!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.