From 65c3377feb939dab3877e1607110f609be4a0f3f Mon Sep 17 00:00:00 2001 From: yafen Date: Wed, 30 Dec 2020 00:07:45 +0800 Subject: [PATCH 1/5] fix: fail to activate swap on boot --- script/step/make_raspi_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/step/make_raspi_image.sh b/script/step/make_raspi_image.sh index 5ce153a..3f5ce14 100644 --- a/script/step/make_raspi_image.sh +++ b/script/step/make_raspi_image.sh @@ -181,7 +181,7 @@ make_img(){ rootp=/dev/mapper/${loopX}p3 LOG "bootp: " ${bootp} "rootp: " ${rootp} mkfs.vfat -n boot ${bootp} - mkswap ${swapp} + mkswap ${swapp} --pagesize 4096 mkfs.ext4 ${rootp} mkdir -p ${root_mnt} ${boot_mnt} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} -- Gitee From 155594ce9e74c68cedadbaabf60cc52ffc219a1e Mon Sep 17 00:00:00 2001 From: yafen Date: Fri, 8 Jan 2021 14:52:46 +0800 Subject: [PATCH 2/5] raspi image: extend root partition on boot, install openssh-clients --- script/config/raspi_image/chroot.sh | 7 +++- script/config/raspi_image/extend-root.sh | 49 ++++++++++++++++++++++++ script/config/raspi_image/rpmlist | 2 + script/step/make_raspi_image.sh | 4 ++ 4 files changed, 61 insertions(+), 1 deletion(-) mode change 100644 => 100755 script/config/raspi_image/chroot.sh create mode 100755 script/config/raspi_image/extend-root.sh diff --git a/script/config/raspi_image/chroot.sh b/script/config/raspi_image/chroot.sh old mode 100644 new mode 100755 index 93f6859..9ab787f --- a/script/config/raspi_image/chroot.sh +++ b/script/config/raspi_image/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/script/config/raspi_image/extend-root.sh b/script/config/raspi_image/extend-root.sh new file mode 100755 index 0000000..1e23a3e --- /dev/null +++ b/script/config/raspi_image/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 diff --git a/script/config/raspi_image/rpmlist b/script/config/raspi_image/rpmlist index 26d14f4..3c6a98c 100644 --- a/script/config/raspi_image/rpmlist +++ b/script/config/raspi_image/rpmlist @@ -8,10 +8,12 @@ iproute iputils NetworkManager openssh-server +openssh-clients passwd hostname bluez pulseaudio-module-bluetooth +parted raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth diff --git a/script/step/make_raspi_image.sh b/script/step/make_raspi_image.sh index 3f5ce14..b29b844 100644 --- a/script/step/make_raspi_image.sh +++ b/script/step/make_raspi_image.sh @@ -143,6 +143,10 @@ make_rootfs(){ cp ${euler_dir}/LICENCE.* ${rootfs_dir}/usr/share/licenses/raspi/ cp ${euler_dir}/chroot.sh ${rootfs_dir}/chroot.sh chmod +x ${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 mount --bind /dev ${rootfs_dir}/dev mount -t proc /proc ${rootfs_dir}/proc mount -t sysfs /sys ${rootfs_dir}/sys -- Gitee From dd06de64ec363e675ed458ef48d4384923d08bd3 Mon Sep 17 00:00:00 2001 From: yafen Date: Tue, 12 Jan 2021 11:55:01 +0800 Subject: [PATCH 3/5] raspi: update ifup-eth0 to ifcfg-eth0 --- script/config/raspi_image/{ifup-eth0 => ifcfg-eth0} | 0 script/step/make_raspi_image.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename script/config/raspi_image/{ifup-eth0 => ifcfg-eth0} (100%) diff --git a/script/config/raspi_image/ifup-eth0 b/script/config/raspi_image/ifcfg-eth0 similarity index 100% rename from script/config/raspi_image/ifup-eth0 rename to script/config/raspi_image/ifcfg-eth0 diff --git a/script/step/make_raspi_image.sh b/script/step/make_raspi_image.sh index b29b844..78fd9d3 100644 --- a/script/step/make_raspi_image.sh +++ b/script/step/make_raspi_image.sh @@ -134,7 +134,7 @@ make_rootfs(){ #if [ ! -d $rootfs_dir/etc/sysconfig/network-scripts ]; then # mkdir -p $rootfs_dir/etc/sysconfig/network-scripts #fi - cp ${euler_dir}/ifup-eth0 $rootfs_dir/etc/sysconfig/network-scripts/ifup-eth0 + cp ${euler_dir}/ifcfg-eth0 $rootfs_dir/etc/sysconfig/network-scripts/ifcfg-eth0 mkdir -p ${rootfs_dir}/usr/bin ${rootfs_dir}/lib/udev/rules.d ${rootfs_dir}/lib/systemd/system if [ -d ${rootfs_dir}/usr/share/licenses/raspi ]; then mkdir -p ${rootfs_dir}/usr/share/licenses/raspi -- Gitee From b7d4ca08174b86eae85689e79d34c10f05270bc3 Mon Sep 17 00:00:00 2001 From: yafen Date: Mon, 18 Jan 2021 16:17:51 +0800 Subject: [PATCH 4/5] rsync rootfs instead tar --- script/step/make_raspi_image.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/script/step/make_raspi_image.sh b/script/step/make_raspi_image.sh index 78fd9d3..afed969 100644 --- a/script/step/make_raspi_image.sh +++ b/script/step/make_raspi_image.sh @@ -204,20 +204,11 @@ make_img(){ cp ${euler_dir}/config.txt ${boot_mnt}/ echo "console=serial0,115200 console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait" > ${boot_mnt}/cmdline.txt - if [ -f ${tmp_dir}/rootfs.tar ]; then - rm ${tmp_dir}/rootfs.tar - fi - pushd ${rootfs_dir} - rm -rf boot - tar cpf ${tmp_dir}/rootfs.tar . - popd - pushd ${root_mnt} - tar xpf ${tmp_dir}/rootfs.tar -C . - popd + rm -rf ${rootfs_dir}/boot + rsync -avHAXq ${rootfs_dir}/* ${root_mnt} sync sleep 10 LOSETUP_D_IMG - rm ${tmp_dir}/rootfs.tar rm -rf ${rootfs_dir} losetup -D pushd ${img_dir} -- Gitee From 9e9075ea2851b1ca467d65a8d8fe705a3814f6ee Mon Sep 17 00:00:00 2001 From: yafen Date: Sat, 23 Jan 2021 18:41:19 +0800 Subject: [PATCH 5/5] fix: can not find bluetooth device --- script/config/raspi_image/chroot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/config/raspi_image/chroot.sh b/script/config/raspi_image/chroot.sh index 9ab787f..2652fab 100755 --- a/script/config/raspi_image/chroot.sh +++ b/script/config/raspi_image/chroot.sh @@ -18,4 +18,5 @@ 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 +cd - +ln -s /lib/firmware /etc/firmware \ No newline at end of file -- Gitee