GPT only, single partition

$ gdisk /dev/sdb

  1. o create a new empty GUID partition table (GPT)
  2. n add a new partition
  3. Partition number (1-128, default 1): 1
  4. First sector (34-3891166, default = 34) or {+-}size{KMGTP}:

Information: Moved requested sector from 34 to 2048 in order to align on 2048-sector boundaries. Use 'l' on the experts' menu to adjust alignment

  1. Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}:

Current type is 'Linux/Windows data'

  1. Hex code or GUID (L to show codes, Enter = 0700):

Changed type of partition to 'Linux/Windows data'

  1. w write table to disk and exit

partprobe

mkfs.vfat /dev/sdb1

Result: Windows says the disk is not formated.

GPT + Hybrid MBR, single partition

$ gdisk /dev/sdb

  1. o create a new empty GUID partition table (GPT)
  2. x extra functionality (experts only)
  3. l set the sector alignment value
  4. Enter the sector alignment value (1-65536, default = 2048): 63
  5. m return to main menu
  6. n add a new partition
  7. Partition number (1-128, default 1): 1
  8. First sector (34-3891166, default = 34) or {+-}size{KMGTP}: 63
  9. Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}:

Current type is 'Linux/Windows data'

  1. Hex code or GUID (L to show codes, Enter = 0700):

Changed type of partition to 'Linux/Windows data'

  1. r recovery and transformation options (experts only)
  2. h make hybrid MBR
  3. Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1
  4. Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N
  5. Enter an MBR hex code (default 07): 0c
  6. Set the bootable flag? (Y/N): N
  7. Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
  8. w write table to disk and exit

    partprobe mkfs.vfat /dev/sdb1

Result: in the MBR, the first partition is the FAT32 one, which is detected and mounted by Windows.

GPT + Hybrid MBR, single bootable partition

Same steps as previously, but the bootable flag is set at step 15. After using liveusb-creator, the stick boots.

GPT + Hybrid MBR, 3 partitions, 2nd one is bootable

$ gdisk /dev/sdb

  1. o create a new empty GUID partition table (GPT)
  2. x extra functionality (experts only)
  3. l set the sector alignment value
  4. Enter the sector alignment value (1-65536, default = 2048): 63
  5. m return to main menu
  6. n add a new partition
  7. Partition number (1-128, default 1): 1
  8. First sector (34-3891166, default = 34) or {+-}size{KMGTP}: 63
  9. Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}: +64M
  10. Hex code or GUID (L to show codes, Enter = 0700):

Changed type of partition to 'Linux/Windows data'

  1. x extra functionality (experts only)
  2. l set the sector alignment value
  3. Enter the sector alignment value (1-65536, default = 2048): 2048
  4. m return to main menu
  5. n add a new partition
  6. Partition number (2-128, default 2): 2
  7. First sector (34-3891166, default = 131135) or {+-}size{KMGTP}:

Information: Moved requested sector from 131135 to 133120 in order to align on 2048-sector boundaries.

  1. Last sector (133120-3891166, default = 3891166) or {+-}size{KMGTP}: +1500M
  2. Hex code or GUID (L to show codes, Enter = 0700): 8301

Changed type of partition to 'Linux reserved'

  1. n add a new partition
  2. Partition number (3-128, default 3): 3
  3. First sector (34-3891166, default = 3205120) or {+-}size{KMGTP}:
  4. Last sector (3205120-3891166, default = 3891166) or {+-}size{KMGTP}:
  5. Hex code or GUID (L to show codes, Enter = 0700): 8301

Changed type of partition to 'Linux reserved'

  1. x extra functionality (experts only)
  2. a set attributes
  3. Partition number (1-3): 2
  4. Toggle which attribute field (0-63, 64 or to exit): 0
  5. Toggle which attribute field (0-63, 64 or to exit): 2
  6. Toggle which attribute field (0-63, 64 or to exit): 60
  7. Toggle which attribute field (0-63, 64 or to exit): 62
  8. Toggle which attribute field (0-63, 64 or to exit): 63

Attribute value is D000000000000005. Set fields are: 0 (system partition) 2 (legacy BIOS bootable) 60 (read-only) 62 (hidden) 63 (do not automount)

  1. Toggle which attribute field (0-63, 64 or to exit):
  2. a set attributes
  3. Partition number (1-3): 3
  4. Toggle which attribute field (0-63, 64 or to exit): 63

Attribute value is 8000000000000000. Set fields are: 63 (do not automount)

  1. Toggle which attribute field (0-63, 64 or to exit):
  2. r recovery and transformation options (experts only)
  3. h make hybrid MBR
  4. Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1 2
  5. Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N

Creating entry for GPT partition #1 (MBR partition #1)

  1. Enter an MBR hex code (default 07): 0c
  2. Set the bootable flag? (Y/N): N

Creating entry for GPT partition #2 (MBR partition #2)

  1. Enter an MBR hex code (default 83): 1c
  2. Set the bootable flag? (Y/N): Y
  3. Unused partition space(s) found. Use one to protect more partitions? (Y/N): Y
  4. Enter an MBR hex code (EE is EFI GPT, but may confuse MacOS): 0a
  5. w write table to disk and exit

    partprobe mkfs.vfat /dev/sdb1 mkfs.vfat /dev/sdb2

Use of liveusb-creator to install an ISO on /dev/sdb2.

GPT + protective MBR, two partitions

$ /sbin/sgdisk                      \
--clear                     \   # create a new partition table
--new=1:0:+1500M            \   # new partition 1, starts at begining, 1500 MiB size
--typecode=1:8301           \   # part 1, set type 8301 (Linux reserved)
--attributes=1:set:0        \   # part 1, set flag: system partition
--attributes=1:set:2        \   # part 1, set flag: legacy BIOS bootable
    --attributes=1:set:60       \   # part 1, set flag: read-only
    --attributes=1:set:62       \   # part 1, set flag: hidden
    --attributes=1:set:63       \   # part 1, set flag: do not automount
    --change-name=1:Linux       \   # part 1, change label to 'Linux'
--largest-new=2             \   # new partition, starts at begining, max size
--typecode=2:8301           \   # part 2, set type 8301 (Linux reserved)
--attributes=1:set:62       \   # part 2, set flag: hidden
--attributes=1:set:63       \   # part 2, set flag: do not automount
--change-name=2:persistent  \   # part 2, change label to 'persistent'
/dev/sdb

Make the partition accessible to Windows, for the time of the installation:

<<EOF sed -e 's/^\([^#]*\) \+# .*$/\1/' | /sbin/gdisk /dev/sdb
r    # recovery and transformation options
h    # make hybrid MBR
1    # add first partition
N    # no EFI GPT (0xEE) partition
0c   # partition type (Win95 FAT32 LBA)
N    # don't set the bootable flag
N    # no protective partition
w    # write table to disk and exit
Y    # proceed, possibly destroying data
EOF

Once the install has been done, lock things up:

<<EOF sed -e 's/^\([^#]*\) \+# .*$/\1/' | /sbin/gdisk /dev/sdb
x    # extra functionality
n    # create a new protective MBR
w    # write table to disk and exit
Y    # proceed, possibly destroying data
EOF