Skip to main content
  1. Posts/

Backup dan Restore Partisi table di Linux

·3 mins·
linux linux
Table of Contents

Tutorial ini dibuat untuk mengkloning partisi pada hdd lama ke hdd baru atau melakukan repair partisi pada hdd lama apabila terjadi kerusakan

Backup partisi table
#

Backup dengan commmand sfdisk seperti berikut

sfdisk -d /dev/vda > backup.img

sesuaikan dengan partisi yang ingin kalian backup misal vda, sda, dll {: .prompt-tip }

Isi file backup.img

# cat backup.img
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

Restore partisi table
#

Untuk restore pada percobaan dibawah menggunakan hdd baru [vdb]

Namun bisa juga kalian sesuaikan dengan hdd lama [vda]. pastikan semua data yang ada di hdd lama sudah dibackup

Untuk perintah restore dengan sfdisk

sfdisk /dev/vdb < backup.img

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.

Cek partisi table dengan fdisk

hdd lama [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 [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.

Related

Cara membuat Logical Volume (LVM)
·3 mins
lvm linux lvm
Cek dan Repair FAT filesystem Linux
·1 min
linux
Setting JS Snippet Cloudflare pada Jekyll
·1 min
jekyll jekyll cloudflare