通過Linux系統將Windows系統遷移到到新的磁碟上

來源:互聯網
上載者:User

   1. 概述

  這篇文章將告訴你如何再 linux 系統下,將 安裝好的windows版本 複製到新的磁碟上(新的磁碟大於等於window鏡像大小)

  2. 使用到的工具

  livecd 工具,可以是CD 也可以是USB啟動的 ,需要有的工具 dd, fdisk, and ntfsresize.

  此例子中,使用如下假設:

  /dev/sdc (新硬碟)

  /dev/sdb (老硬碟,安裝好的window版本資料在 /dev/sdb1 分區中)

  = 格式化新盤(/dev/sdc) =

  使用root 使用者,進行如下分區操作

  代碼如下:

  [root@centos6 ~]# fdisk /dev/sdc

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

  switch off the 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

  First 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, 63 sectors/track, 2088 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

  Disk identifier: 0xa1c3a1c3

  Device Boot Start End Blocks Id System

  /dev/sdc1 1 2088 16771828+ 83 Linux

  在完成之前,我們必須設定啟動標誌和分區系統ID,分區系統ID必須是WINDOWS的,ID值為 7.

  代碼如下:

  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, 63 sectors/track, 2088 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

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

  I/O size (minimum/optimal): 512 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.

  = 複製MBR =

  為了讓新盤能夠引導, 我們必須從Master Boot Record (MBR) 複製引導代碼到新的磁碟上

  MBR 在磁碟的第一個扇區,由3部分組成:

  代碼如下:

  Boot Code (446 bytes)

  Partition Table (64 bytes)

  Boot Code Signature = 55aa (2 bytes)

  我們只需要複製引導代碼,起始的 446 bytes. 使用dd工具來複製:

     代碼如下:

  # 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)

  = 複製分區 =

  下一步任務就是將檔案系統從一個盤複製到另一個盤上.在這裡我們使用 ntfsclone 工具來複製 NTFS 檔案系統

  代碼如下:

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

  如果在來源硬碟上有壞的扇區,則需要添加 --rescue 選項

  代碼如下:

  # ntfsclone --rescue --overwrite /dev/sdc1 /dev/sdb1

  注意: 來源硬碟 是 最後一個參數(/dev/sdb1)

  3. 改變分區大小

  在新盤比來源硬碟大的情況下,我們需要改變分區大小來使用所有空間,這裡我們使用 ntfsresize 命令

  代碼如下:

  [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 you want to proceed (y/[n])? y

  Schedule chkdsk for NTFS consistency check at 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. 使用新盤重新啟動系統

  重新啟動後,windows 會自動檢查檔案系統如下(因為分區大小有所變化),檢查完成後自動重起就能進入windows系統了

  5. 總結

  當然這種方式的拷貝是在同一台伺服器上操作的(驅動無變化),如果將一個乾淨的windows裸系統通過這種方式安裝到不同型號的伺服器上時, 就會出現驅動問題,如何解決,請看下回分解!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.