Write Raspberry Pi OS on SD Card
This guide explains how to write Raspberry Pi OS onto an SD card using the dd command-line tool.
Warning: Using dd incorrectly can overwrite the wrong drive and cause permanent data loss. Double-check your target device before proceeding.
The Linux distribution used was Debian 12 (Bookworm), but it should work on any Linux distribution with the dd tool available.
Before starting, ensure you have a compatible SD card with a capacity above the Raspberry Pi OS image size and the Raspberry Pi OS image downloaded.
Finding the SD card
1. First option
For basic information about connected drives, you can use:
lsblk
Example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 224.6G 0 disk
├─sda1 8:1 0 476M 0 part /boot/efi
└─sda2 8:2 0 224.1G 0 part /
sdc 8:32 1 7.2G 0 disk
├─sdc1 8:33 1 256M 0 part
└─sdc2 8:34 1 1.6G 0 part
In this example:
/dev/sdais the system drive/dev/sdcis the SD card
2. Second option
For additional information about connected drives, you can use:
sudo parted -l
On a Debian/Ubuntu system, if parted command is not available, you can install it using:
sudo apt install parted -y
Example output:
Model: ATA INTEL SSDSC2BW12 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 120GB 120GB primary ext4 boot
Model: ATA KINGSTON SVP200S (scsi)
Disk /dev/sdc: 60GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 60GB 60GB ext4 primary
In this example:
/dev/sdais the system drive/dev/sdcis the SD card
Writing the image
Once you've identified your SD card, use dd to write the image:
sudo dd if=/path/of/the/image/raspios-bullseye-armhf-lite.img of=/dev/sdc bs=1024 status=progress
Command breakdown:
if=specifies the input file (Raspberry Pi OS image)of=specifies the output device (SD card)bs=1024sets the block size to 1024 bytesstatus=progressshows the writing progress
Successful write output example:
1957872640 bytes (2.0 GB, 1.8 GiB) copied, 730 s, 2.7 MB/s
1921024+0 records in
1921024+0 records out
1967128576 bytes (2.0 GB, 1.8 GiB) copied, 837.249 s, 2.3 MB/s
Best practices
- Always double check the device name before writing
- Use a system with minimal connected drives to avoid mistakes
- Back up any important data before proceeding
Resources
- Official Raspberry Pi OS Downloads
- DD Command Manual