如何在卸载的磁盘上重新编号 GPT 分区?

Bil*_*llV 9 partition gpt gdisk

我尝试/dev/sdb通过终端对分区进行排序(重新编号),使用gdisk来自操作系统(在 上运行/dev/sda)并且没有sdb安装任何分区,但我得到的唯一选项是[-l]列出我尝试使用的选项的选项。

root@arch-bill /home/bill # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
|-sda1   8:1    0  15.6G  0 part /
|-sda2   8:2    0 915.9G  0 part /home
`-sda3   8:3    0     2M  0 part 
sdb      8:16   0   1.8T  0 disk 
|-sdb1   8:17   0     2M  0 part 
|-sdb2   8:18   0     4G  0 part 
|-sdb3   8:19   0    16G  0 part 
|-sdb4   8:20   0    60G  0 part 
`-sdb6   8:22   0   1.8T  0 part 
sr0     11:0    1  1024M  0 rom  
root@arch-bill /home/bill # blkid
/dev/sdb1: PARTUUID="c1073e4b-fc00-4f02-8b81-6f17b8a188c4" 
/dev/sdb2: LABEL="var" UUID="62921c0a-5d34-464d-8a7a-2ff46ad8f12b" TYPE="ext4" PARTUUID="c350316a-0bd8-4e82-8597-123553977f99" 
/dev/sdb3: LABEL="rootbkp" UUID="c245c20e-d503-4b61-aaaf-060aae1b21d4" TYPE="ext4" PARTUUID="b1f391db-de37-479c-8b44-ff27f3bd6aa5" 
/dev/sdb4: LABEL="snapster" UUID="8fef4e0a-efd4-455b-b484-83bd4500161f" TYPE="ext4" PARTUUID="02801cd9-3fe5-4814-9b92-c4c83b86173d" 
/dev/sdb6: LABEL="homebkp" UUID="51d73ac7-fd96-4ac1-b4f3-4abf6bc4936b" TYPE="ext4" PARTUUID="481ae7d0-228f-4979-8949-befbd498534b" 
/dev/sda1: UUID="91865df2-0841-42f5-80f3-a5133976e70f" TYPE="ext4" PARTUUID="48dc34cb-e791-4838-b9f2-2fe2b2cced33" 
/dev/sda2: UUID="e5743a89-13ed-4c96-b39d-78cb6478fb72" TYPE="ext4" PARTUUID="4156cbf2-2a2d-47ae-87cf-99c14cf8f2c2" 
/dev/sda3: PARTUUID="8669392a-663e-4e15-bc63-a6a5e95c97ad" 

root@arch-bill /home/bill # gdisk -s /dev/sdb
GPT fdisk (gdisk) version 0.8.10

Usage: gdisk [-l] device_file
1 
root@arch-bill /home/bill # gdisk -l /dev/sdb                                                                                                                                                                                          :(
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.
Disk /dev/sdb: 3907029168 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 0645408C-0374-4357-8663-D2A3512E07BD
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4204653 sectors (2.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            6143   2.0 MiB     EF02  
   2            8192         8396799   4.0 GiB     0700  
   3         8398848        41953279   16.0 GiB    0700  
   4        41955328       167786495   60.0 GiB    0700  
   6       167788544      3902834687   1.7 TiB     0700  
1 root@arch-bill /home/bill #
Run Code Online (Sandbox Code Playgroud)

jas*_*yan 10

gdisk只有一个命令行选项 ( -l),列出分区表然后退出。所有其他操作都是从内部以交互方式进行的gdisk。有关更多上下文,请参阅Rod Smith 的演练

但是,本质上,您只想使用该命令# gdisk /dev/sdb,然后在提示符下使用该s命令对分区条目进行排序。来自man gdisk


对分区条目进行排序。GPT 分区编号不需要与磁盘上的分区顺序匹配。如果您希望它们匹配,您可以使用此选项。请注意,某些分区实用程序会在进行更改时对分区进行排序。此类更改将反映在您的设备文件名中,因此如果您使用此选项,您可能需要编辑 /etc/fstab。

在开始之前,您还应该阅读 Rod 关于修复 GPT 磁盘的页面,以防万一在操作过程中出现问题...