Italiano English
Edit History Actions

Diff for "Hybrid_UEFI_MBR_USB_Drive"

Differences between revisions 7 and 9 (spanning 2 versions)
Revision 7 as of 2016-09-14 13:28:55
Size: 5692
Editor: 91
Comment:
Revision 9 as of 2016-09-14 13:43:54
Size: 6495
Editor: 91
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
A working Linux installation with the following packages: ''grub2, grub2-efi, gdisk'' (on Debian Jessie: ''grub-pc-bin, grub-efi, grub-efi-amd64, gdisk'')
An USB drive
Some Linux ISO.
 *A working Linux installation with the following packages: ''grub2, grub2-efi, gdisk'' (on Debian Jessie: ''grub-pc-bin, grub-efi, grub-efi-amd64, gdisk'')
 *An USB drive
 *Some Linux ISO.
Line 7: Line 7:
=== Step 1: get the proper /dev === === Step 1: get the right /dev ===
Line 25: Line 25:
Find the right dev (ie: mine was '''/dev/sdc''' and ''i will use it in the guide''). Find the right dev (ie: mine was '''/dev/sdc''' and ''I WILL USE IT IN THE GUIDE'').
Line 93: Line 93:
`root@debianvm:~# gdisk /dev/sdc`<<BR>> `root@debianvm:~#` '''gdisk /dev/sdc'''<<BR>>
Line 104: Line 104:
`Command (? for help): r`<<BR>> `Command (? for help):` '''r'''<<BR>>
Line 136: Line 136:
gdisk will quit (again) and it's ok.

=== Step 4: Format the partitons ===
We have to format in FAT32 two of the three partitions, '''''/dev/sdc2''''' and '''''/dev/sdc3'''''.
Umount the partitions if mounted and then:

`root@debianvm:~#` '''mkfs.fat -F32 -n GRUB2EFI /dev/sdc2'''<<BR>>
`mkfs.fat 3.0.27 (2014-11-12)`<<BR>>

`root@debianvm:~#` '''mkfs.fat -F32 -n DATA /dev/sdc3'''<<BR>>
`mkfs.fat 3.0.27 (2014-11-12)`<<BR>>

Now the partitons are ready, we will mount '''''/devsdc2''''' to '''''/mnt/efi''''' and '''''/dev/sdc3''''' to '''''/mnt/data'''''.

`root@debianvm:~#` '''mkdir /mnt/efi'''<<BR>>
`root@debianvm:~#` '''mkdir /mnt/data'''<<BR>>
`root@debianvm:~#` '''mount /dev/sdc2 /mnt/efi/'''<<BR>>
`root@debianvm:~#` '''mount /dev/sdc3 /mnt/data/'''<<BR>>

An Hybrid UEFI GPT + BIOS GPT/MBR boot USB disk is a disk that works on both UEFI and BIOS PCs.

Requisites:

  • A working Linux installation with the following packages: grub2, grub2-efi, gdisk (on Debian Jessie: grub-pc-bin, grub-efi, grub-efi-amd64, gdisk)

  • An USB drive
  • Some Linux ISO.

Step 1: get the right /dev

From now on we will use a root shell because almost all commands we will use require it.

root@debianvm:~# fdisk -l

...............

Disk /dev/sdc: 14.9 GiB, 16005464064 bytes, 31260672 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1           2 31260671 31260670 14.9G af HFS / HFS+

Find the right dev (ie: mine was /dev/sdc and I WILL USE IT IN THE GUIDE).

Step 2: make GUID partition table and partitions

root@debianvm:~# gdisk /dev/sdc
And then we are in gdisk prompt; from now on just give the commands in bold and the press enter.

GPT fdisk (gdisk) version 0.8.10

Partition table scan:

  • MBR: MBR only
    BSD: not present
    APM: not present
    GPT: not present

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************

Warning! Main partition table overlaps the first partition by 32 blocks!
You will need to delete this partition or resize it in another utility.

Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n Partition number (1-128, default 1): 
First sector (34-31260638, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-31260638, default = 31260638) or {+-}size{KMGTP}: +1M
Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): EF02
Changed type of partition to 'BIOS boot partition'

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-31260638, default = 4096) or {+-}size{KMGTP}:
Last sector (4096-31260638, default = 31260638) or {+-}size{KMGTP}: +50M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to 'EFI System'

Command (? for help): n
Partition number (3-128, default 3):
First sector (34-31260638, default = 106496) or {+-}size{KMGTP}:
Last sector (106496-31260638, default = 31260638) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
Now gdisk will quit, it's ok.

Step 3: make hybrid GUID/MBR

root@debianvm:~# gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): r

Recovery/transformation command (? for help): h

WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.

Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 1 2 3
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): n

Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code (default EF): EF02
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default EF): EF00
Set the bootable flag? (Y/N): n

Creating entry for GPT partition #3 (MBR partition #3)
Enter an MBR hex code (default 07): 0700
Set the bootable flag? (Y/N): y

Recovery/transformation command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
gdisk will quit (again) and it's ok.

Step 4: Format the partitons

We have to format in FAT32 two of the three partitions, /dev/sdc2 and /dev/sdc3. Umount the partitions if mounted and then:

root@debianvm:~# mkfs.fat -F32 -n GRUB2EFI /dev/sdc2
mkfs.fat 3.0.27 (2014-11-12)

root@debianvm:~# mkfs.fat -F32 -n DATA /dev/sdc3
mkfs.fat 3.0.27 (2014-11-12)

Now the partitons are ready, we will mount /devsdc2 to /mnt/efi and /dev/sdc3 to /mnt/data.

root@debianvm:~# mkdir /mnt/efi
root@debianvm:~# mkdir /mnt/data
root@debianvm:~# mount /dev/sdc2 /mnt/efi/
root@debianvm:~# mount /dev/sdc3 /mnt/data/