1 export autoresize autoresize_unit
6 rootfs="$$(mount |grep -w / |cut -d' ' -f1)"
7 roottype="$$(mount |grep -w / |cut -d' ' -f5)"
10 /dev/mmcblk?p2) rootdev="$${rootfs%p2}";;
11 /dev/[sh]d?2) rootdev="$${rootfs%2}";;
15 before="$$(sfdisk --dump "$$rootdev")"
17 sfdisk --dump "$$rootdev" |sed '$$s;, size=.*,;,;;' \
18 | sfdisk --force "$$rootdev"
20 after="$$(sfdisk --dump "$$rootdev")"
22 if [ "$$before" = "$$after" ]; then
25 ext[234]) resize2fs "$$rootfs";;
26 btrfs) btrfs filesystem resize max /;;
27 nilfs2) nilfs-resize -y "$$rootfs";;
29 systemctl disable autoresize
37 define autoresize_unit :=
39 Description=Resize root filesystem during first boot
42 ExecStart=/opt/autoresize.sh
45 WantedBy=multi-user.target
51 _autoresize: ${CFGROOT}
52 mkdir -p "$${CFGROOT}/etc/systemd/system/"
53 printf '%s\n' "$$autoresize" >"$${CFGROOT}/opt/autoresize.sh"
54 chmod 755 "$${CFGROOT}/opt/autoresize.sh"
55 printf '%s\n' "$$autoresize_unit" >"$${CFGROOT}/etc/systemd/system/autoresize.service"
56 chroot "$${CFGROOT}" systemctl enable autoresize