get_partition

This commit is contained in:
poslop
2026-01-16 15:55:04 -06:00
parent c138fc4bcb
commit ce05c833e7

View File

@@ -52,6 +52,15 @@ cleanup() {
} }
trap 'echo "Status Code: $?"; cleanup;' EXIT trap 'echo "Status Code: $?"; cleanup;' EXIT
get_partition($disk_name, $part_num) {
third_part_dev="$(
lsblk -ln -o NAME,TYPE "$disk_name" \
| awk '$2=="part"{print "/dev/"$1}' \
| sed -n "${part_num}p"
)"
return $third_part_dev
}
# Set your target disk here # Set your target disk here
udevadm trigger udevadm trigger
@@ -107,7 +116,7 @@ partprobe || true
# Resize physical volume # Resize physical volume
echo "Resizing physical volume..." echo "Resizing physical volume..."
pvresize ${disk_name}3 || true pvresize "$(get_partition $disk_name "3")" || true
# Resize swap and root logical volumes # Resize swap and root logical volumes
echo "Resizing swap and root volumes..." echo "Resizing swap and root volumes..."
@@ -119,8 +128,8 @@ lvresize -l +100%FREE --resizefs PBX-vg/root
echo "Mounting restored system..." echo "Mounting restored system..."
mkdir -p /mnt/debian mkdir -p /mnt/debian
mount /dev/mapper/PBX--vg-root /mnt/debian/ mount /dev/mapper/PBX--vg-root /mnt/debian/
mount ${disk_name}2 /mnt/debian/boot mount "$(get_partition $disk_name "2")" /mnt/debian/boot
mount ${disk_name}1 /mnt/debian/boot/efi mount "$(get_partition $disk_name "3")" /mnt/debian/boot/efi
for i in "${mount_points[@]}"; do mount -B $i /mnt/debian$i; done for i in "${mount_points[@]}"; do mount -B $i /mnt/debian$i; done