-
Notifications
You must be signed in to change notification settings - Fork 1
/
fdisk_gpt.sh
executable file
·47 lines (45 loc) · 1.44 KB
/
fdisk_gpt.sh
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
#!/bin/bash
if [ -z "$1" ]; then
echo "** MISSING DEVICE! **"
exit 1
fi
## https://superuser.com/a/984637
# to create the partitions programatically (rather than manually)
# we're going to simulate the manual input to fdisk
# The sed script strips off all the comments so that we can
# document what we're doing in-line with the actual commands
# Note that a blank line (commented as "defualt" will send a empty
# line terminated with a newline to take the fdisk default.
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk "$1"
g # overwrite the partition table with GPT
n # new partition
1 # Windows bootloader
# default - start at beginning of disk
+128M # 128 MB boot parttion
n # new partition
2 # LinusGates recovery (copy USB, replaces Windows recovery)
# default - start after last partition
+128M # 128 MB recovery partition
n # new partition
3 # Windows
# default - start after last partition
# default - fill to end of disk
t # change partition type
1 # change partition 1
1 # EFI System
t # change partition type again
2 # change partition 2
10 # Microsoft reserved
t # change partition type one more time
3 # change partition 3
11 # Microsoft basic data
x # enable expert mode
A # make a partition bootable
1 # bootable partition is partition 1 -- /dev/sdc1
r # exit expert mode
p # print the in-memory partition table
w # write the partition table
q # and we're done
EOF
sync
sleep 3