Ubuntuを使ってWindows11のHDD(500GB)からSSD(256GB)のクローンを作成する

500GBのHDDから256GBのSSDに換装するのが目的。

BitLockerが有効な場合な無効化する
HDD全体のイメージバックアップを取る
HDDの使用領域を250GB程度に収める

gpartedをインストールして起動し、必要なパーティションの終了セクタが500,000,000(256GB÷512)程度以下なるように調整して、それ以降のセクタを削除する。

# apt install gparted

事前にlsblkなどでデバイスパスを把握し、ddコマンドでコピーする。
※countの値は256GB÷1024k

# dd if=/dev/[コピー元] of=/dev/[コピー先] bs=1024k count=256k status=progress

コピーが終了したらgdiskでパーティションテーブルを修正する。

# gdisk /dev/[コピー先]
GPT fdisk (gdisk) version 1.0.8

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!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

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

Command (? for help): x

Expert command (? for help): v

Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.

Problem: Disk is too small to hold all the data!
(Disk size is 488397168 sectors, needs to be 1953525168 sectors.)
The 'e' option on the experts' menu may fix this problem.

Problem: GPT claims the disk is larger than it is! (Claimed last usable
sector is 1953525134, but backup header is at
1953525167 and disk size is 488397168 sectors.
The 'e' option on the experts' menu will probably fix this problem

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.

Identified 5 problems!

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

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/[コピー先].
The operation has completed successfully.

Windowsのパーティションが見えるようになったら、最後にgpartedで右端に余っている空き領域を利用できるよう設定する。