vorfee's Tech Blog

Just another tech blog

コマンドプロンプトを使ってWindows 10のパーティションをカスタマイズしてクリーンインストールする

概要

準備

特に解説はしないが、作業を始める前に以下の2点を準備した。

  1. Windows 10のインストールUSBを作成する。
  2. PCに接続されている不要なHDDを取り外す。

目標

パーティション構成を以下の図のようにする。

f:id:vorfee:20160807052224p:plain

ちなみにWindows 10を普通にインストールすると、勝手に以下の図のようになる。

f:id:vorfee:20160807052433p:plain

1. パーティションを作成する

インストールUSBからインストール環境を起動し、修復用ツールからコマンドプロンプトを開く。diskpart コマンドでパーティションの作成をする。

X:\Sources> diskpart

diskpartのプロンプトが起動したら、list disk で接続されているディスク一覧を確認する。

DISKPART> list disk

  DISK ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          931 GB      0 B        *
  Disk 1    Online         7520 MB      0 B

今回はDisk 0がWindows 10をインストールするHDDである。よって select disk 0 でDisk 0を選択する。正しく選択されているかどうかは list disk でDiskの左側に*があるかどうかで確認できる。

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list disk

  DISK ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
* Disk 0    Online          931 GB      0 B        *
  Disk 1    Online         7520 MB      0 B

clean で一切のパーティション情報を破棄し、まっさらなMBRディスクにする。この時点でHDD内の全てのデータを失うことになる。パーティション情報が消えたかどうかは list partition で確認できる。

DISKPART> clean

Diskpart succeeded in cleaning the disk.

DISKPART> list partition

There are no partitions on this disk to show.

UEFIマザーボードを使用しているので、convert gpt でディスクをGPTに変更する。

DISKPART> convert gpt

Diskpart successfully converted the selected disk to GPT format.

ここから create コマンドを使ってパーティションの新規作成を行う。まずは512MBのEFI System Partitionを追加する。

フォーマットは自動で行われないので、手動でFAT32にフォーマットする必要がある。またEFI System Partitionはインストール時にSのドライブレターをつける必要がある。

DISKPART> create partition efi size=512

Diskpart succeeded in creating the specified partition.

DISKPART> format quick fs=fat32 label=EFI

  100 percent completed

Diskpart successfully formatted the volume.

DISKPART> assign letter=S

Diskpart successfully assigned the drive letter or mount point.

次にMSRを追加する。MSRはフォーマットまで自動で行われるため、コマンドは一行で良い。サイズは128MB。

DISKPART> create partition msr size=128

Diskpart succeeded in creating the specified partition.

次に回復用ツールを格納するパーティションを作成する。サイズは300MB。形式はNTFS。

回復用のパーティションには de94bba4-06d1-4d40-a16a-bfd50179d6ac というGUIDをセットしなければならない。また回復用パーティションはインストール時にRのドライブレターをセットしておく必要がある。

DISKPART> create partition primary size=300

Diskpart succeeded in creating the specified partition.

DISKPART> format quick fs=ntfs label=Recovery

  100 percent completed

Diskpart successfully formatted the volume.

DISKPART> assign letter=R

Diskpart successfully assigned the drive letter or mount point.

DISKPART> setid id=de94bba4-06d1-4d40-a16a-bfd50179d6ac

Diskpart successfully set the partition ID.

最後にWindowsのシステムをインストールするパーティションを作成する。最終的にこのパーティションWindows上でCドライブとして見えることになる。

DISKPART> create partition primary

Diskpart succeeded in creating the specified partition.

DISKPART> format quick fs=ntfs label=Windows

  100 percent completed

Diskpart successfully formatted the volume.

DISKPART> assign letter=W

Diskpart successfully assigned the drive letter or mount point.

最終的なパーティションは以下のようになった。

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             512 MB  1024 KB
  Partition 2    Reserved           128 MB   513 MB
  Partition 3    Recovery           300 MB   641 MB
* Partition 4    Primary            930 GB   941 MB

※ もしもここでPartition 3のTypeがRecoveryではなくPrimaryになっていたら、きっとGUIDを間違えている。

確認をしたらdiskpartを終了する。

DISKPART> exit

Leaving Diskpart...

X:\Sources>

これで正しくパーティショニングできたので、続いてWindowsのインストールを開始する。

2. Windows 10をインストール

セットアッププログラムを起動する。

X:\Sources> setup.exe

ここからはコマンドではなくGUIでの操作になる。CUIと違って見ればわかる為、省略する。

インストールが完了したら勝手に再起動し、HDDからWindows 10を起動すればすべての手順が完了する。

参照

Microsoft Reserved Partition - Wikipedia

UEFI/GPT-based hard drive partitions

Windows and GPT FAQ - Windows 10 hardware dev

UEFI ベースの推奨ディスク パーティション構成

パーティション - Wikipedia

GUIDパーティションテーブル - Wikipedia