To enable autologin, raspi-config
does the following:
systemctl set-default multi-user.target
ln -fs /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]
cat > /etc/systemd/system/[email protected]/autologin.conf << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM
EOF
There's no easy way to make this happen before first boot but you can unpack the distribution onto a fresh SD card, mount the root filesystem on some other computer, make the changes, then re-pack the distribution.
For example:
unzip -p ~/Downloads/2020-08-20-raspios-buster-armhf-lite.zip | sudo dd of=/dev/sdd bs=4M conv=fsync status=progress
Remove and reinsert the sd card; the two filesystems will be mounted as /media/$USER/boot
and /media/$USER/rootfs
(by Ubuntu on the desktop). If not automatically mounted, mount them.
Change directory to .../rootfs
and execute the ln
and cat
commands above, after removing the leading slash from the pathnames (lest you edit your computer's files, rather than those on the sd card).