linuxでディスクパーティションテーブルをバックアップおよびリカバリする方法
パーティション・テーブルのバックアップとリカバリ方法
バックアップセクタ
[root@centos7 ~]# dd if=/dev/sda of=/app/mbr bs=1 count=512
512+0 records in
512+0 records out
512 bytes (512 B) copied, 0.00279983 s, 183 kB/s
[root@centos7 app]# ll mbr
-rw-r--r--. 1 root root 512 Dec 2 17:04 mbr
バックアップファイルを別のマシンに転送
[root@centos7 app]# scp mbr 192.168.27.128:/app/
root@192.168.27.128's password:
mbr 100% 512 315.4KB/s 00:00
プライマリパーティションテーブルの破壊
[root@centos7 app]# dd if=/dev/zero of=/dev/sda bs=1 count=512
512+0 records in
512+0 records out
512 bytes (512 B) copied, 0.00105923 s, 483 kB/s
[root@centos7 app]# hexdump -C -n 512 /dev/sda
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200
[root@centos7 app]# fdisk -l
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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
# dd if=./mbr of=/dev/sda bs=1 count=512
そしてシステムを再起動すればいいです.もちろん、ハードディスク(HDD)を直接取り外してバックアップしたマシンにマウントし、リカバリすることもできます.