我可以使用sgdisk -b /dev/sdx将磁盘的GPT分区映射保存到文件中。我想为GPT生成这样一个文件,它有一个一定大小的分区。我看到这样做的唯一方法是在像GParted这样的工具中实际格式化磁盘,然后使用gdisk保存GPT。
有没有一种方法,最好是在GParted中,用我想要的分区设置一个GPT表,然后将它保存到一个文件中,而不是将它写到磁盘上?
其他不受欢迎的选择:
sgdisk手动编辑转储。很难把事情做好。sgdisk导出。我想要的440 disk磁盘要花很长时间。编辑:实际上,如果我使用动态分配的虚拟磁盘,这是快速的,但它是一个笨重的解决方案。发布于 2017-11-27 03:56:25
我理解您的问题与分区表和分区有关,而不是数据。如果这是正确的,那么您的答案已经在parted和这里的手册页中了。
本质上,创建创建gpt方案所需的parted命令的脚本,然后
parted --script /dev/sdx [script commands]这可以放到shell脚本中,并根据需要执行,也许可以将设备作为参数传递给脚本。
编辑后注释:根据man sgdisk页面,要获得“幻影”磁盘的sgdisk输出,请使用'-P‘选项,它在内存中执行任务(S),但不对磁盘提交更改。
我刚用usb试了一下,看起来很管用
sudo sgdisk -p /dev/sdb
Disk /dev/sdb: 31653888 sectors, 15.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2016C547-548B-482E-8810-A5E7A1466CED
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31653854
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 31651839 15.1 GiB 0700 IDEA #old name
sudo sgdisk -P -c 1:random -p /dev/sdb #change the name
Setting name!
partNum is 0
REALLY setting name!
Disk /dev/sdb: 31653888 sectors, 15.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2016C547-548B-482E-8810-A5E7A1466CED
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31653854
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 31651839 15.1 GiB 0700 random #name changed重执行
sudo sgdisk -p /dev/sdb
Number Start (sector) End (sector) Size Code Name
1 2048 31651839 15.1 GiB 0700 IDEA #change not written此更改也反映在
sudo sgdisk -P -c 1:random --backup=phantomDisk /dev/sdbhttps://unix.stackexchange.com/questions/407197
复制相似问题