Tutorial ini dibuat untuk mengkloning tabel partisi dari HDD lama ke HDD baru atau melakukan perbaikan (repair) tabel partisi pada HDD lama apabila terjadi kerusakan.
Backup Partition Table #
Untuk melakukan backup tabel partisi dapat menggunakan perintah sfdisk seperti berikut:
sfdisk -d /dev/vda > backup.img
/dev/vda, /dev/sda, dan lain-lain.
Isi file backup.img akan terlihat seperti berikut:
label: gpt
label-id: A01CA716-11FF-42B7-B0F3-8A6E9FF8CE6F
device: /dev/vda
unit: sectors
first-lba: 34
last-lba: 4612062
sector-size: 512
/dev/vda1 : start= 227328, size= 4384735, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=CA28AB7B-93EC-418B-99BC-87C42F331D2B
/dev/vda14 : start= 2048, size= 8192, type=21686148-6449-6E6F-744E-656564454649, uuid=F0DC197C-99CB-4287-8A13-3FA7CAF72163
/dev/vda15 : start= 10240, size= 217088, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=4DC63329-B918-43F2-A8F3-093AE90CEF9A
File ini berisi informasi lengkap mengenai struktur tabel partisi, termasuk label disk, UUID, posisi sektor awal, dan ukuran masing-masing partisi.
Restore Partition Table #
Untuk proses restore, pada contoh berikut menggunakan HDD baru /dev/vdb.
Namun perintah ini juga dapat digunakan untuk memperbaiki tabel partisi pada HDD lama (/dev/vda) jika tabel partisinya rusak.
Perintah restore menggunakan sfdisk:
sfdisk /dev/vdb < backup.img
Contoh output:
Checking that no-one is using this disk right now ... OK
Disk /dev/vdb: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: A01CA716-11FF-42B7-B0F3-8A6E9FF8CE6F).
/dev/vdb1: Created a new partition 1 of type 'Linux filesystem' and of size 2.1 GiB.
/dev/vdb2: Created a new partition 14 of type 'BIOS boot' and of size 4 MiB.
/dev/vdb15: Created a new partition 15 of type 'EFI System' and of size 106 MiB.
/dev/vdb16: Done.
New situation:
Disklabel type: gpt
Disk identifier: A01CA716-11FF-42B7-B0F3-8A6E9FF8CE6F
Device Start End Sectors Size Type
/dev/vdb1 227328 4612062 4384735 2.1G Linux filesystem
/dev/vdb14 2048 10239 8192 4M BIOS boot
/dev/vdb15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Verifikasi Partition Table #
Setelah proses restore selesai, lakukan pengecekan menggunakan fdisk.
HDD lama (/dev/vda)
#
fdisk -l /dev/vda
Disk /dev/vda: 2.2 GiB, 2361393152 bytes, 4612096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A01CA716-11FF-42B7-B0F3-8A6E9FF8CE6F
Device Start End Sectors Size Type
/dev/vda1 227328 4612062 4384735 2.1G Linux filesystem
/dev/vda14 2048 10239 8192 4M BIOS boot
/dev/vda15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
HDD baru (/dev/vdb)
#
fdisk -l /dev/vdb
Disk /dev/vdb: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A01CA716-11FF-42B7-B0F3-8A6E9FF8CE6F
Device Start End Sectors Size Type
/dev/vdb1 227328 4612062 4384735 2.1G Linux filesystem
/dev/vdb14 2048 10239 8192 4M BIOS boot
/dev/vdb15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
Dari hasil tersebut terlihat bahwa struktur tabel partisi pada HDD baru sudah sama dengan HDD lama.