Tom*_*oth 8 partition dd mbr gparted
我有一个 MBR 格式的 SD 卡,当连接到 Linux 机器(xubuntu 12.04)时,它可以挂载一个分区并解析文件系统(GParted 也可以)。但是,当我尝试使用 dd 从设备读取 MBR 时,它给了我一堆虚假数据。
当 dd 无法读取 MBR 时,任何人都可以阐明 Linux/GParted 如何能够读取和理解 MBR。他们是否使用不同的方法来获取数据?IE 未打开(),读取()
DD命令是:
dd if=/dev/sdb of=mbr.bin bs=512 count=1
Run Code Online (Sandbox Code Playgroud)
DD输出为:
1+0 records in
1+0 records out
512 bytes transferred in 0.000786 secs (651345 bytes/sec)
Run Code Online (Sandbox Code Playgroud)
mbr.bin 转储hexdump -C mbr.bin是:
00000000 04 16 41 53 4d 49 2d 53 44 03 00 00 00 00 16 f1 |..ASMI-SD.......|
00000010 00 7f 00 32 1f 5b 80 00 36 db bf bf 96 c0 00 01 |...2.[..6.......|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 6f 00 00 10 00 00 02 2e 00 00 00 00 00 00 00 00 |o...............|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200
Run Code Online (Sandbox Code Playgroud)
我会尝试使用该sfdisk命令而不是dd. 例如:
$ sudo sfdisk -d /dev/sda > /tmp/mbr_using_sfdisk.bin
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Run Code Online (Sandbox Code Playgroud)
现在查看mbr_using_sfdisk.bin揭示了您正在寻找的内容:
$ more /tmp/mbr_using_sfdisk.bin
# partition table of /dev/sda
unit: sectors
/dev/sda1 : start= 2048, size= 2457600, Id= 7, bootable
/dev/sda2 : start= 2459648, size=314765312, Id= 7
/dev/sda3 : start=956291072, size= 20480000, Id= 7
/dev/sda4 : start=317224960, size=639066112, Id= 5
/dev/sda5 : start=317227008, size= 1024000, Id=83
/dev/sda6 : start=318253056, size=638038016, Id=8e
Run Code Online (Sandbox Code Playgroud)
dd?我不完全确定为什么,但我确实遇到了这个技巧,它向您展示了如何mbr.bin使用file命令查看分区表。
例如:
$ sudo dd if=/dev/sda bs=512 count=1 of=mbr.bin
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000184924 s, 2.8 MB/s
$ file mbr.bin
mbr.bin: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x12f0c26a, GRUB version 0.94;
partition 1: ID=0x7, active, starthead 32, startsector 2048, 2457600 sectors;
partition 2: ID=0x7, starthead 162, startsector 2459648, 314765312 sectors;
partition 3: ID=0x7, starthead 239, startsector 956291072, 20480000 sectors;
partition 4: ID=0x5, starthead 239, startsector 317224960, 639066112 sectors, code offset 0x48
Run Code Online (Sandbox Code Playgroud)