PartedMagicでHFSPlus UUIDを変更する

PartedMagicでHFSPlus UUIDを変更する

最近、ハードドライブ(不良ブロックFTW)を複製する必要がありました。当時私はClonezillaを使っていました。

しかし、ClonezillaはHFS +パーティションのコピーを拒否したため、手動でコピーしました。問題は、UUIDが同期されていないことです。

HFS+の特定のUUIDを設定するコマンドは何ですか?

ベストアンサー1

まず、500M イメージファイルを作成します。

$ cd /tmp
$ fallocate -l $((1024*1024*500)) ./disk

これでGPTを提供します。

$ gdisk ./disk

GPT fdisk (gdisk) version 0.8.10

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

Creating new GPT entries.

o新しいGPTを作成するために使用されます。

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

n新しいパーティションを作成するために使用されます。次にEnterキーを押してすべてのデフォルト値を選択します。

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

w変更をディスクに書き込みます。

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 ./disk.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

これでパーティションデバイスとして設定し、ファイルシステムを使用して最初のパーティションをフォーマットします。

$ sync; lp=$(sudo losetup --show -fP ./disk)
$ sudo mkfs.vfat -n SOMEDISK "${lp}p1"

結果:

$ lsblk -o NAME,FSTYPE,LABEL,PARTUUID "$lp"

NAME      FSTYPE LABEL    PARTUUID       
loop0                                
└─loop0p1 vfat   SOMEDISK f509e1d4-32bc-4a7d-9d47-b8ed0f280b36  

今、それを変更します。まず、ブロック開発を破壊します。

$ sudo losetup -d "$lp"

これでGPTを編集します。

$ gdisk ./disk

GPT fdisk (gdisk) version 0.8.10
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present
Found valid GPT with protective MBR; using GPT.

i単一パーティションの拡張情報を提供します。複数のパーティションがある場合は、そのパーティション番号を入力するように求められます。後続のコマンドも同様ですc

Command (? for help): i
Using 1
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: F509E1D4-32BC-4A7D-9D47-B8ED0F280B36
First sector: 2048 (at 1024.0 KiB)
Last sector: 1023966 (at 500.0 MiB)
Partition size: 1021919 sectors (499.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'

xxパーツメニューです。

Command (? for help): x

cPARTUUIDを変更するために使用されます。

Expert command (? for help): c
Using 1
Enter the partition's new unique GUID ('R' to randomize): F509E1D4-32BC-4A7D-9D47-B00B135D15C5                  
New GUID is F509E1D4-32BC-4A7D-9D47-B00B135D15C5

wディスクへの変更の書き込み(またはこの場合は私の画像ファイルとして)

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 ./disk.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

$ sync; lp=$(sudo losetup --show -fP ./disk)

結果:

$ lsblk -o NAME,FSTYPE,LABEL,PARTUUID "$lp"

NAME      FSTYPE LABEL    PARTUUID
loop0                     
└─loop0p1 vfat   SOMEDISK f509e1d4-32bc-4a7d-9d47-b00b135d15c5

おすすめ記事