Skip to content

Commit a56f8f1

Browse files
author
Prakash Surya
committed
Add scripts to enable rpool disk expansion
PR URL: https://www.github.com/delphix/delphix-platform/pull/463
1 parent cea781e commit a56f8f1

File tree

4 files changed

+128
-1
lines changed

4 files changed

+128
-1
lines changed

debian/rules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ DEPENDS += ansible, \
5959
debootstrap, \
6060
debsums, \
6161
dmidecode, \
62+
gdisk, \
6263
init, \
6364
iproute2, \
6465
iputils-ping, \
66+
jq, \
6567
kbd, \
6668
kmod, \
6769
less, \
@@ -85,7 +87,8 @@ DEPENDS += ansible, \
8587
sudo, \
8688
systemd-container, \
8789
tzdata, \
88-
udev,
90+
udev, \
91+
util-linux,
8992

9093
#
9194
# The CRA PAM module provides an authentication method for the delphix user.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2023 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
function die() {
19+
echo "$(basename "$0"): $*" >&2
20+
exit 1
21+
}
22+
23+
function cleanup() {
24+
# shellcheck disable=SC2317
25+
([[ -z "$GRUB_DIR" ]] || [[ ! -d "$GRUB_DIR" ]]) && return
26+
27+
umount "$GRUB_DIR"
28+
rm -rf "$GRUB_DIR"
29+
}
30+
31+
function get_partition_path() {
32+
lsblk -p "$1" --json | jq -Mr '.[][]["children"][0]["name"]'
33+
}
34+
35+
[[ $# -gt 2 ]] && usage "too many arguments specified"
36+
[[ $# -eq 1 ]] && usage "too few arguments specified"
37+
38+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
39+
40+
trap cleanup EXIT
41+
42+
OLD_DISK_PATH="$(readlink -f "$1")"
43+
NEW_DISK_PATH="$(readlink -f "$2")"
44+
45+
OLD_DISK_PART="$(get_partition_path "$OLD_DISK_PATH")"
46+
NEW_DISK_PART="$(get_partition_path "$NEW_DISK_PATH")"
47+
48+
GRUB_DIR=$(mktemp -d -p /tmp -t unpack.XXXXXXX)
49+
50+
set -o xtrace
51+
zpool attach rpool "$OLD_DISK_PART" "$NEW_DISK_PART"
52+
mount -t zfs "rpool/grub" "$GRUB_DIR"
53+
grub-install --root-directory="$GRUB_DIR" "$NEW_DISK_PATH"
54+
grub-mkconfig -o "/mnt/boot/grub/grub.cfg"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2023 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
function die() {
19+
echo "$(basename "$0"): $*" >&2
20+
exit 1
21+
}
22+
23+
function get_partition_path() {
24+
lsblk -p "$1" --json | jq -Mr '.[][]["children"][0]["name"]'
25+
}
26+
27+
[[ $# -gt 1 ]] && usage "too many arguments specified"
28+
[[ $# -eq 0 ]] && usage "too few arguments specified"
29+
30+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
31+
32+
DISK_PATH="$(readlink -f "$1")"
33+
DISK_PART="$(get_partition_path "$DISK_PATH")"
34+
35+
set -o xtrace
36+
zpool detach rpool "$DISK_PART"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2023 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
function die() {
19+
echo "$(basename "$0"): $*" >&2
20+
exit 1
21+
}
22+
23+
[[ $# -gt 1 ]] && usage "too many arguments specified"
24+
[[ $# -eq 0 ]] && usage "too few arguments specified"
25+
26+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
27+
28+
DISK_PATH="$(readlink -f "$1")"
29+
30+
set -o xtrace
31+
sgdisk --zap-all "$DISK_PATH"
32+
sgdisk "$DISK_PATH" --set-alignment=1 --new=2:1m:+1m --typecode=2:EF02
33+
sgdisk "$DISK_PATH" --new=1:: --typecode=1:8300
34+
sgdisk "$DISK_PATH" --print

0 commit comments

Comments
 (0)