0

I have a raspbian lite SD Card Image.

I have expanded the cmdline.txt file by the following line init=/usr/lib/raspi-config/init_resize.sh.

cmdline.txt

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes logo.nologo vt.global_cursor_default=0 rootwait quiet init=/usr/lib/raspi-config/init_resize.sh

On the first boot, I get the blue screen (see picture below) for 1-2 seconds.

"Resized Root filesystem. Restart in 5 seconds." (<- this is the right text; picture is only an example!)

enter image description here

But the filesystem is not expanded!

If I call the script (/usr/lib/raspi-config/init_resize.sh) by myself after boot, I get the following error:

enter image description here

1
  • Could you please post your answer as an answer?
    – Darth Vader
    Commented Dec 8, 2016 at 8:14

2 Answers 2

2

by posting this thread, I got the answer for my own question. So now here is my solution!

I saw that the /etc/init.d/resizefs_once script and /etc/rc3.d/S01resize2fs_once is missing, which is build by raspi-config (source: https://raspberrypi.stackexchange.com/a/56623/57858).

After baking the image, I have mounted the image again and add the /etc/init.d/resizefs_once file

#!/bin/sh
### BEGIN INIT INFO
# Provides:          resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO

. /lib/lsb/init-functions

case "$1" in
  start)
    log_daemon_msg "Starting resize2fs_once" &&
    resize2fs /dev/mmcblk0p2 &&
    update-rc.d resize2fs_once remove &&
    rm /etc/init.d/resize2fs_once &&
    log_end_msg $?
    ;;
  *)
    echo "Usage: $0 start" >&2
    exit 3
    ;;
esac

and the missing symbolic link: /etc/rc3.d/S01resize2fs_once

sudo ln -s /$PathToMountPoint$/etc/init.d/resize2fs_once /$PathToMountPoint$/etc/rc3.d/S01resize2fs_once

Now everything works!

Hope this manual helps someone else.

0

Thanks for Dominic answer I could make it work.

I had to change a couple things to make it work in Raspbian 9 though.

This is my final code

# restore expand filesystem on first boot
  cat > /etc/init.d/resize2fs_once <<'EOF'
#!/bin/sh
### BEGIN INIT INFO
# Provides:          resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 3
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO

. /lib/lsb/init-functions

case "$1" in
  start)
    log_daemon_msg "Starting resize2fs_once" && \
    resize2fs /dev/mmcblk0p2 && \
    update-rc.d resize2fs_once remove && \
    rm /etc/init.d/resize2fs_once && \
    log_end_msg $?
    ;;
  *)
    echo "Usage: $0 start" >&2
    exit 3
    ;;
esac
EOF
  chmod +x /etc/init.d/resize2fs_once
  systemctl enable resize2fs_once

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.