commit | author | age
|
849fbd
|
1 |
#!/bin/bash |
G |
2 |
|
|
3 |
set -e |
|
4 |
set -u |
|
5 |
|
|
6 |
# find the root partition information |
|
7 |
ROOT_PART="$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')" |
|
8 |
ROOT_DEV="/dev/$(lsblk -no pkname /dev/${ROOT_PART})" |
|
9 |
PART_NUM="$(echo $ROOT_PART | grep -o "[[:digit:]]*$")" |
|
10 |
|
|
11 |
# Get the starting offset of the root partition |
|
12 |
PART_START=$(fdisk -l $ROOT_DEV | grep $ROOT_PART | awk '{print $2}') |
|
13 |
[ "$PART_START" ] || return 1 ; |
|
14 |
|
|
15 |
fdisk "$ROOT_DEV" > /dev/null 2>&1 <<EOF |
|
16 |
p |
|
17 |
d |
|
18 |
$PART_NUM |
|
19 |
n |
|
20 |
p |
|
21 |
$PART_NUM |
|
22 |
$PART_START |
|
23 |
|
|
24 |
p |
|
25 |
w |
|
26 |
EOF |
|
27 |
|
|
28 |
resize2fs /dev/$ROOT_PART > /dev/null 2>&1 |
|
29 |
|
|
30 |
echo "Expand rootfs size successfully, it will be enlarged upon the next reboot." |
|
31 |
|