86

I'm sure this must be fairly simple but can't find it here.

How does one go from having a blank SD card to having an SD card that boots a Raspi?

2

12 Answers 12

95

You can do it from the command line as well. No need to install anything.

  1. Find the name of the device of the plugged in SD-card. For instance I typed ls -la /dev/sd* before and after plugging in the sd-card. I saw the date of /dev/sdc change and thus decided that that was the one.

  2. Find the place of the unzipped image, which was /home/username/Downloads/2012-10-28-wheezy-raspbian.img for me.

Type the following (mutatis mutandis):

sudo dd if=/home/username/Downloads/2012-10-28-wheezy-raspbian.img of=/dev/sdc

or with improvements suggested by other users:

sudo dd if=/home/username/Downloads/2012-10-28-wheezy-raspbian.img of=/dev/sdc status=progress bs=4M

and wait for the command to return. It may be quite a while, especially over usb2.

Resizing can be done from the Pi itself in the raspi-config program that starts automatically the first time you boot.

Be careful. Make absolutely sure the device name is that of the SD-card. If you replace it with the device name of your hard drive, your hard drive will be overwritten.

8
  • 19
    I prefer recognizing the drive name with the help of sudo fdisk -l. Commented Jun 4, 2013 at 18:47
  • 10
    Adding bs=4M to the dd can significantly improve performance. Commented Apr 16, 2014 at 19:36
  • 2
    Best answer here, no extra tools needed besides basic Linux commands. Commented Feb 15, 2017 at 20:33
  • 1
    7 years later I still tried to go with this answer but could not because I could not figure out what was the name of my SD card under dev. I wish there was an easier way to find out which device is which in dev.
    – scribe
    Commented Jul 17, 2020 at 21:42
  • 2
    you can also use lsblk -p to get a short and simple list of devices and their path (recommended from raspberrypi official installation documentation ) Commented Aug 25, 2020 at 21:31
43

On Ubuntu versions 14.04, 16.04 and 18.04, right click on the installer image and choose Open with disk images writer. Select your SD card unit and press Start.

6
  • 12
    the first of these should be the marked answer. With dd the potential to destroy some partition or disk is imo greater than with that GUI tool
    – erikbstack
    Commented Nov 24, 2014 at 12:25
  • It is not possible with brasero it dosen't know .img extension.
    – Chinmaya B
    Commented Aug 21, 2015 at 12:08
  • 5
    By far, the simplest solution on Ubuntu.
    – brunofitas
    Commented Mar 29, 2016 at 0:01
  • This method has the advantage of working on 15.10 also, but the drawback that it won't work for the NOOBS installer that many users will be interested in as NOOBS does not use a .img file. Commented May 11, 2016 at 20:26
  • On Ubuntu Xenial is it somehow not-very-clearly called "Image disk creation" even though it can also be used to write it back. Very nice trick! :D Commented Sep 7, 2016 at 23:52
23

Easy Install & Resize the SD Card on the Raspberry Pi on Ubuntu.

  1. First, open a terminal and install the ImageWriter and GParted utilities with apt-get:

    sudo apt-get install usb-imagewriter gparted
    
  2. Assuming you are starting with a fresh install, download the newest release from the Raspberry Pi download site.

  3. Extract the downloaded archive, and then open ImageWriter by typping in a console:

    sudo imagewriter
    
  4. Select the desired .img file and target device, in this case, debian6-19-04-2012.img, and /dev/mmcblk0

    enter image description here

  5. Once the image write has completed, the next task is to repartition the SD card. Note: this process can be done at any later as well, it is not limited to only during initial setup!

For 13.04 you can find packages here.

If you're interested on resizing your SD CARD, check the source of this answer

Source

6
  • 1
    I had trouble with this, eventually found that I needed sudo imagewriter in order to get it to write to my SD. Commented Jan 25, 2013 at 13:22
  • 6
    Sadly, usb-imagewriter is no longer available for Ubuntu 13.04 or higher because some fool decided it was "too slow" and took it out of the package repository. I've been trying other solutions, the dd tool is kind of scary but should work.
    – Milimetric
    Commented Apr 6, 2014 at 22:03
  • 1
    @Milimetric You can find packages for 13.04 here: launchpad.net/ubuntu/raring/+package/usb-imagewriter
    – LnxSlck
    Commented Apr 7, 2014 at 9:15
  • 1
    Thanks for the link LnxSlck, I kind of gave up on that route though. I tried downloading from launchpad and Ubuntu Software Center says "dependency can not be satisfied: hal". I would go down the rabbit hole but I've learned my lesson with Linux: stop at the first error. Otherwise you regret it 10 errors in :) xkcd.com/349
    – Milimetric
    Commented Apr 7, 2014 at 12:27
  • @Milimetric Remember that the fun in Linux is learning, even if you learn by mistake
    – LnxSlck
    Commented Apr 7, 2014 at 21:44
