Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Create resize_rootfs.sh
Browse files Browse the repository at this point in the history
自动扩容
  • Loading branch information
ykla authored Feb 6, 2020
1 parent 9179064 commit c30bcf9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions resize_rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

set -e

if [ "$(id -u)" -ne "0" ]; then
echo "This script requires root."
exit 1
fi

set -x

DEVICE="/dev/mmcblk0"
PART="2"

resize() {
start=$(fdisk -l ${DEVICE}|grep ${DEVICE}p${PART}|awk '{print $2}')
echo $start

set +e
fdisk ${DEVICE} <<EOF
p
d
2
n
p
2
$start
w
EOF
set -e

partx -u ${DEVICE}
resize2fs ${DEVICE}p${PART}
}

systemctl disable resize_rootfs
resize

0 comments on commit c30bcf9

Please sign in to comment.