gpt.mdwn 7.22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[[!toc levels=2]]

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

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

Current type is 'Linux/Windows data'

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

Changed type of partition to 'Linux/Windows data'

7. 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'

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

Changed type of partition to 'Linux/Windows data'

11. r	recovery and transformation options (experts only)
12. h	make hybrid MBR
13. Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 1
14. Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N
15. Enter an MBR hex code (default 07): 0c
16. Set the bootable flag? (Y/N): N
17. Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
18. 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'

11. x	extra functionality (experts only)
12. l	set the sector alignment value
13. Enter the sector alignment value (1-65536, default = 2048): 2048
14. m	return to main menu
15. n	add a new partition
16. Partition number (2-128, default 2): 2
17. 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.

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

Changed type of partition to 'Linux reserved'

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

Changed type of partition to 'Linux reserved'

25. x	extra functionality (experts only)
26. a	set attributes
27. Partition number (1-3): 2
28. Toggle which attribute field (0-63, 64 or <Enter> to exit): 0
29. Toggle which attribute field (0-63, 64 or <Enter> to exit): 2
30. Toggle which attribute field (0-63, 64 or <Enter> to exit): 60
31. Toggle which attribute field (0-63, 64 or <Enter> to exit): 62
32. Toggle which attribute field (0-63, 64 or <Enter> 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)

33. Toggle which attribute field (0-63, 64 or <Enter> to exit):
34. a	set attributes
35. Partition number (1-3): 3
36. Toggle which attribute field (0-63, 64 or <Enter> to exit): 63

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

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

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

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

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

44. Enter an MBR hex code (default 83): 1c
45. Set the bootable flag? (Y/N): Y
46. Unused partition space(s) found. Use one to protect more partitions? (Y/N): Y
47. Enter an MBR hex code (EE is EFI GPT, but may confuse MacOS): 0a
48. 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
====================================

Tails developers's avatar
Tails developers committed
172
	$ /sbin/sgdisk                      \
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	--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:

Tails developers's avatar
Tails developers committed
191
192
193
194
195
196
197
198
199
200
201
	<<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
202
203
204
205


Once the install has been done, lock things up:

Tails developers's avatar
Tails developers committed
206
207
208
209
210
211
	<<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