2

I have always managed to create bootable linux usb devices using only dd. But when it comes to Windows, the computer fails to boot from USB .. - I don't know why it doesn't work that way, but the most important is: Why it is required to write the MBR into the device in order to get Windows boot properly?

5
  • How do you create the image of the Windows OS ? Would, as example an .iso file of your windows work when copied to the usb-storage with DiskPart ?
    – Tech-IO
    Commented Oct 14, 2017 at 12:03
  • @Tech-IO there are no tools similar to dd in Windows and you need some tool to create an install disk. They don't simply copy the whole ISO to the pendrive byte-by-byte but create a bootable USB that you can store data as normal
    – phuclv
    Commented Oct 14, 2017 at 14:29
  • @Tech-IO I use dd. but woeusb helped me to create bootable usb device. Commented Oct 14, 2017 at 15:48
  • I didn't tried to make bootable a running windows, thru an usb-storage. At least I could make bootable Windows to install it new. How to make a clone of a running Windows, with external usb ?
    – Tech-IO
    Commented Oct 14, 2017 at 19:37
  • @Tech-IO that's what Windows To Go for
    – phuclv
    Commented Oct 15, 2017 at 3:24

3 Answers 3

4

Your premise is incorrect. Not all Linux distros can boot just by dd the image to the flash drive. For example in old Ubuntu versions you have to use a tool to create Ubuntu install/live USB drive. In Ubuntu 5.x or 6.x you even have to use separate CDs for live session and for installation.

Most Linux distros nowadays use hybrid ISOs so that you can just write the whole ISO into the disk and it'll work. However that doesn't mean all Linux distros support that. Knoppix has just changed to hybrid ISO in the lastest version (8.1)

What is a Hybrid Image?

We are used to downloading ISO images from Ubuntu mirrors whenever a new release comes out. At the same time when these images can be burnt directly to a CD-ROM disc, for creating a startup installation USB, one needs to use specific USB creation tools like 'Startup Disk Creator' (included by default in Ubuntu), 'UNetbootin', etc. With hybrid images, you can simply write the data -including the filesystem- of the image to a USB drive by using the 'dd' command. Notice that just copying its content, after mounting it, won't work, as it wouldn't copy the MBR and the partition table, as well as additional sectors at the end of the image.

A normal ISO will have all zeros at the beginning. A hybrid ISO will contain an MBR at the beginning so that the BIOS will think that's a valid boot sector and load it

Hybrid Setup for BIOS and EFI from CD/DVD and USB stick

The EL Torito Boot Catalog can offer in the same ISO filesystem alternative boot images for PC-BIOS and for EFI.

But El Torito is interpreted by the firmware only if presented on an optical medium: CD, DVD, BD. For booting PC-BIOS and EFI from USB stick or other hard-disk-like devices, there is need for an MBR and, if desired, for a GPT.

http://wiki.osdev.org/El-Torito#Hybrid_Setup_for_BIOS_and_EFI_from_CD.2FDVD_and_USB_stick

Linux bootloaders support booting from either MBR and GPT in both BIOS and UEFI systems so there'll be no problem. However the USB flash drive won't be writable anymore in Windows because it's recognized as a CD or DVD drive. You need to clean the drive and recreate using MBR or GPT scheme like this. You still need tools to make bootable Linux pendrives if you want to use the drive for normal data storage as well as booting or if you want to live boot with persistent data.

OTOH Windows doesn't use a hybrid ISO and typically USB-installer makers will just copy the boot.wim, install.wim and other necessary files then flash Windows bootloader to the drive. As Windows bootloader requires GPT on UEFI systems and MBR on BIOS systems, if you're booting MBR flash drive on UEFI it won't work.

For more information:

