Reflash using SD card

Seems like the tutorial above is not fully describing the simple answer to the question: “How do I reflash a Librem 5 without a PC?” Here’s a tutorial specific to that:

  1. Buy a micro SD card.

  2. Turn off your Librem 5.

  3. Remove the battery from your Librem 5. If you do not, your SIM card and micro SD card might be destroyed due to a known issue with Librem 5 shorting.

  4. Using the little metal poker stick that comes with the Librem 5, or a sufficiently long and thin paperclip, pop out your SIM card and micro SD card tray from the side of your device. [If you do this step prior to Step 3, your SIM card and/or micro SD card may be destroyed.]

  5. Now that you have your card tray removed, place the new and empty micro SD card onto the tray.

  6. Insert the tray back into your Librem 5.

  7. Insert the battery back into your Librem 5

  8. When the battery contacts the Librem 5, it immediately turns on the moment it sees the battery. Go ahead and finish booting (enter your LUKS encryption pass phrase if needed)

  9. Inside the Librem 5, using your favorite web browser, go to the following URL: Index of /librem5/images/

  10. Navigate the url until you find the version right for you. Crimson is the newer version, and Byzantium is the older stable version (more info on that is all over these forums if you search)

  11. Based on your Librem 5 version, pick the folder for you. Mine is the newer Evergreen style of Librem 5, so I always use the librem5r4 images (“revision 4”). Most people probably have that version of Librem 5. If your Librem 5 is older than spring 2023 when I got mine, perhaps you have an older revision. It will be in your email from Purism when the device was shipped to you.

  12. Pick the luks folder if you want the encrypted version of PureOS, or the plain version if you do not want your hard drive encrypted.

  13. Click the artifact/ folder.

  14. Now in that folder, click on librem5r4.img.xz or the similarly named .img.xz file so that it will download to your device. For example, you might download from https://storage.puri.sm/librem5/images/byzantium/2025.04/librem5r4/luks/artifact/librem5r4.img.xz if you are using Byzantium stable version, reading this in 2025, using an Evergreen version of the Librem 5, and you want a LUKS encrypted hard drive.

  15. Now that you have librem5r4.img.xz in your downloads folder, open Terminal app

  16. In the terminal, type cd Downloads or to whatever folder you saved the .img.xz file into using your web browser of choice

  17. Now in the terminal, if you type ls it should show a list of files. One of the files should be librem5r4.img.xz or whatever name your downloaded image has.

  18. Use unxz librem5r4.img.xz and wait for it to finish. When the command has finished, it will have uncompressed the Librem 5 image. This may use a substantial amount of storage space, possibly up to 6 GB. (I did this on a Librem 5 Liberty device that has 128 GB of main storage instead of 32 GB, so the 6 GB wasted on this download was not so painful. If you’re struggling with disk space on a 32 GB storage device, consider removing your stuff. You should already have your own backups, and at the end of the tutorial we will erase the device storage and reflash it anyway)

  19. Use ls -htlr librem5r4.img to see that the .img file was automatically created without .xz on the end of the name. It will say something such as 5.6 GB for the size if all is well.

  20. Use lsblk and/or df commands if you would like to inspect your system to review the device name of your SD card. In all likelihood, your SD card will show up as sda in these

  21. Now that you are confident that /dev/sda describes your SD card, issue the following command to erase all data on the SD card and replace it with the bootable Librem 5 PureOS image:

    sudo dd bs=10M status=progress if=./librem5r4.img of=/dev/sda
    
  22. This command will take some time to finish, since it is erasing all data on your SD card and replacing it with the 5.6 GB of the clean PureOS installation

  23. Once the command has finished, power off your Librem 5 normally.

  24. Hold the power button to boot the Librem 5 back on. As soon as the light flashes green, move your finger to the Volume Down key and hold it.

  25. After some delay, the phone should boot into a clean installation of PureOS. NOTE: Your phone is not flashed yet – we are booting from the SD card

  26. After entering the 123456 password - or no password if you did not choose LUKS – you should be welcomed to a totally clean PureOS Phosh home screen of a new install.

  27. If your SD card is a big one, and you plan to keep it the same for a long time, see Appendix: Creating an Extra Backup for notes on how you can backup your current OS install on your phone, creating an exact image of it that you could put back later if you don’t like how flashing goes. [You would have to do that now before flashing.]

  28. Repeat steps 9 to 19 of this tutorial while keeping the device powered ON in this “boot from SD card” state.

  29. Now your Librem 5 is running from the SD card and not the hard drive, but you have a file in the current directory called librem5r4.img. It’s time to flash the device itself with this file, which we do with the following command (Note that we are writing to mmcblk0, the eMMC internal storage this time, and not “sda” the SD card):

    sudo dd bs=10M status=progress if=./librem5r4.img of=/dev/mmcblk0
    
  30. When this command has completed, it should be safe to power off your device, then start it back up. This time do not touch the Volume Down button, and allow it to boot normally.

  31. After logging in through the default 123456 encryption key and pin number, you should be looking at the totally reset flashed PureOS Phosh homescreen – all without using a PC, just by flashing the Librem 5 to itself with itself!

Appendix: Creating an Extra Backup

While you are inside of the SD card boot, but before you flash your phone, if you want to create a backup of your phone that you could restore later, and if your SD card is much bigger than your phone, then you can use the following command (the name my-backup.img is replaceable – choose whatever name for the file you prefer):

sudo dd bs=10M status=progress if=/dev/mmcblk0 of=./my-backup.img

This will take some time, possibly multiple hours if you are on a 128 GB Liberty phone, because it will create a file containing the exact storage of the device even if the device is empty. As such, the newly created file will be 32 GB for a Librem 5, or will be 128 GB for a Librem 5 Liberty. [So your SD card must be bigger than that!]

The key intuition here is that when you flash your phone in the future, you can use this my-backup.img file as the input to flash from instead of librem5r4.img when flashing your phone again in this way in the future.

Given the time these backups take to create and to flash, I often like to do this step with the battery removed from the Librem 5 while it is connected to power. This may reduce heating on the device, offering it a pocket of air to dissipate heat into on the back instead of a battery that might be discharging and then charging back up periodically, or however that works.

2 Likes