A quick, or if you will TL;DR version, step-by-step guide for quickly getting up and running with a Raspberry Pi with Raspberry Pi OS using the Lite release.
This is the way.
Preparing SD card with OS for a Raspberry Pi, the TL;DR version
Preparing a microSD card with an operating system image for your Raspberry Pi is easy. You definitely do not need any huge downloads of a fancy GUI tool just to prepare a SD card!
This is a short, to the point, non-GUI, quick start guide, on how to prepare a microSD card with the Raspberry Pi Operating System image for your Raspberry Pi.
- downloading the OS image
- extracting the image file
- writing the OS image to the SD card, from the command line.
- Configure the image, add a user, enable ssh, etc
As It Should Be Done.
Download the Raspberry Pi OS image
Download the release OS image you would like to use. The example below is for the 64-bit Lite release.
wget https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz
Write image to SD card
The only tool you need for writing the image to an SD card is a plain and simple dd. No need for any bloated GUIs.
Unpack the SD image file with unxz
The image file is compressed with xz, so first unpack the SD card image file with the unxz tool:
unxz 2022-09-22-raspios-bullseye-arm64-lite.img.xz
Now you have the raw 1:1 image file ready for writing.
Determine the SD card device node
This depends on what kind of SD card reader you are using, in our example we use an USB Multi card reader. The device name is probably something else on your system, change sdf in the example accordingly. Make absolutely sure you are using the correct device!!!
lsblk ... sdf 8:80 1 29,1G 0 disk ...
Or
lsblk -S
NAME HCTL TYPE VENDOR MODEL REV TRAN sda 0:0:0:0 disk ATA KINGSTON_SUV400S37240G D6SD sata sdb 3:0:0:0 disk ATA ST1000NM0011 PT0D sata sdc 4:0:0:0 disk ATA WD1002FBYS-12 0300 sata sdd 10:0:0:0 disk Seagate Expansion_HDD 1801 usb sde 8:0:0:0 disk ATA CT1000BX500SSD1 054 sata sdf 9:0:0:0 disk Multi-Reader_-0 0031 usb sr0 7:0:0:0 rom hp hp_DVD_RW_AD-7251H5 1H8D sata
Write the image to the SD card
Write the image to SD card with dd
dd if=2023-12-11-raspios-bookworm-arm64-lite.img of=/dev/sdf bs=4M status=progress
Re-read the SD card partition table with partprobe so your Linux system know how to use the freshly written information:
partprobe /dev/sdf
Additional preparations, mount the SD card
Mount the boot partition from the SD card
mount /dev/sdf1 /mnt
Add initial user(s)
The OS image does not come with a default user anymore. Or password. You need to add that yourself by creating a userconf file in the boot partition. Highly annoying if you are working headless. The example below adds a pi user with the password YourFavoritePassword.
(echo -n pi: ; echo 'YourFavoritePassword' | openssl passwd -6 -stdin) | sudo tee /mnt/userconf
You can add as many more users you like, with whatever username/password combo you like.
(echo -n another: ; echo 'YourOtherPassword' | openssl passwd -6 -stdin) | sudo tee -a /mnt/userconf
Enable SSH
touch /mnt/ssh
Unmount, insert card into the Pi and boot your Pi
Un-mount the boot partition
umount /mnt
Eject the SD card
eject /dev/sdf
Insert the SD card into your Pi and boot up.
After first boot
The images tend to be "old", so make sure you do the apt upgrade dance after the first boot:
sudo apt update && sudo apt upgrade -y