Reflash using SD card

You’ve posted something similar before, and then, as now, I am not clear on just what you did. If you are dd’ing the image from the SD card aren’t you using a file that is in use as the input to dd?

If anywhere in either very long post you had posted the exact dd command then everything would be clear. Usually detailing a general dd operation there can be a problem giving device names in linux because hardware configuarations can vary, but in the case of dd from SD card to eMMC under PureOS on a librem 5, all the device names should be fixed.

One thing I wondered about when you first posted about this is whether you epanded the image on the SD card to fill it, then mounted the card on a computer and copied the image as a file onto the mounted card and then put the card in the L5, booted from the card and dd’d the image file to the eMMC. That seems more complicated than you implied.

So I ask, aren’t you using an active partition as an input to dd?

1 Like

In my most recent case using this, I downloaded the .img, then according to bash_history did this:

sudo dd if=./librem5r4.img of=/dev/sda bs=10M status=progress

This overwrote the SD card with a bootable partition. Upon booting, it automatically expanded to fill the card. It’s a terrabyte card, so it is infinitely big relative to everything else.

Once booted from the SD card, my bash history shows the following:

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

At this point, I removed the SD card from the device, and put it into a different new device I wanted to replace my daily driver with.

Then, I booted the SD card – same partition, new hardware – and ran the opposite of the prior command:

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

(note that if and of are reversed.)

The result of the operation is that the eMMC on the new device matches the eMMC on the old device, having flashed to be its direct replica. And this was accomplished from L5 without using the laptop, from what I recall. (I don’t have timestamps and the first command actually is in my bash history a whole bunch of times, flashing multiple SD cards from the handset. But I probably did it all without PC, because why not.)

Sorry that I omitted the commands in my other post. The point of what I was saying was moreso that learning to use dd in general is advantageous, so it’s possible that posting explicit commands is contrary to that and encourages users to think of dd as a line to copy rather than an idea for something useful to use in any direction.

Edit: Although my above .bash_history is specific to doing a transfer from an old device to a new device, a user could apply the same principle to flash their Librem 5 with no additional hardware beyond the SD card. The difference would be to omit the middle command – don’t clone eMMC. And instead, redownload librem5r4.img from Purism on the SD card storage that we’re booted from, then write it onto the (not currently in use) eMMC while the SD card’s OS is running.

4 Likes

As a general comment about any such instructions, it is important to be clear about which device is executing the shell command - since we are “all” using Linux “everywhere” :wink:. So, let’s say that we are talking about a single phone scenario (what most customers would face), and let’s say two different situations:

a) the phone is still perfectly bootable but needs reflashing for whatever reason

b) the phone is borked and won’t boot any more (e.g. bad LUKS passphrase set, but could be many other different scenarios) and hence needs reflashing. (I guess in this situation, and assuming no other computer is available, you would have had to prepare the µSD card in advance, which wouldn’t be a bad idea to have available.)

3 Likes