From 06655278a484df500641bc95109252cec19569f4 Mon Sep 17 00:00:00 2001 From: yafen Date: Wed, 6 Jan 2021 17:38:36 +0800 Subject: [PATCH 1/2] extend root partition on boot --- build-image.sh | 4 ++++ config/chroot.sh | 7 ++++++- config/extend-root.sh | 49 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 config/extend-root.sh diff --git a/build-image.sh b/build-image.sh index c6393dd..b59bc64 100644 --- a/build-image.sh +++ b/build-image.sh @@ -248,6 +248,10 @@ make_rootfs(){ cp ${euler_dir}/*.rules ${rootfs_dir}/lib/udev/rules.d/ cp ${euler_dir}/LICENCE.* ${rootfs_dir}/usr/share/licenses/raspi/ cp ${euler_dir}/chroot.sh ${rootfs_dir}/chroot.sh + if [ ! -d ${rootfs_dir}/etc/rc.d/init.d ]; then + mkdir -p ${rootfs_dir}/etc/rc.d/init.d + fi + cp ${euler_dir}/extend-root.sh ${rootfs_dir}/etc/rc.d/init.d/extend-root.sh chmod +x ${rootfs_dir}/chroot.sh mount --bind /dev ${rootfs_dir}/dev mount -t proc /proc ${rootfs_dir}/proc diff --git a/config/chroot.sh b/config/chroot.sh index 93f6859..9ab787f 100644 --- a/config/chroot.sh +++ b/config/chroot.sh @@ -13,4 +13,9 @@ if [ -f /usr/share/zoneinfo/Asia/Shanghai ]; then fi if [ -f /etc/rc.d/rc.local ]; then chmod +x /etc/rc.d/rc.local -fi \ No newline at end of file +fi +cd /etc/rc.d/init.d +chmod +x extend-root.sh +chkconfig --add extend-root.sh +chkconfig extend-root.sh on +cd - \ No newline at end of file diff --git a/config/extend-root.sh b/config/extend-root.sh new file mode 100755 index 0000000..1e23a3e --- /dev/null +++ b/config/extend-root.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# chkconfig: - 99 10 +# description: extend root + +set -e + +extend_root(){ + ROOT_PART="$(findmnt / -o source -n)" # /dev/mmcblk0p3 + ROOT_DEV="/dev/$(lsblk -no pkname "$ROOT_PART")" # /dev/mmcblk0 + PART_NUM="$(echo "$ROOT_PART" | grep -o "[[:digit:]]*$")" # 3 + + PART_INFO=$(parted "$ROOT_DEV" -ms unit s p) + # BYT; + # /dev/mmcblk0:31116288s:sd/mmc:512:512:msdos:SD SC16G:; + # 1:8192s:593919s:585728s:fat16::boot, lba; + # 2:593920s:1593343s:999424s:linux-swap(v1)::; + # 3:1593344s:31116287s:29522944s:ext4::; + LAST_PART_NUM=$(echo "$PART_INFO" | tail -n 1 | cut -f 1 -d:) # 3 + PART_START=$(echo "$PART_INFO" | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g') # 1593344 + PART_END=$(echo "$PART_INFO" | grep "^${PART_NUM}" | cut -f 3 -d: | sed 's/[^0-9]//g') # XXXX < 31116288 + ROOT_END=$(echo "$PART_INFO" | grep "^/dev"| cut -f 2 -d: | sed 's/[^0-9]//g') # 31116288 + ((ROOT_END--)) # 31116287 + + if [ $PART_END -lt $ROOT_END ]; then + fdisk "$ROOT_DEV" <> /var/log/extend-root.log + else + echo "Already the largest! Do not need extend any more!" >> /var/log/extend-root.log + fi + return 0 +} + +if extend_root; then + rm -f /etc/rc.d/init.d/extend-root.sh +else + echo "Fail to root!" >> /var/log/extend-root.log +fi -- Gitee From 3e59e0089a5c8187ef79bff2feb80879e19ace24 Mon Sep 17 00:00:00 2001 From: yafen Date: Thu, 7 Jan 2021 09:02:31 +0800 Subject: [PATCH 2/2] install openssh-clients --- config/rpmlist | 1 + 1 file changed, 1 insertion(+) diff --git a/config/rpmlist b/config/rpmlist index 26d14f4..ea03020 100644 --- a/config/rpmlist +++ b/config/rpmlist @@ -8,6 +8,7 @@ iproute iputils NetworkManager openssh-server +openssh-clients passwd hostname bluez -- Gitee