Kaz*_*lfe 5 cloning uuid hfs+ parted-magic gdisk
我最近需要克隆我的硬盘驱动器(坏块 FTW)。我当时正在使用 Clonezilla。
但是,Clonezilla 拒绝复制 HFS+ 分区,所以我手动完成了。问题是 UUID 不同步。
为 HFS+ 设置特定 UUID 的命令是什么?
首先我将创建一个500M的图像文件:
\n\n$ cd /tmp\n$ fallocate -l $((1024*1024*500)) ./disk\n
Run Code Online (Sandbox Code Playgroud)\n\n现在我将给它一个 GPT:
\n\n$ gdisk ./disk\n\nGPT fdisk (gdisk) version 0.8.10\n\nPartition table scan:\n MBR: not present\n BSD: not present\n APM: not present\n GPT: not present\n\nCreating new GPT entries.\n
Run Code Online (Sandbox Code Playgroud)\n\no
用于创建新的 GPT。
Command (? for help): o\nThis option deletes all partitions and creates a new protective MBR.\nProceed? (Y/N): y\n
Run Code Online (Sandbox Code Playgroud)\n\nn
用于创建新分区。之后我只需按 Enter 键即可选择所有默认值。
Command (? for help): n\nPartition number (1-128, default 1): 1\nFirst sector (34-1023966, default = 2048) or {+-}size{KMGTP}: \nLast sector (2048-1023966, default = 1023966) or {+-}size{KMGTP}: \nCurrent type is \'Linux filesystem\'\nHex code or GUID (L to show codes, Enter = 8300): \nChanged type of partition to \'Linux filesystem\'\n
Run Code Online (Sandbox Code Playgroud)\n\nw
将更改写入磁盘。
Command (? for help): w\n\nFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING\nPARTITIONS!!\n\nDo you want to proceed? (Y/N): y\nOK; writing new GUID partition table (GPT) to ./disk.\nWarning: The kernel is still using the old partition table.\nThe new table will be used at the next reboot.\nThe operation has completed successfully.\n
Run Code Online (Sandbox Code Playgroud)\n\n现在我将其设置为分区块设备并使用文件系统格式化第一个分区:
\n\n$ sync; lp=$(sudo losetup --show -fP ./disk)\n$ sudo mkfs.vfat -n SOMEDISK "${lp}p1"\n
Run Code Online (Sandbox Code Playgroud)\n\n结果:
\n\n$ lsblk -o NAME,FSTYPE,LABEL,PARTUUID "$lp"\n\nNAME FSTYPE LABEL PARTUUID \nloop0 \n\xe2\x94\x94\xe2\x94\x80loop0p1 vfat SOMEDISK f509e1d4-32bc-4a7d-9d47-b8ed0f280b36 \n
Run Code Online (Sandbox Code Playgroud)\n\n现在,要改变这一点。\n首先,销毁块开发:
\n\n$ sudo losetup -d "$lp"\n
Run Code Online (Sandbox Code Playgroud)\n\n现在,编辑 GPT:
\n\n$ gdisk ./disk\n\nGPT fdisk (gdisk) version 0.8.10\nPartition table scan:\n MBR: protective\n BSD: not present\n APM: not present\n GPT: present\nFound valid GPT with protective MBR; using GPT.\n
Run Code Online (Sandbox Code Playgroud)\n\ni
提供有关单个分区的扩展信息。如果我有多个分区,接下来会提示我输入其分区号。后面的命令也是如此c
。
Command (? for help): i\nUsing 1\nPartition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)\nPartition unique GUID: F509E1D4-32BC-4A7D-9D47-B8ED0F280B36\nFirst sector: 2048 (at 1024.0 KiB)\nLast sector: 1023966 (at 500.0 MiB)\nPartition size: 1021919 sectors (499.0 MiB)\nAttribute flags: 0000000000000000\nPartition name: \'Linux filesystem\'\n
Run Code Online (Sandbox Code Playgroud)\n\nx
是x
perts 菜单。
Command (? for help): x\n
Run Code Online (Sandbox Code Playgroud)\n\nc
用于更改 PARTUUID。
Expert command (? for help): c\nUsing 1\nEnter the partition\'s new unique GUID (\'R\' to randomize): F509E1D4-32BC-4A7D-9D47-B00B135D15C5 \nNew GUID is F509E1D4-32BC-4A7D-9D47-B00B135D15C5\n
Run Code Online (Sandbox Code Playgroud)\n\nw
将更改写入磁盘(或者在本例中写入我的图像文件)。
Expert command (? for help): w\n\nFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING\nPARTITIONS!!\n\nDo you want to proceed? (Y/N): y\nOK; writing new GUID partition table (GPT) to ./disk.\nWarning: The kernel is still using the old partition table.\nThe new table will be used at the next reboot.\nThe operation has completed successfully.\n\n$ sync; lp=$(sudo losetup --show -fP ./disk)\n
Run Code Online (Sandbox Code Playgroud)\n\n结果:
\n\n$ lsblk -o NAME,FSTYPE,LABEL,PARTUUID "$lp"\n\nNAME FSTYPE LABEL PARTUUID\nloop0 \n\xe2\x94\x94\xe2\x94\x80loop0p1 vfat SOMEDISK f509e1d4-32bc-4a7d-9d47-b00b135d15c5\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
1125 次 |
最近记录: |