12

On 13.10 I couldn't get usb-imagewriter to install E: Unable to locate package usb-imagewriter.

I found that plain old gnome-disks command Disks from desktop worked. You can select the usb drive and have the option to Restore disk image.

1
  • Using xubuntu 14.04. This worked for me.
    – clyde
    Commented Jan 16, 2016 at 22:31
9

Those are all really great answers...

I like to add status=progress to the dd command:

sudo dd if=rasidiskimg.img of=/dev/mmcbl.. status=progress bs=4M

#it reports like so:
2037383168 bytes (2.0 GB, 1.9 GiB) copied, 198.548 s, 10.3 MB/s
9

Use Startup Disk Creator. It should be installed on Ubuntu by default. It worked for me very well.

3

Some answers mention usb-imagewriter but that doesn't exist anymore (at least on Ubuntu 16.04).

I used usb-creator-gtk, and that did the trick for me.

1
  • Yes, choose Disk Images instead of CD Images in the file selection menu to open .img files instead of .iso files. Commented Jul 12, 2022 at 16:57
2

In addition to Wilbert's excellent answer, in order to do this often, the following has the added benefit of compressing and uncompressing the image on the fly, and shows progress using pv (you may need to apt-get install pv):

I do a backup with:

sudo dd if=/dev/mmcblk0p7 | pv -c -N filesystem | \
gzip -c | pv -c -N compressed > backup/mmcblk0p7.img.gz

And a restore with:

cat mmcblk0p7.img.gz | pv -c -N compressed | \
gunzip | pv -c -N filesystem | sudo dd of=/dev/mmcblk0p7

Make sure to replace mmcblk0p7 with the partition you want to backup/restore.

1
  • cat can be combined with the pv command.
    – brianegge
    Commented Dec 27, 2023 at 19:33
1

Install an image to Rasperry Pi by cloning (sometimes called flashing, burning, restoring). If the image is compressed, extract it before cloning, or use a tool that can extract and clone.

dd (and cp and cat)

The basic tool for cloning is dd. You can also use cp or cat for the same purpose. But these three tools are risky, when used to clone, to write to a mass storage device, because they do what you tell them to do without questions. So if you tell them to wipe the family pictures ... and it is a minor typing error away. dd is sometimes nicknamed 'data destroyer'.

  • Yes you can use dd (or cp or cat) for this purpose, but double-check and triple-check that you know what you are doing, and that everything is exactly as it should be before you press the Enter key.

Safer tools

There are several tools, that help you clone from an image file or a compressed image file, and that provide more security. There is a 'final checkpoint' and the target device is 'seen' in such a way, that it is easy to identify and make sure, that it is the correct target device (not the drive where you store the family pictures).

  • Disks alias gnome-disks has a built-in cloning tool, that you use when you 'restore' from an iso file or image file to a mass storage device, for example an SD card for Raspberry Pi. Disks is built into Ubuntu, so you need not install it. Extract from a compressed image file separately before using Disks (because there is a bug in some versions, bug #1571255).

  • mkusb uses dd to clone. It 'wraps a safety belt' around dd. mkusb can also install directly from compressed image files, if compressed with gzip or xz ('file.img.gz' or 'file.img.xz'). Install and use mkusb according to the following links,

    help.ubuntu.com/community/mkusb

    Expansion and imaging from a compressed image file

    sudo add-apt-repository universe  # only for standard Ubuntu
    
    sudo add-apt-repository ppa:mkusb/ppa  # and press Enter
    sudo apt-get update
    sudo apt-get install mkusb mkusb-nox usb-pack-efi
    
1

Startup Disk Creator

Install the usb-creator-gtk package using the following command:

$ sudo apt install usb-creator-gtk

After installation, the new tool can be found under the name Startup Disk Creator:

Startup Disk Creator desktop item

Startup Disk Creator is pretty straightforward to use:

Startup Disk Creator use

0
  1. Open Disks from the unity launcher.
  2. Navigate to your SD card in the left pane by clicking on it.
  3. Next, click on the hamburger menu icon in top right corner.
  4. Select Restore Disk Image from the menu.
  5. In the subsequent popup window, next to the Image to Restore field, click on the open folder icon.
  6. Navigate to the OS image you want to boot and click open and finally click on Start Restoring.(OS image in this case will be a .img file which needs to be extracted from the .zip file which can be downloaded from the Raspberry Pi Website)

Wait for the process to finish.

Tested on Ubuntu 16.04

1
  • Duplicate answer
    – crypdick
    Commented Feb 25, 2023 at 15:16
0

When we have only an ubuntu 21.04 live cd and no internet, the stock application is:

gnome-disks

Click the sd card and the three dots and:

Restore Disk Image...

It is possible to go there also with right click on the .img file and:

Open with Other Application

Disk Image Writer
1
  • Duplicate answer
    – crypdick
    Commented Feb 25, 2023 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .