凌云实验室推出的ARM Linux物联网网关开发板IGKBoard(IoT Gateway Kit Board)项目源码
guowenxue
2021-12-27 8944472dc440891bf7388889aeb06fca9a38b3f6
Add expand_rootfs
1 files modified
1 files added
42 ■■■■■ changed files
bsp/rootfs/build.sh 11 ●●●●● patch | view | raw | blame | history
bsp/rootfs/files/expand_rootfs 31 ●●●●● patch | view | raw | blame | history
bsp/rootfs/build.sh
@@ -171,6 +171,14 @@
    fi
}
function do_common()
{
    if [ -s ${PATCH_PATH}/expand_rootfs ] ; then
        cp ${PATCH_PATH}/expand_rootfs ${ROOTFS_DIR}/usr/sbin/
        chmod a+x ${ROOTFS_DIR}/usr/sbin/expand_rootfs
    fi
}
function do_buildroot()
{
    if [ $ROOTFS != "buildroot" ] ; then
@@ -204,6 +212,9 @@
    # modify for buildroot rootfs
    do_buildroot
    # modify for all rootfs
    do_common
    # update hostnmae and issue
    echo "Welcome to LingYun IoT Gateway Kit Board GNU/Linux $ROOTFS system, default password '$DEF_PASSWD'." > ${ROOTFS_DIR}/etc/issue
    echo $DEF_HOSTNAME > ${ROOTFS_DIR}/etc/hostname
bsp/rootfs/files/expand_rootfs
New file
@@ -0,0 +1,31 @@
#!/bin/sh
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."