dd
We'll see how to flash the image of an OS into a microsd, we want a microsd because we're doing this for a raspberry pi.
discover mount point
run:
lsblk -p
This will list all the block devices, in other words (less accurate), it will allow us to know the name of the microsd we just connected.
See all the devices and filesystems listed? Good, now connect your microsd
run again:
lsblk -p
See the new device it just appeared. That's the one we are looking for, in my case it was at the end: /dev/mmcblk0
Now let's unmount the device partitions (if they are mounted, you will know this if they have a filesystem attached to them).
In my case these were mounted
umount /dev/mmcblk0p2
umount /dev/mmcblk0p1
flash it
this is the super command that does all the work. BE CAREFULL read the whole paragraph before running it
sudo dd if=<img-to-flash>.img of=/dev/mmcblk0 bs=4M conv=fsync status=progress
the important part is the of=, if you write another block different from the one we just discovered in the first step, you can erase the partition of the linux system you are using.
In other words make sure you write the device we just discovered, in my case /dev/mmcblk0.
Note that I'm not using the once we unmount, those are the partitions, and we need to specify the device.
Read the command twice before running it. you can find what the other thing mean here