凌云实验室推出的ARM Linux物联网网关开发板IGKBoard(IoT Gateway Kit Board)项目源码
guowenxue
2023-03-30 7800e82e4b6b59a46e648c93f488636b0a1555fc
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
#!/bin/sh
#
# Copyright (C) 2022 LingYun IoT System Studio
# Author: Guo Wenxue<guowenxue@gmail.com>
#
# This shell script used to expand rootfs partition size to whole TF card space
#
 
set -e
set -u
 
# find the root partition information
ROOT_PART="$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')"
ROOT_DEV="/dev/$(lsblk -no pkname /dev/${ROOT_PART})"
PART_DEV="$(lsblk ${ROOT_DEV} | grep -w "\/" | grep mmcblk | awk '{print $1}' | cut -d- -f2)"
PART_NUM="$(echo ${PART_DEV} | cut -dp -f2)"
 
# Get the starting offset of the root partition
PART_START=$(fdisk -l $ROOT_DEV | grep $PART_DEV | awk '{print $2}')
[ "$PART_START" ] || return 1 ;
 
fdisk "$ROOT_DEV" > /dev/null 2>&1 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START
 
p
w
EOF
 
resize2fs /dev/$ROOT_PART > /dev/null 2>&1
 
echo "Expand rootfs size successfully, it will be enlarged upon the next reboot."