-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenhd_resize_util.sh
45 lines (35 loc) · 1.15 KB
/
openhd_resize_util.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#resize function
# Specify the UUID of the partition you want to resize
PARTITION_UUID=$1
PARTNR=$2
# Check if the resize.txt file exists
if [ -f "/boot/openhd/openhd/resize.txt" ] || [ -f "/boot/openhd/resize.txt" ]; then
# Find the device path using the UUID
DEVICE_PATH=$(blkid -l -o device -t UUID="$PARTITION_UUID")
MOUNT_POINT=$(echo "$DEVICE_PATH" | sed 's/[0-9]*$//')
if [ -n "$DEVICE_PATH" ]; then
# Resize the partition using gdisk DO NOT EDIT
fdisk "$MOUNT_POINT" <<EOF
d
$PARTNR
n
$PARTNR
w
EOF
# Refresh partition table
partprobe "$DEVICE_PATH"
# Resize the filesystem using resize2fs
resize2fs "/dev/disk/by-uuid/$PARTITION_UUID"
echo "Partition resized and filesystem expanded."
if [ -f "/boot/openhd/openhd/resize.txt" ]; then
rm -Rf /boot/openhd/openhd/resize.txt
elif [ -f "/boot/openhd/resize.txt" ]; then
rm -Rf /boot/openhd/resize.txt
fi
reboot
else
echo "Partition with UUID $PARTITION_UUID not found."
fi
else
echo "Resize not requested. The file /boot/openhd/resize.txt does not exist."
fi