- GPT only, single partition
- GPT + Hybrid MBR, single partition
- GPT + Hybrid MBR, single bootable partition
- GPT + Hybrid MBR, 3 partitions, 2nd one is bootable
- GPT + protective MBR, two partitions
GPT only, single partition
$ gdisk /dev/sdb
- o create a new empty GUID partition table (GPT)
- n add a new partition
- Partition number (1-128, default 1): 1
- 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
- Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}:
Current type is 'Linux/Windows data'
- Hex code or GUID (L to show codes, Enter = 0700):
Changed type of partition to 'Linux/Windows data'
- 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
- o create a new empty GUID partition table (GPT)
- x extra functionality (experts only)
- l set the sector alignment value
- Enter the sector alignment value (1-65536, default = 2048): 63
- m return to main menu
- n add a new partition
- Partition number (1-128, default 1): 1
- First sector (34-3891166, default = 34) or {+-}size{KMGTP}: 63
- Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}:
Current type is 'Linux/Windows data'
- Hex code or GUID (L to show codes, Enter = 0700):
Changed type of partition to 'Linux/Windows data'
-
r recovery and transformation options (experts only)
-
h make hybrid MBR
-
Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1
-
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N
-
Enter an MBR hex code (default 07): 0c
-
Set the bootable flag? (Y/N): N
-
Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
-
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
- o create a new empty GUID partition table (GPT)
- x extra functionality (experts only)
- l set the sector alignment value
- Enter the sector alignment value (1-65536, default = 2048): 63
- m return to main menu
- n add a new partition
- Partition number (1-128, default 1): 1
- First sector (34-3891166, default = 34) or {+-}size{KMGTP}: 63
- Last sector (2048-3891166, default = 3891166) or {+-}size{KMGTP}: +64M
- Hex code or GUID (L to show codes, Enter = 0700):
Changed type of partition to 'Linux/Windows data'
- x extra functionality (experts only)
- l set the sector alignment value
- Enter the sector alignment value (1-65536, default = 2048): 2048
- m return to main menu
- n add a new partition
- Partition number (2-128, default 2): 2
- 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.
- Last sector (133120-3891166, default = 3891166) or {+-}size{KMGTP}: +1500M
- Hex code or GUID (L to show codes, Enter = 0700): 8301
Changed type of partition to 'Linux reserved'
- n add a new partition
- Partition number (3-128, default 3): 3
- First sector (34-3891166, default = 3205120) or {+-}size{KMGTP}:
- Last sector (3205120-3891166, default = 3891166) or {+-}size{KMGTP}:
- Hex code or GUID (L to show codes, Enter = 0700): 8301
Changed type of partition to 'Linux reserved'
- x extra functionality (experts only)
- a set attributes
- Partition number (1-3): 2
- Toggle which attribute field (0-63, 64 or to exit): 0
- Toggle which attribute field (0-63, 64 or to exit): 2
- Toggle which attribute field (0-63, 64 or to exit): 60
- Toggle which attribute field (0-63, 64 or to exit): 62
- 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)
- Toggle which attribute field (0-63, 64 or to exit):
- a set attributes
- Partition number (1-3): 3
- Toggle which attribute field (0-63, 64 or to exit): 63
Attribute value is 8000000000000000. Set fields are: 63 (do not automount)
- Toggle which attribute field (0-63, 64 or to exit):
- r recovery and transformation options (experts only)
- h make hybrid MBR
- Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1 2
- 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 07): 0c
- Set the bootable flag? (Y/N): N
Creating entry for GPT partition #2 (MBR partition #2)
-
Enter an MBR hex code (default 83): 1c
-
Set the bootable flag? (Y/N): Y
-
Unused partition space(s) found. Use one to protect more partitions? (Y/N): Y
-
Enter an MBR hex code (EE is EFI GPT, but may confuse MacOS): 0a
-
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