Chapter 3 - Preconfigure the operating system¶
In this chapter, you will preconfigure the operating system to create a user account, enable SSH, and optionally set up the WiFi network on its first boot.
Steps¶
Access the boot partition of microSD card¶
If you haven't already, unplug the microSD card from your computer and plug it back in. This will allow the operating system to acknowledge the changes made to the microSD card.
Your operating system should automatically mount the microSD card. On macOS and Windows, you should see a single FAT32 partition named boot
or bootfs
. On Linux, you should see two partitions, one FAT32 partition named boot
or bootfs
and one ext4 partition named root
or rootfs
.
You can open the boot partition to access its files and folders.
Configure a user¶
To avoid any security issues, you will create a user account with a password for your Raspberry Pi.
Start by generating a password hash for the user account you want to create. You will need OpenSSH. OpenSSH is available in the Dev Container as well if you use Windows. Generate a password hash with the following command. You will be prompted to enter a password.
In a terminal, execute the following command(s). | |
---|---|
In the boot partition, create a file named userconf
(without any extension). Open the userconf
file and add the following lines. Replace <username>
with the username you want to create and <password hash>
with the password hash you generated.
userconf | |
---|---|
Save and close the file.
Set up the WiFi network¶
If you want to set up the WiFi network, you can create a file named wpa_supplicant.conf
in the boot partition.
Open the wpa_supplicant.conf
file and add the following lines. Replace the <iso-3166-1-country-code>
placeholder with the ISO 3166-1 country code (check the full list here, for Switzerland it's CH
), <network>
with the name of the WiFi network and <password>
with the password of the WiFi network.
Save and close the file.
Enable SSH¶
To enable SSH, create a file named ssh
(without any extension) in the boot partition.
Check the results¶
Your boot partition should look like this:
- This enables SSH on the Raspberry Pi.
- This creates a user account.
- This sets up the WiFi network.
Summary¶
Congrats! You have preconfigured the Raspberry for its first boot! You can unmount and unplug the microSD card from your computer.