3
  • if I understand it correctly, a hybrid ISO contains MBR. so in that case dd would copy the MBR as long as the data? Commented Oct 14, 2017 at 10:38
  • also you said that "Windows just set the mode to quick eject by default to reduce data loss" - could you explain this? Commented Oct 14, 2017 at 10:43
  • 1
    @user6039980 see my edit. Regarding quick eject mode see this superuser.com/q/631022/241386. However that doesn't matter here because no one cares about that before and during boot
    – phuclv
    Commented Oct 14, 2017 at 14:26
4

MBR is only required if the boot firmware is either BIOS or in a BIOS compatibility mode. If the firmware is in full UEFI mode without compatibility support then Windows will expect the boot disk to be partitioned as GPT.

Windows boot support for disk partitions can be found at Windows support for hard disks that are larger than 2 TB

System        BIOS + MBR   UEFI + GPT                  BIOS + GPT                   UEFI + MBR
Windows 7     Supported    Supported; (64-bit only)   Boot volume not supported     Boot volume not supported
Windows Vist  Supported    Supported; (64-bit only)   Boot volume not supported     Boot volume not supported
Windows XP    Supported    Not supported              Boot volume not supported     Boot volume not supported
0
1

Your premise is incorrect.
The MBR is always required if the PC has a BIOS.
If you managed to make a bootable disk or flash drive using dd, then you either used the existing MBR of that device, or the dd command wrote a fresh copy to the first sector.

The MBR installed in the first sector is required for every device that emulates a hard disk drive by the PC architecture and BIOS. This requirement is not related to any OS.

I have always managed to create bootable linux usb devices using only dd.

If you used dd to copy a hydrid ISO image to a USB flash drive, then there definitely is a MBR in that image.
Whereas if you tried to use an ordinary ISO image, that USB flash drive would not boot. See what is the difference between the usb booting mechanism and optical disk booting mechanism?

But when it comes to Windows, the computer fails to boot from USB ..

USB is a bus, not a device.
You need a device for booting.
Surely you would encounter a difference booting from a USB HDD or SDD versus a USB flash drive.

Why it is required to write the MBR into the device in order to get Windows boot properly?

Probably because, by default, Windows does not treat (or format) USB flash drives as equivalent to a hard drive. For a USB flash drive Windows writes a device boot sector that has no partition table, just like a floppy drive.
Linux, on the other hand, treats a USB flash drive just like a HDD, and always writes a MBR with a partition table.

When you claim that you "write the MBR into the device", no doubt you are using a Linux system instead of Windows.

ADDENDUM

As proof that Windows does not install a partition table for a USB flash drive, here's a hex dump of the first sector of a USB flash drive that was first "cleaned" with a dd if=/dev/zero of=/dev/sdb count=1, and then formated on a Win7 system using the default parameters.

Hex dump of boot sector of USB flash drive Note that there is a text string where the partition table is supposed to be.

6
  • Windows treats a USB flash drive like a floppy drive, i.e. there is no partition table. it's incorrect. Unlike Linux, Windows won't work with whole disk partition (In Linux you can just format the whole sda as ext4 without the need to create a partition like sda1, sda2...) and it doesn't recognize flash USB as a floppy drive. Even a pendrive must be formatted as MBR. Windows just set the mode to quick eject by default to reduce data loss
    – phuclv
    Commented Oct 14, 2017 at 5:52
  • I mean by usb, the type of boot (either net, hdd, or usb .. of course it's clear enough that a device shall be present on usb port - I don't need to mention the word 'device' twice). I know what USB is. Commented Oct 14, 2017 at 10:51
  • @LưuVĩnhPhúc -- No, I did not intend to mean that Windows "recognize(s) flash USB as a floppy drive". Windows does not put a partition table on either floppies or USB flash drives.
    – sawdust
    Commented Oct 16, 2017 at 6:49
  • @LưuVĩnhPhúc -- You're wrong, and what you think is "proof" is merely output from a second-hand source. Try examining the actual 1st sector as I have done.
    – sawdust
    Commented Oct 17, 2017 at 2:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .