Skip to content

Commit dadbfd2

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 dadbfd2

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash -eux
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 cleanup() {
19+
# shellcheck disable=SC2317
20+
([[ -z "$GRUB_DIR" ]] || [[ ! -d "$GRUB_DIR" ]]) && return
21+
22+
umount "$GRUB_DIR"
23+
rm -rf "$GRUB_DIR"
24+
}
25+
26+
function get_partition_path() {
27+
lsblk -p "$1" --json | jq '.[][]["children"][0]["name"]'
28+
}
29+
30+
[[ $# -gt 2 ]] && usage "too many arguments specified"
31+
[[ $# -eq 1 ]] && usage "too few arguments specified"
32+
33+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
34+
35+
trap cleanup EXIT
36+
37+
OLD_DISK_PATH="$(readlink -f "$1")"
38+
NEW_DISK_PATH="$(readlink -f "$2")"
39+
40+
OLD_DISK_PART="$(get_partition_path "$OLD_DISK_PATH")"
41+
NEW_DISK_PART="$(get_partition_path "$NEW_DISK_PATH")"
42+
43+
zpool attach rpool "$OLD_DISK_PART" "$NEW_DISK_PART"
44+
45+
GRUB_DIR=$(mktemp -d -p /tmp -t unpack.XXXXXXX)
46+
47+
mount -t zfs "rpool/grub" "$GRUB_DIR"
48+
49+
grub-install --root-directory="$GRUB_DIR" "$NEW_DISK_PATH"
50+
grub-mkconfig -o "/mnt/boot/grub/grub.cfg"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash -eux
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 get_partition_path() {
19+
lsblk -p "$1" --json | jq '.[][]["children"][0]["name"]'
20+
}
21+
22+
[[ $# -gt 1 ]] && usage "too many arguments specified"
23+
[[ $# -eq 0 ]] && usage "too few arguments specified"
24+
25+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
26+
27+
DISK_PATH="$(readlink -f "$1")"
28+
DISK_PART="$(get_partition_path "$OLD_DISK_PATH")"
29+
30+
zpool attach rpool "$DISK_PART"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash -eux
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+
[[ $# -gt 1 ]] && usage "too many arguments specified"
19+
[[ $# -eq 0 ]] && usage "too few arguments specified"
20+
21+
[[ "$EUID" -ne 0 ]] && die "must be run as root"
22+
23+
DISK_PATH="$(readlink -f "$1")"
24+
25+
sgdisk --zap-all "$DISK_PATH"
26+
sgdisk "$DISK_PATH" --set-alignment=1 --new=1:1m:+1m --typecode=2:EF02
27+
sgdisk "$DISK_PATH" --new=1:: --typecode=1:8300
28+
sgdisk "$DISK_PATH" --print

0 commit comments

Comments
 (0)