重新安装预装的 Windows 8

重新安装预装的 Windows 8

我给自己买了一台新的小型笔记本电脑 - Asus X201E。它预装了 UEFI 模式下的 Windows 8,但我没有 DVD - 没有任何带驱动程序的 DVD 或 Windows 8。

由于我不是 Windows 的忠实粉丝,所以我想在 Windows 8 附近安装 Ubuntu - 但这是一个很长的故事,值得再讨论一次。我的问题是,在 Windows 8 附近安装 Ubuntu 后,我如何重新安装 Windows 8?假设我想稍后重新安装所有内容(Win8 和 Ubuntu)- 我该怎么做?我可以从 Microsoft 下载 Win8 吗?这是否合法(我确实关心它是否合法)。总结:

  1. 现在我只有以 UEFI 模式预装的 Windows 8(没有 DVD,我的笔记本电脑没有 CD-ROM 或 DVD 驱动器)
  2. 我禁用了安全启动和快速启动
  3. 我想明天在 Windows 8 附近安装 Ubuntu
  4. 如何在一段时间后(比如说从今天起 5-6 个月)重新安装 Windows8 和 Ubuntu?谢谢 :)

答案1

在撰写本文时,win8 内置恢复选项或 asus backtracker 均无法在安装新磁盘时将系统重置为出厂状态。它们创建了 USB 恢复备份磁盘,但无法从中恢复。

本指南的目的是展示如何创建可以还原到新磁盘并启动到出厂状态的 win8 出厂备份。 所有这些操作完全从 linux 进行。

在此示例中,原始磁盘有 6 个分区,如下所示:

  • 电喷
  • 恢复
  • 磁共振
  • 操作系统
  • 数据
  • 恢复

需要:

  • Linux 从某个设备启动
  • 备份磁盘(我这里是12G容量)
  • 预装 win8 的原装硬盘
  • 新硬盘的容量小于或大于原始磁盘,但仍足以容纳所有需要的东西

认为:

  • 原始/新磁盘是 /dev/sda
  • 备份磁盘是 /tmp/backup
  • 一些挂载点,例如 /tmp/mnt

简要流程如下:

  • 备份硬盘的开头部分
  • 备份恢复分区的内容
  • 恢复硬盘的开头
  • 重新创建 OS/DATA/恢复分区以适合新磁盘
  • 更新 win8 以使用新的磁盘形状
  • 重启恢复出厂安装

备份

1)从原始磁盘获取分区信息(仅最后 3 个将重新创建的分区):

[root]# gdisk /dev/sda 
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 1465149168 sectors, 698.6 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 11111111-1111-1111-1111-111111111111
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1465149134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3757 sectors (1.8 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   EF00  EFI system partition
   2          616448         1845247   600.0 MiB   2700  Basic data partition
   3         1845248         2107391   128.0 MiB   0C01  Microsoft reserved part
   4         2107392       588165119   279.5 GiB   0700  Basic data partition
   5       588165120      1423204351   398.2 GiB   0700  Basic data partition
   6      1423204352      1465147391   20.0 GiB    2700  Basic data partition

Command (? for help): i
Partition number (1-6): 4
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: 44444444-4444-4444-4444-444444444444
First sector: 2107392 (at 1.0 GiB)
Last sector: 588165119 (at 280.5 GiB)
Partition size: 586057728 sectors (279.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'Basic data partition'

Command (? for help): i
Partition number (1-6): 5
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: 55555555-5555-5555-5555-555555555555
First sector: 588165120 (at 280.5 GiB)
Last sector: 1423204351 (at 678.6 GiB)
Partition size: 835039232 sectors (398.2 GiB)
Attribute flags: 0000000000000000
Partition name: 'Basic data partition'

Command (? for help): i
Partition number (1-6): 6
Partition GUID code: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC (Windows RE)
Partition unique GUID: 66666666-6666-6666-6666-666666666666
First sector: 1423204352 (at 678.6 GiB)
Last sector: 1465147391 (at 698.6 GiB)
Partition size: 41943040 sectors (20.0 GiB)
Attribute flags: 8000000000000001
Partition name: 'Basic data partition'

Command (? for help): q

2)前3个分区(以及硬盘的第一个扇区)必须完整,它们的原始副本也必须完整:

a) 注意要复制的大小 - 直到 OS 分区 (#4) 为止的扇区数,因此只需将 OS 分区的“起始 (扇区)”设为2107392,其中扇区大小通常为=512。

b) 复制到备份设备,并压缩:

