I would like to be able to boot on a live linux contained in a usb key connected to my Raspberry PI, from the terminal of my primary Raspbian contained on the SD card.
The Pi4 can boot entirely from USB, if that is what you want, or you can do things like use chroot to run a separate userland from a different root filesystem, or do much the same thing by running that userland in a container.
In both cases the same kernel continues to be used; currently you cannot hot swap the kernel, meaning the one that boots is the only one in use until you reboot or shutdown. Also, the original userland will continue to operate in the background (this is not optional) and you can switch back and forth between them.
Something you can also do is indicate a different location for the root filesystem in /boot/commandline.txt
, in which case the kernel on the SD card is used but a userland from USB or where ever. However...
The goal is to be able to automate a clone of the SD card on a network storage from the live linux.
This is not necessary in order to clone the system in a useful sense, and in fact it's pointless, because again, you cannot completely shutdown the OS that runs from boot. So you might as well run the cloning process from there, or else just boot from USB (either entirely or via the cmdline.txt
method mentioned above).
See Can a Raspberry Pi be used to create a backup of itself?