備份
sfdisk -d /dev/sdx > part_table_filepath
回存
sfdisk /dev/sdx < part_table_filepath
root@cyvm:/dev# sfdisk /dev/sdd < /media/sf_hd_image_backup/5054/part_table Checking that no-one is using this disk right now ... OK Disk /dev/sdd: 698.7 GiB, 750156374016 bytes, 1465149168 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: dos Disk identifier: 0x5e487107 Old situation: Device Boot Start End Sectors Size Id Type /dev/sdd1 2048 31459327 31457280 15G 27 Hidden NTFS WinRE /dev/sdd2 31459328 38799359 7340032 3.5G 12 Compaq diagnostics /dev/sdd3 * 38799360 39004159 204800 100M 7 HPFS/NTFS/exFAT /dev/sdd4 39004160 1465145343 1426141184 680G f W95 Ext'd (LBA) /dev/sdd5 39006208 1465145343 1426139136 680G 7 HPFS/NTFS/exFAT >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Created a new DOS disklabel with disk identifier 0x2fdd5485. Created a new partition 1 of type 'Hidden NTFS WinRE' and of size 9.8 GiB. /dev/sdd2: Created a new partition 2 of type 'FAT16' and of size 51.2 GiB. /dev/sdd3: Created a new partition 3 of type 'HPFS/NTFS/exFAT' and of size 50.9 GiB. /dev/sdd4: New situation: Device Boot Start End Sectors Size Id Type /dev/sdd1 63 20466809 20466747 9.8G 27 Hidden NTFS WinRE /dev/sdd2 * 20466810 127732814 107266005 51.2G 6 FAT16 /dev/sdd3 127732815 234436544 106703730 50.9G 7 HPFS/NTFS/exFAT The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
dd
使用 dd 僅能備份主要分割資訊,所以不建議使用,這裡僅供研究參考用。
參考:https://wiki.archlinux.org/index.php/Fdisk
MBR 使用磁碟最前面 512 bytes 來儲存資訊,包含了三部份:
- 446 bytes: boot loader
 - 64 bytes: partition table (共四組,每組使用16 bytes)
 - 2 bytes: identifier
 
備份方法:
dd if=/dev/sdx of=part_table_filepath bs=1 skip=446 count=64
回存方法:
dd if=part_table_filepath of=/dev/sdx bs=1 seek=446 count=64