dd if=/dev/sda conv=sync,noerror bs=512 count=2107392 | gzip -c > /tmp/backup/win8-factory-head.gz

3) 忽略/丢弃操作系统和数据分区 - 它们将被创建为空

4)备份最后一个“恢复”分区,其中包含工厂安装.wim:

[root]# mount /dev/sda6 /tmp/mnt

[root]# df -h /tmp/mnt
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        20G   12G  8.3G  59% /tmp/mnt

请注意,原始分区为 20G,但使用的空间远低于该值,因此创建的新分区可能更小,以获得这几 GB。

执行内容文件/目录备份,而不是原始副本:

[root]# cd /tmp/mnt

[root]# tar -pczf /tmp/backup/win8-factory-restore.tgz .

[root]# cd /

[root]# umount /tmp/mnt

5)保留本指南和以下两个文件作为完整备份:

  • win8-工厂-head.gz
  • win8-出厂恢复.tgz

恢复

1) 用新磁盘替换原始磁盘。切记不要将原始磁盘与新准备的磁盘一起插入,因为它们将使用相同的 UID。

2)恢复硬盘开始:

gunzip -c win8-factory-head.gz | dd of=/dev/sda conv=sync,noerror bs=512

3) 写入新磁盘的 GPT 必须修复(除非该磁盘与原始磁盘相同,则省略步骤 b、c、e、f、g)。

[root]# gdisk /dev/sda

现在从 gdisk 命令行继续。

a) 如果新磁盘比原来的小,则会出现一些警告,例如:

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

如果出现以下情况,请选择选项“1”。

Found invalid MBR and corrupt GPT. What do you want to do? (Using the
GPT MAY permit recovery of GPT data.)
 1 - Use current GPT
 2 - Create blank GPT

b) 如果之前没有这样做,在进行备份时,打印最后 3 个分区的信息:

Command (? for help): i
Partition number (1-6): 4

Command (? for help): i
Partition number (1-6): 5

Command (? for help): i
Partition number (1-6): 6

c) 删除最后 3 个分区:

Command (? for help): d
Partition number (1-6): 6

Command (? for help): d
Partition number (1-5): 5

Command (? for help): d
Partition number (1-4): 4

Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 11111111-1111-1111-1111-111111111111
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1465149134
Partitions will be aligned on 2048-sector boundaries
Total free space is 1463043757 sectors (697.6 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   EF00  EFI system partition
   2          616448         1845247   600.0 MiB   2700  Basic data partition
   3         1845248         2107391   128.0 MiB   0C01  Microsoft reserved part

d) 注意“总可用空间为1463043757根据“磁盘 /dev/sda:976773168扇区,465.8 GiB”。修复此问题,以便新创建分区的建议大小有效:

Command (? for help): x

Expert command (? for help): e
Relocating backup data structures to the end of the disk

Expert command (? for help): m

Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 11111111-1111-1111-1111-111111111111
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 974667757 sectors (464.8 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   EF00  EFI system partition
   2          616448         1845247   600.0 MiB   2700  Basic data partition
   3         1845248         2107391   128.0 MiB   0C01  Microsoft reserved part

e) 重新创建已删除的分区(每个分区给出合理的大小,以及与相关原始分区相同的有效“十六进制代码或 GUID”):

Command (? for help): n
Partition number (4-128, default 4): 
First sector (34-976773134, default = 2107392) or {+-}size{KMGTP}: 
Last sector (2107392-976773134, default = 976773134) or {+-}size{KMGTP}: +200G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Command (? for help): n
Partition number (5-128, default 5): 5
First sector (34-976773134, default = 421537792) or {+-}size{KMGTP}: 
Last sector (421537792-976773134, default = 976773134) or {+-}size{KMGTP}: +250G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Command (? for help): n
Partition number (6-128, default 6): 
First sector (34-976773134, default = 945825792) or {+-}size{KMGTP}: 
Last sector (945825792-976773134, default = 976773134) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 2700
Changed type of partition to 'Windows RE'

Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 11111111-1111-1111-1111-111111111111
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   EF00  EFI system partition
   2          616448         1845247   600.0 MiB   2700  Basic data partition
   3         1845248         2107391   128.0 MiB   0C01  Microsoft reserved part
   4         2107392       421537791   200.0 GiB   0700  Microsoft basic data
   5       421537792       945825791   250.0 GiB   0700  Microsoft basic data
   6       945825792       976773134   14.8 GiB    2700  Windows RE

f) 由于新创建的分区具有默认参数,因此请更新它们,以便它们完全模仿原始分区的值。

修复名称(可能没有必要):

