參考 How can I clone/backup/restore Windows 10 from Linux?
分割區回復後,出現無法開機的處理
0xc0000225 Error Code on Windows 10 [Fixed]
在經過多次失敗後,最後終於成功。上面的解決辦法只適用於 MSDOS(MBR) 的磁碟分割表(partition table),使用 GPT 磁碟分割表,在執行 "bootrec /fixboot" 會出現 "存取被拒" 的錯誤訊息,解決辦法參考下面連結
windows10 Bootrec /Fixboot 存取被拒(Access Is Denied)
原始文章
zdelete -z c:
Get some live Linux USB to boot and backup MBR and partition table to a spare drive
dd if=/dev/sda of=/somewhere/mbr bs=512 count=63
dd if=/dev/sda1 bs=1M status=progress | lz4 > /somewhere/sda1.lz4
dd if=/dev/sda2 bs=1M status=progress | lz4 > /somewhere/sda2.lz4
備份 GPT 分割區
Linux: Copy GPT partition table with dd
備份分割區
dd if=/dev/sda of=GPT_TABLE bs=1 count=A
還原分割區
dd if=GPT_TABLE of=/dev/sdb bs=1 count=A
partprobe /dev/sdb
其中 A 的計算如下:
A=(128*B)+1024
B 為分割區的數目
B=parted -ms /dev/sda print |tail -1|cut -b1
例如有 4 個分割區, 則 count (A) 的值為 1536
還原
測試檔案的大小是否正確# lz4 -v sda1.lz4 > /dev/null
*** LZ4 command line interface 64-bits v1.9.2, by Yann Collet ***
Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead !
sda1.lz4 : decoded 104857600 bytes
Place the new disk into the computer, boot the live Linux again and restore the beginning of the disk
dd of=/dev/sda if=/somewhere/file.mbr
dd of=/dev/sda1 bs=1M status=progress < lz4cat /somewhere/sda1.lz4
dd of=/dev/sda2 bs=1M status=progress < lz4cat /somewhere/sda2.lz4
lz4 -dc sda1.lz4 | dd of=/dev/sda1 bs=1M
lz4 -dc sda2.lz4 | dd of=/dev/sda2 bs=1M status=progress
bootrec /fixmbr
ntfsclone but that didn't produce bootable Windows (it was complaining of some missing files in \Windows\System32). I am not sure why it didn't work. At the end the dd + lz4 solution created smaller image than ntfsclone by itself. Your mileage may vary based on how full the disk is modulo bugs in ntfsclone - dd seems much easier to get right :-)測試 Windows 7 的備份/還原
使用 Vmware Workstation 的 VM 測試,Linux 則是用 Ubuntu磁碟 60GB,分割區如下
sda1 : 100MB
sda2: 59.9GB,使用 16.3GB
# ls -lh
total 7.7G
-rw-r--r-- 1 root root 32K Apr 28 01:34 mbr
-rw-r--r-- 1 root root 14M Apr 28 01:34 sda1.lz4
-rw-r--r-- 1 root root 7.7G Apr 28 01:41 sda2.lz4
備份 sda2 的花費時間
real 5m18.318s
user 1m4.509s
sys 3m17.199s
還原測試
# time lz4 -d sda2.lz4 | dd of=/dev/sda2 bs=1M status=progress
Warning : using stdout as default output. Do not rely on this behavior: use explicit `-c` instead !
64157974528 bytes (64 GB, 60 GiB) copied, 228 s, 281 MB/s
14086+444198 records in
14086+444198 records out
64317554688 bytes (64 GB, 60 GiB) copied, 229.768 s, 280 MB/s
花費時間 real 3m49.786s
user 1m5.480s
sys 3m11.717s
還原之後,即可正常開機。
在 ASUS VivoBook 14 備份/還原 Windows 10
用 dd 指令還原 gpt 分割區失敗,只好用 cfdisk 手動建立,讓 start/end 的數字儘量一樣,不然失敗時,會不曉得是否為分割區不對所造成。其中 /dev/nvme0n1p3 的容量設到 476.0334G,勉強一致。
建立分割區後,使用 dd 指令還原各分割區的資料,其中476GB的分割區,要花費超過2個半小時,這比重新安裝的時間還久。但 dd 指令,就是要把每一個 byte 資料都寫回去才行啊,只好等囉。
資料還原後,必須重建 BCD (即 Boot Configuration Data),才能重新開機。這個有點順利,試了好幾次,差點放棄,還好最後成功開機了。
這台筆電 BIOS 中的 [SATA Mode] 有兩種,
[AHCI] 及 [Intel RST Premium With Intel Optane System Acceleration] (以下簡稱 RST)
原來裝 Win 10 時,是設成 RST。但必須改成 AHCI,Linux 的 LiveDVD 才能看到 SSD。
還原後,我先用 Windows10 -1803 版本的 ISO,SATA 在 RST 模式下,也是看不到 SSD。切換成 AHCI,可以看到,但重建 BCD 時,在 "bootrec /fixboot" 指令時,出現 "存取被拒",還原失敗,然後放棄。
中間有用安裝 ISO 從頭裝起,但裝著裝著就厭煩起來,實在 越來越不喜歡 Windows 的囉唆,而且資訊不明,根本不知它在做什麼。
後來在學校下載新的 Windows10 - 1909 版本的 ISO,又再試一次。這次在 RST 模式下,可以看到 SSD 了,果然新版的才有 driver。 但重建 BCD 在 "bootrec /fixboot" 指令仍然出錯。就用這指令當關鍵字,果然搜尋到一堆結果。挑了一篇來看,照著做,YA,成功,可以重開了。
----------------------
用安裝 ISO 開機後,選擇 [Troubleshoot]。
然後在 menu 中選 [Command Prompt],在命令視窗中
執行下述 command:
Diskpart ==> 進入程式,執行下述 command:
List disk
Sel disk 0 (選擇安裝 Win 10 的磁碟,在此選 0)
List vol (選擇開機磁區,通常為 FAT32,且沒有磁碟編號)
Sel vol 4
assign letter=V: (指定開機磁區為 V: 磁碟)
Exit
在命令視窗中,繼續執行
bcdboot C:\windows /s V: /f UEFI






















