-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdisk.sh
29 lines (23 loc) · 881 Bytes
/
gdisk.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
#!/bin/sh
# vim:set syntax=sh:
# kate: syntax bash;
# SPDX-License-Identifier: CC-BY-SA-4.0
# Copyright 2021 Jakob Meng, <[email protected]>
exit # do not run any commands when file is executed
#
# (s)gdisk
#
# Print partitions
sgdisk --print /dev/disk/by-id/DEVICE
# Replicate partition table and randomize its guids
sgdisk -R=/dev/disk/by-id/TARGET_DEVICE /dev/disk/by-id/SOURCE_DEVICE
sgdisk -G /dev/disk/by-id/TARGET_DEVICE
# Sort partition numbers, e.g. because Debian Installer assigns
# partition numbers in order of creation during install.
sgdisk --sort /dev/disk/by-id/DEVICE
# Wipe GPT and MBR data structures
sgdisk --zap-all /dev/disk/by-id/DEVICE
# Clear partition data, i.e. GPT header data, partition definitions and the protective MBR
sgdisk --clear /dev/disk/by-id/DEVICE
# Create new partition
sgdisk --set-alignment=4096 --new=0:0:0 /dev/disk/by-id/DEVICE