Command (? for help): c
Partition number (1-6): 4
Enter name: Basic data partition

Command (? for help): c
Partition number (1-6): 5
Enter name: Basic data partition

Command (? for help): c
Partition number (1-6): 6
Enter name: Basic data partition

修复唯一 GUID:

Command (? for help): x

Expert command (? for help): c
Partition number (1-6): 4
Enter the partition's new unique GUID ('R' to randomize): 44444444-4444-4444-4444-444444444444
New GUID is 44444444-4444-4444-4444-444444444444

Expert command (? for help): c
Partition number (1-6): 4
Enter the partition's new unique GUID ('R' to randomize): 55555555-5555-5555-5555-555555555555
New GUID is 55555555-5555-5555-5555-555555555555

Expert command (? for help): c
Partition number (1-6): 4
Enter the partition's new unique GUID ('R' to randomize): 66666666-6666-6666-6666-666666666666
New GUID is 66666666-6666-6666-6666-666666666666

修复属性(实际上只需要“恢复”分区):

Expert command (? for help): a
Partition number (1-6): 6
Known attributes are:
0: system partition
1: hide from EFI
2: legacy BIOS bootable
60: read-only
62: hidden
63: do not automount

Attribute value is 0000000000000000. Set fields are:
  No fields set

Toggle which attribute field (0-63, 64 or <Enter> to exit): 0
Have enabled the 'system partition' attribute.
Attribute value is 0000000000000001. Set fields are:
0 (system partition)

Toggle which attribute field (0-63, 64 or <Enter> to exit): 63
Have enabled the 'do not automount' attribute.
Attribute value is 8000000000000001. Set fields are:
0 (system partition)
63 (do not automount)

Toggle which attribute field (0-63, 64 or <Enter> to exit): 

g) 从 NEXT 命令中注意“开始(扇区)=945825792' 表示最后的 #6 分区。

Expert command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 11111111-1111-1111-1111-111111111111
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   EF00  EFI system partition
   2          616448         1845247   600.0 MiB   2700  Basic data partition
   3         1845248         2107391   128.0 MiB   0C01  Microsoft reserved part
   4         2107392       421537791   200.0 GiB   0700  Basic data partition
   5       421537792       945825791   250.0 GiB   0700  Basic data partition
   6       945825792       976773134   14.8 GiB    2700  Basic data partition

h) 将更改存储在磁盘上

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

4)让系统重新加载新磁盘:

[root]# partprobe /dev/sda

5)格式化新创建的分区

[root]# mkfs.ntfs -f -L OS /dev/sda4
[root]# mkfs.ntfs -f -L DATA /dev/sda5
[root]# mkfs.ntfs -f -L Restore /dev/sda6

6)恢复‘恢复’分区内容。

[root]# mount /dev/sda6 /tmp/mnt
[root]# cd /tmp/mnt
[root]# tar -pxzf /tmp/backup/win8-factory-restore.tgz .
[root]# cd /
[root]# umount /tmp/mnt

7)更新恢复数据,以便系统在重启时恢复到出厂设置(如果使用原始磁盘而不重新分区,则省略此步骤)

[root]# mount /dev/sda2 /tmp/mnt
[root]# vi /tmp/mnt/Recovery/WindowsRE/ReAgent.xml

a) 根据扇区偏移量(来自上面的步骤 3g)计算最后一个分区的字节偏移量,945825792*512=484262805504

b) 使用新的偏移值更新 ReAgent.xml 文件中的以下行:

<OsInstallLocation path="\RecoveryImage" id="0" offset="484262805504" guid="{11111111-1111-1111-1111-111111111111}" index="2"/>

c) 移除安装

[root]# umount /tmp/mnt

8) 重启,使用 F9 进入恢复环境,选择“重置 PC”选项。这将恢复与第一次启动时相同的操作系统。

答案2

现代计算机中包含的大多数 Windows 恢复系统都会将计算机恢复到出厂状态。这意味着如果您使用它们,您将丢失 Linux 安装。因此,您实际上有两个选择:

  • 备份 Windows 至接近原始状态,并在必要时使用它进行恢复。您应该使用能够恢复到较小分区的 Windows 工具执行此操作,或者但是,您缩小了 Windows 分区。(请注意,有些工具不是允许恢复到较小的分区,因此请务必检查这个细节!)
  • 获取 Windows 8 零售 DVD 并将其与您当前安装的序列号结合使用。这个问题和答案涵盖获取合法 Windows 8 DVD。我不确定序列号,但我知道可以通过某种方式找到它。

就我个人而言,我希望对这两种选择都做好准备。

相关内容