| 221 | For automatically resizing the rootfs on boot you can create a one-shot init script before you unmount the filesystem above: |
| 222 | {{{#!bash |
| 223 | cat << EOF > /etc/init.d/resize2fs_once |
| 224 | #!/bin/sh |
| 225 | ### BEGIN INIT INFO |
| 226 | # Provides: resize2fs_once |
| 227 | # Required-Start: |
| 228 | # Required-Stop: |
| 229 | # Default-Start: 2 3 4 5 S |
| 230 | # Default-Stop: |
| 231 | # Short-Description: Resize the root filesystem to fill partition |
| 232 | # Description: |
| 233 | ### END INIT INFO |
| 234 | |
| 235 | . /lib/lsb/init-functions |
| 236 | |
| 237 | ROOT=\$(cat /proc/cmdline | sed -e 's/^.*root=//' -e 's/ .*\$//') |
| 238 | |
| 239 | case "\$1" in |
| 240 | start) |
| 241 | log_daemon_msg "Starting resize2fs_once" && |
| 242 | resize2fs \$ROOT && |
| 243 | rm /etc/init.d/resize2fs_once && |
| 244 | update-rc.d resize2fs_once remove && |
| 245 | log_end_msg \$? |
| 246 | ;; |
| 247 | *) |
| 248 | echo "Usage: \$0 start" >&2 |
| 249 | exit 3 |
| 250 | ;; |
| 251 | esac |
| 252 | |
| 253 | EOF |
| 254 | chmod +x /etc/init.d/resize2fs_once |
| 255 | systemctl enable resize2fs_once |
| 256 | }}} |
| 257 | |
| 258 | |