How to see if USB stick has MBR?

Posted on

Problem :

I have a USB stick supposed to be bootable, but the computer does not boot it. I suspect that there is no MBR (Master Boot Record).

How do I test if this is so, preferably from command line in Linux.

Solution :

You can inspect this with dd and file, e.g. for /dev/sda:

root@rapunzel:~# dd if=/dev/sda of=/tmp/test count=1 bs=512
1+0 records in
1+0 records out
512 bytes (512 B) copied, 6.1994e-05 s, 8.3 MB/s

Then you’ve got the bootsector in /tmp/test you can ask file what it thinks:

root@rapunzel:~# file /tmp/test
/tmp/test: x86 boot sector; partition 1: ID=0x7, starthead 32, startsector 2048, 1850621692 sectors; partition 2: ID=0x17, starthead 254, startsector 2922062850, 8209215 sectors; partition 3: ID=0xfd, starthead 254, startsector 1850623740, 1071439110 sectors, code offset 0x63, OEM-ID "      ΠΌ", Bytes/sector 190, sectors/cluster 124, reserved sectors 191, FATs 6, root entries 185, sectors 64514 (volumes <=32 MB) , Media descriptor 0xf3, sectors/FAT 20644, heads 6, hidden sectors 309755, sectors 2147991229 (volumes > 32 MB) , physical drive 0x7e, dos < 4.0 BootSector (0x0)

You can also inspect the file manually with hexdump -C

since CesarB didn’t post his comment as an answer:

jcomeau@aspire:~$ sudo file -s /dev/sdb
[sudo] password for jcomeau: 
/dev/sdb: DOS floppy 1440k, DOS/MBR hard disk boot sector

You can use TestDisk (free, open source, and cross platform) to do this. It can scan any drive you want, and analyze the partition layout (or you can specify it and it will try to search for partitions in the layout style you choose). TestDisk can also overwrite the MBR on a disk with the one you choose.

Leave a Reply

Your email address will not be published. Required fields are marked *