Repair GPT Table: Difference between revisions

From WikiMLT
m (Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Linux Server)
m (Text replacement - "mlw-continue" to "code-continue")
 
Line 18: Line 18:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="yaml" class="mlw-continue">
<syntaxhighlight lang="yaml" class="code-continue">
GPT fdisk (gdisk) version 1.0.5
GPT fdisk (gdisk) version 1.0.5


Line 31: Line 31:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash" class="mlw-continue">
<syntaxhighlight lang="bash" class="code-continue">
Command (? for help): ?
Command (? for help): ?
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="shell-session" class="mlw-continue">
<syntaxhighlight lang="shell-session" class="code-continue">
b      back up GPT data to a file
b      back up GPT data to a file
c      change a partition's name
c      change a partition's name
Line 54: Line 54:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash" class="mlw-continue">
<syntaxhighlight lang="bash" class="code-continue">
Command (? for help): p
Command (? for help): p
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="terraform" class="mlw-continue">
<syntaxhighlight lang="terraform" class="code-continue">
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Model: CT250MX500SSD1
Model: CT250MX500SSD1
Line 74: Line 74:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash" class="mlw-continue">
<syntaxhighlight lang="bash" class="code-continue">
Command (? for help): v
Command (? for help): v
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="terraform" class="mlw-continue">
<syntaxhighlight lang="terraform" class="code-continue">
No problems found. 4397 free sectors (2.1 MiB) available in 2
No problems found. 4397 free sectors (2.1 MiB) available in 2
segments, the largest of which is 2383 (1.2 MiB) in size.
segments, the largest of which is 2383 (1.2 MiB) in size.
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash" class="mlw-continue">
<syntaxhighlight lang="bash" class="code-continue">
Command (? for help): w
Command (? for help): w
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="shell-session" class="mlw-continue">
<syntaxhighlight lang="shell-session" class="code-continue">
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
PARTITIONS!!
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash" class="mlw-continue">
<syntaxhighlight lang="bash" class="code-continue">
Do you want to proceed? (Y/N): y
Do you want to proceed? (Y/N): y
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="shell-session" class="mlw-continue">
<syntaxhighlight lang="shell-session" class="code-continue">
OK; writing new GUID partition table (GPT) to /dev/sda.
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
Warning: The kernel is still using the old partition table.

Latest revision as of 08:29, 26 September 2022

Gere is pre­sent­ed a list of the steps that I've ap­plied to re­pair the GPT ta­ble of one of my de­vices.

Cre­ate a Back­up of the Par­ti­tion Ta­ble

First things first – cre­ate a back­up copy of the par­ti­tion ta­ble.

sudo sfdisk -d /dev/sda > /mnt/backups/gpt_table_sda_cx250.txt

Re­pair the GPT Par­ti­tion Ta­ble

Here I'm us­ing the gdisk tool but for sim­i­lar tasks there is a plen­ty of oth­er tolls is avail­able. As fi­nal re­sult the par­ti­tion ta­ble is re­paired and al­so a back­up copy is writ­ten to the disk. In the list­ing be­low are used the fol­low­ing gdisk's com­mands:

  • p print the par­ti­tion ta­ble,
  • v ver­i­fy disk,
  • w write ta­ble to disk and ex­it.
sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.5

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

Found valid GPT with protective MBR; using GPT.
Command (? for help): ?
b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu
Command (? for help): p
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Model: CT250MX500SSD1
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 0AC2B894-BAE7-4790-80F9-1934C8F84E24
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 488397134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4397 sectors (2.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00
   2         1050624       488394751   232.4 GiB   8300
Command (? for help): v
No problems found. 4397 free sectors (2.1 MiB) available in 2
segments, the largest of which is 2383 (1.2 MiB) in size.
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/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

Ref­er­ences