I did not measure it, but I think it takes about twice as long to boot a fresh Raspbian Lite image than an image that has already been booted. I don't know why that's the case. I'm curious what happens during first boot.
2 Answers
There's a service that run only on the first boot, then disables itself. It's a Debian SysV style script in /etc/init.d
, resize2fs_once
. It does this:
log_daemon_msg "Starting resize2fs_once"
ROOT_DEV=$(findmnt / -o source -n) &&
resize2fs $ROOT_DEV &&
update-rc.d resize2fs_once remove &&
rm /etc/init.d/resize2fs_once &&
log_end_msg $?
There's a detailed description of resize2fs
in man resize2fs
. As the name implies, it is for resizing filesystems. This is actually the second step in expanding the filesystem to fill the SD card; the first is resizing the partition which contains the filesystem.
That's done via this kernel parameter in /boot/config.txt
:
init=/usr/lib/raspi-config/init_resize.sh
That tells the kernel to start the userspace with that shell script, rather than the default /sbin/init
. The script resizes the partition, removes that parameter, and reboots.
So, the "first boot" referred to above is actually the second boot, which uses the normative /sbin/init
that starts system services including resize2fs_once
. The real first boot of init_resize.sh
probably does not take more than a few seconds -- resizing a partition is trivial. Resizing a filesystem is more complex.
It's not clear from your question what you observed, but it might be because it gets booted twice the first time, once to resize the file system and again to start up "for real."