Setup Raspbian on Raspberry Pi
This post explains how to install Raspberry Pi OS and set up a Raspberry Pi from scratch. You will need another computer with an SD (or MicroSD) card reader to write the image.
Note: This post has been updated for Raspberry Pi OS and Raspberry Pi Imager. Raspbian was renamed Raspberry Pi OS in 2020, and the old “download a
.zip, unzip the.img, then flash it with Win32 Disk Imager” routine has been replaced by the official Raspberry Pi Imager, which downloads and writes the image in one step and can pre-configure SSH, Wi-Fi, and your user account before the first boot.
Install Raspberry Pi OS
Write the Image with Raspberry Pi Imager
Raspberry Pi OS is the Raspberry Pi Foundation’s officially supported operating system. The easiest way to install it is Raspberry Pi Imager, available for Windows, macOS, and Linux.
Install and launch Imager, then:
- Click Choose Device and pick your Raspberry Pi model.
- Click Choose OS and select Raspberry Pi OS (the recommended build), or Raspberry Pi OS Lite if you want a headless, console-only system.
- Click Choose Storage and select your SD card.
- Click Next, and when prompted, open Edit Settings to pre-configure the install.
That last step replaces a lot of the manual fiddling the old workflow required. Under Edit Settings you can set the hostname, create your user account (the default pi user no longer ships enabled), join a Wi-Fi network, set the locale and timezone, and enable SSH. For a headless Pi, this means you can boot straight into a working, network-connected machine with no monitor attached.
Click Write, wait for Imager to download and flash the image, then move the card to your Pi. Connect power (plus a monitor, keyboard, and mouse if you are not going headless) and it will boot into Raspberry Pi OS.
Troubleshooting: No HDMI Output
Modern Raspberry Pi OS auto-detects displays, so you usually do not need to touch any video settings. If your monitor stays blank, you can force a safe HDMI mode by editing config.txt on the boot partition. On Raspberry Pi OS Bookworm and later this file lives at /boot/firmware/config.txt (it was /boot/config.txt on older releases):
hdmi_safe=1
hdmi_safe=1 enables a conservative, widely compatible HDMI mode, which is enough for most “blank screen” cases. The older hdmi_group, hdmi_mode, and config_hdmi_boost tuning is legacy and is ignored on Raspberry Pi 4 and newer, which drive HDMI through the KMS display driver.
Set Up the Pi
raspi-config
Most settings can be tweaked from a single tool called raspi-config. If you did not configure everything in Imager, run it from a terminal:
sudo raspi-config
The current menu is organised into these sections:
- System Options: hostname, password, boot behaviour, auto-login, and network-at-boot.
- Display Options: resolution, screen blanking, and underscan.
- Interface Options: enable SSH, VNC, SPI, I2C, the camera, and other peripherals.
- Performance Options: GPU memory split and, on supported boards, overclocking.
- Localisation Options: locale, timezone, keyboard layout, and Wi-Fi country.
- Advanced Options: expand the filesystem, switch the boot device, and other expert tweaks.
To set your timezone and language, go to Localisation Options. You no longer need to expand the filesystem by hand: Raspberry Pi OS resizes the root partition to fill the card automatically on the first boot. (If you ever need to do it manually, it lives under Advanced Options → Expand Filesystem.)
Use the arrow keys to move, Tab to jump to <Select> / <Finish>, and Enter to confirm.
Extend SD Card Life with tmpfs
SD cards have a finite number of write cycles. If you plan to run a Raspberry Pi 24/7, you can reduce wear by keeping frequently-written, disposable files in RAM instead of on the card.
tmpfs mounts a filesystem in RAM. To use it, add entries to /etc/fstab for the directories you want held in memory, then reboot so each mount is in place before services start writing. The kernel only consumes as much RAM as the files actually need, not the full size of the mount.
These are the locations Linux writes to most often, and a reasonable starting point for most setups:
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0
The size= parameter caps RAM usage so a runaway process cannot exhaust memory. noatime and nosuid improve performance and security, while mode= and gid= reproduce the permissions and group of the original directory.
Keep one caveat in mind: anything stored on a tmpfs mount is lost on reboot. In the example above, /var/log is wiped every time the Pi restarts, so do not put anything you need to keep across reboots on a tmpfs mount. If you want RAM-backed logs that still survive a reboot, log2ram buffers /var/log in RAM and periodically syncs it back to the card.
On recent Raspberry Pi OS releases, /run (and often /tmp) are already mounted as tmpfs by default, so you can drop those lines if they are present. With these settings in place, your SD card should last considerably longer. Enjoy your Raspberry Pi.
The Disqus comment system is loading ...
If the message does not appear, please check your Disqus configuration.