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
|
#!/usr/bin/python3
import sys
import subprocess
def run(*l, **d):
print('run:', *l, d)
return subprocess.run(*l, **d)
def main():
if len(sys.argv) < 2:
print('Usage: {} <device>'.format(sys.argv[0]), file=sys.stderr)
raise SystemExit(1)
device = sys.argv[1]
# use this without check first, in some condition double invokation is
# needed...
run([
'sudo',
'sgdisk',
'--zap-all',
device,
])
run([
'sudo',
'sgdisk',
'--set-alignment=8192',
'--new=1:4M:+100M',
'--change-name=1:boot',
'--typecode=1:EF00',
'--largest-new=2',
'--change-name=2:root',
'--typecode=2:8300',
'--hybrid=1',
'--print',
'--print-mbr',
device,
], check=True)
run([
'sudo',
'mkfs.vfat',
'-F', '32',
'-n', 'boot',
device + '1',
], check=True)
run([
'sudo',
'mkfs.vfat',
'-n', 'boot',
device + '1',
], check=True)
run([
'sudo',
'mkfs.ext4',
'-q',
'-L', 'root',
device + '2'
], check=True)
if __name__ == '__main__':
main()
|