software

How to load linux on raspberry pi? Do it from the sd or to usb

The Raspberry Pi has become one of the most popular microcomputers in recent times. A device, of just 40 euros, that works like a complete computer (and with a more than acceptable power). This computer is manufactured using free hardware, and designed to run Linux operating systems . But it does not have any flash memory to install an operating system, so to make it work we must choose between installing the system on a micro-sd or on a USB memory and start the RPi from it.

SD vs USB: which is better?

The Raspberry Pi is designed to boot, by default, from the micro-sd or from a normal SD (in the case of the first model). However, due to the fact that many users asked for the possibility of being able to boot from USB sticks, the company decided to enable this option. In one way or another, any Raspberry Pi model can boot from the memory card or from a pendrive . Of course, only the most modern models can do it through the network. However, it is not the best way to do it.

Many performance tests have shown that booting the system and using programs is much faster and smoother with a micro-SD than with a USB stick connected to a USB port. Using a flash drive on the Raspberry will make the microcomputer much slower than using a memory card, so it won’t be worth it.

What we can do is connect an external SSD (in the Raspberry Pi 4), since there are scenarios (such as using it as a web server or file server) in which it really improves performance, but many others in which the expense does not worth.

In the end, the best option, the one that will give us the best performance and with the least problems we will have is with a good quality micro-sd.

Install Linux on the Raspberry Pi with a micro-SD

This microcomputer is configured by default to boot the operating system found on the memory card. It does not matter if it is Raspberry Pi OS, LibreELEC, Lakka, RetroArch and even NOOBS. If we insert the memory card, and connect this micro-computer, it will boot from it by default.

All we have to do is download the operating system we want to use and save it to the memory card. We can do this, for example, using the Raspberry Pi Imager program, the easiest solution to install the system we want on the memory card, since it will take care of everything.

Boot the RPi system from USB

The truth is that having the micro-SD, there is no reason to want to boot the Raspberry Pi from other means. Micro-SD today are very cheap, and if we buy a high-quality one we will get amazing speeds. We can always carry several micro-SDs with us, one with each operating system, and use them as we want. There are no restrictions. But there are always old-fashioned users who prefer to use USB sticks, just like on a computer, to boot the operating system.

This can be done from the «Pi 2B» model, and depending on the model, the process may vary a bit. It should be noted that these methods usually also enable network boot.

Raspberry Pi 400

This is one of the last models manufactured to date. Its main purpose is to offer users a complete computer hidden inside a keyboard so that we only need a screen and a mouse to be able to use it.

In this model we don’t have to do anything special. We simply have to connect the USB memory to the computer and, using the “Raspberry Pi Imager” software, record the operating system we want on it. We connect it to the Pi 400, turn it on and voila, nothing more needs to be done.

Raspberry Pi 4B

In this model (another of the most recent), in some units it is activated by default while in others it must be activated by hand. To check if ours has it activated, what we must do is connect it, without micro-SD inserted, and check on the screen if the bootloader is equal to or greater than Sep 3 2020. If so, we do not have to do anything other than save the image to USB with the RPi Imager software, while if it is earlier we will have to update the bootloader.

We can do this from the RPi Imager, selecting the option ” Raspberry Pi 4 EEPROM boot recovery ” and creating a new micro-sd with the update (the program takes care of everything). Once ready, we start the micro-computer with said memory card connected and the bootloader will be updated. At the end, we check that everything is indeed correct, the version is Sep 3 2020 and that’s it.

Old models (2B, 3A +, 3B…)

On these models, USB boot is not enabled by default. Therefore, we will have to activate it ourselves manually in order to use it. The first thing we will need for these models is to prepare a micro-sd with Raspberry Pi OS (Raspbian) and boot, as always, from this storage medium.

Once inside, in the terminal, we will execute the following command:

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

Once the code has been executed, we restart the RPi with “sudo reboot”, and when starting we will verify that the change has been applied by executing:

vcgencmd otp_dump | grep 17:

If the output value is equal to “0x3020000a”, then we have already enabled USB boot on the Raspberry Pi.

Of course, we must know that the change made in the OTP bit is irreversible, it cannot be undone. What we can do is disable USB booting by removing the “program_usb_boot_mode” line from the config.txt so that we can only boot from USB again.

Booting from USB on the Pi 1, 2, and Zero

Lastly, older models based on the BCM2835 and BCM2836 chips also have a little ‘trick’ to do this. What we must do in this case is download the bootcode.bin file and copy it to the root of an SD or micro-SD formatted in FAT32. What the Raspberry Pi does in this case is load this file first, and within it are the instructions necessary to continue loading from a USB port.

Of course, we must bear in mind that in order to use this method we must always have the memory card inserted in the Raspberry Pi with this file. If we remove it, it won’t boot from USB at all.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button