How to see if USB stick has MBR?

25

6

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.

Mads Skjern

Posted 2011-08-29T17:54:21.683

Reputation: 1 070

Answers

23

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

Flexo

Posted 2011-08-29T17:54:21.683

Reputation: 1 897

What if it says /dev/sdb1: x86 boot sector but nothing else? In my case it won't boot ... – Raketenolli – 2018-03-10T14:50:22.193

Could be gpt or corrupted disk or a sample taken with DD that's too short. Maybe you can get lucky and guess what the partition table is meant to be, but I hope you've got a backup. – Flexo – 2018-03-10T17:16:06.803

I took 2048 bytes as well, same result. The thumb drive is probably simply not made for booting. I'll use a different one which has proven to work in the past. – Raketenolli – 2018-03-10T17:32:30.717

dd-ing an image to a USB drive in my case required of=/dev/sdb. It did not work with /dev/sdb1. – Raketenolli – 2018-03-11T00:17:09.413

30Instead of all that dd dance, just use file -s /dev/sda. – CesarB – 2011-08-29T19:46:00.823

21

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

jcomeau_ictx

Posted 2011-08-29T17:54:21.683

Reputation: 687

3

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.

Breakthrough

Posted 2011-08-29T17:54:21.683

Reputation: 32 927

TestDisk seems very helpful. However, I did not find a way of just collecting information with it, and not be on the way to recover/repair something. – Mads Skjern – 2011-09-01T08:36:52.567