How does a MBR in USB drive works?

9,202

Every USB drive has a Master Boot Record.

It is not true. I mean you can call the very first 512 bytes "MBR" by default but it doesn't have to be actually working MBR holding MBR-specific data. In my Kubuntu I can easily create a filesystem on my whole USB device or use the device as swap.


Coming to USB, it has only 1 partition.

Technically you can have MBR (or GPT) and partitions on a USB drive in the same way as on "regular" HDDs, if only you manage to create them. Linux tools have no problem with that, they can partition not only block devices but also regular files or already existing partitions, regardless whether it makes sense or not. Windows on the other hand…

Few months ago I discovered that Windows (7? – don't remember now) had troubles reading USB stick where there were two partitions. It accepted one partition only, or the filesystem directly on the device. It was formally a removable device. I know Windows in general can treat USB disks and USB removable devices differently. Compare this and this – amusing example of "OS that knows better". I have never seen Linux doing similarly arrogant thing.

This old thread agrees with my observations:

I bought a 16GB PNY SD card to use on my Dell mini. It works fine in Ubuntu (naturally) but I want to switch the Removable Media Bit (RMB) so that windows will see it as a fixed disk. This allows multiple partitions to be visible and configurable in Windows.

And later:

Linux doesn't care about this [Removable Media Bit], neither does your BIOS.


MBR has boot signature which will make it bootable. So, every USB must be bootable, right?

Wrong. Even if there is a place for a bootstrap code (some parts of MBR are such places) you may or may not have (sane) code there. But maybe you meant "every USB can be made bootable". If so then yes, as far as I know there is no technical reason which would prevent making a USB drive bootable.

The different issue is: will your hardware boot from it? Old(-ish) motherboards cannot boot from USB, they have no such option. This can be circumvented by booting to GRUB or Plop Boot Manager etc. that exists elsewhere and then chainloading to the USB.

Another issue: will your software boot from it? Once the booting process gets to the specific loader that needs multiple files to "conjure" the working operating system or another software, this loader expects to find the files on such-and-such device, it may have no drivers (or simply no intentions) to access other devices. E.g. live CD software would try to access the optical drive and you need some tricks (done by Rufus, Yumi etc.) to make it work with USB stick. The same may apply if the software expects a fixed disk and you need to boot from the removable one.

Again Linuxes seem to have an advantage here, treating various block devices in a similar manner. This guide on how to install Ubuntu to USB drive is basically "choose the right drive for Ubuntu and for a bootloader, install as you would normally do, then boot from it". With Windows it is not that simple.

Share:
9,202

Related videos on Youtube

Panther Coder
Author by

Panther Coder

Student on the go learning anything anywhere. Got my area of interest in Operating System Designs. Just as a quote that says, Computers are incredibly fast, accurate and stupid and me? I fell in love with that stupid. We both make the best pair aiming to innovate something new with 0's and 1's apparently. Everything else is secondary - haha Steve. Meta data? I don't get used to reveal it public. - Apparently, this user prefers to keep an air of mystery about them. ;)

Updated on September 18, 2022

Comments

  • Panther Coder
    Panther Coder over 1 year

    Every USB drive has a Master Boot Record. MBR contains Partition Table. While on a normal HDD, The MBR can have 4 partitions and the MBR has information about the partitions. Coming to USB, it has only 1 partition. So, what will be the remaining 3 partition? I mean BIOS 64 bytes in MBR is for partition table right? If only one partition is used , what about the remaining? Ok, If everything goes well, MBR has boot signature which will make it bootable. So, every USB must be bootable right?

    I have read lot of tutorials and found nothing about MBR in USB. I am a lot confused. If anything is wrong above, kindly help me..

    Thanks

  • Panther Coder
    Panther Coder over 7 years
    No, I am asking whether the USB by default has a MBR. If so, every USB is bootable right?
  • Ipor Sircer
    Ipor Sircer over 7 years
    MBR is the 1st 256byte of the device. Every device has its first 256b, unless it is smaller than 256byte. :->
  • Panther Coder
    Panther Coder over 7 years
    Every USB drive has a MBR - If this is not true, then what will be in the first 512 bytes of a USB?
  • Kamil Maciorowski
    Kamil Maciorowski over 7 years
    @PantherCoder It may be another type of bootsector, see VBR. In Linux I can build large virtual device over several small physical devices (e.g. linear setup like JBOD or striped like RAID0) with dmsetup. The virtual device MBR will be on the first physical device or even striped across many of them. I can even write any 512 bytes to these first 512 bytes if I wish so.