D
D
Diman892020-01-02 16:00:44
ubuntu
Diman89, 2020-01-02 16:00:44

Is it possible to remotely overwrite a memory card?

There is a Raspberry Pi 3, installed in a place that is not easily accessible, on the memory card of which Ubuntu Server is installed. Is it possible in any way (by a script/command) to "reset" the installed OS (in case, for example, of an incorrect OS/software setup, when it is easier to reinstall the entire OS than to clean out the tails, or replace Ubuntu Server with some other distribution) ? And if possible, how?
The following script (or commands separately) comes to mind for installing MikroTik CHR on any VPS:

CHR_VERSION=6.37
INSTALLPATH=/dev/vda

apt-get update &&
apt-get install -y unzip wget pv &&
wget http://download2.mikrotik.com/routeros/${CHR_VERSION}/chr-${CHR_VERSION}.img.zip &&
unzip chr-${CHR_VERSION}.img.zip &&
echo u > /proc/sysrq-trigger &&
pv chr-${CHR_VERSION}.img | dd of=$INSTALLPATH &&
reboot

Maybe it can be modified?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Ilya Efimov, 2020-01-02
@A_M

Putting rpi in an hard-to-reach place is a shitty undertaking. Memory cards under the axis - consumables. Once it was required to roll up the controller under unify as a temporary crutch. The card died in 4 months.

K
Karpion, 2020-01-02
@Karpion

I do not understand the situation in which you are going to use the OS reset. Modern computers are made in such a way that the operating system can be damaged so that it does not boot at all - damage the bootloader, and that's it. And access via the network appears only after loading the kernel and working out a significant number of scripts.
The following seems like a reasonable option:

  1. The host's operating system is installed, which never gets under way.
  2. The virtual machine manager is installed.
  3. A guest operating system is placed inside the virtual machine. And in case of problems - start booting the guest system from the distribution.
Such a scheme will withstand any mistakes made in the guest operating system.
You can also connect to a computer KVM - access to the keyboard and screen via the network. And from there it will be possible to give a command to boot from an external medium where the distribution kit is located.
Some people modify the system like this:
Run a script that applies the changes, and after a specified time cancels them. If testing has shown that the changes are correct, they are finally made. The most common use of such a script is for FireWall rules.

D
Drno, 2020-01-03
@Drno

well, you can try the following option -
either booting via PXE in case of failure to boot from the card,
or booting with option 2 from a USB flash drive on which some kind of liveCD is already raised

R
Roman, 2020-01-24
@OlafAndvarafors

Your output is Docker.
Install the OS on the raspberry, docker on this OS and create a container (roughly speaking a virtual machine) with the OS you need. Do not touch the main OS under any circumstances, but with the one that is spinning in the container, you can do whatever you want, and when you decide to rearrange, delete the old container, and raise the new container from the image and that's it.
There is nothing complicated here. The docker documentation is good, there are a lot of videos about it on YouTube.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question