Sujet : Re: How to boot from SD but run from US
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.sys.raspberry-piDate : 11. Mar 2025, 04:42:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vqobf9$1m25v$2@dont-email.me>
References : 1 2
User-Agent : Pan/0.162 (Pokrosvk)
On Wed, 26 Feb 2025 17:45:00 +1300, Dave Vandermeer wrote:
Actually I did read somewhere that it is possible. Technically you
only need to use the SD card to boot to init, so modify your
/etc/fstab to change the location of your root partition to the
device of the USB drive.
The root volume (mounted on “/”) is the one volume that cannot be
mounted/dismounted directly in the normal way on a Linux system.
Instead, the kernel offers a special system call, pivot_root(2)
<
https://manpages.debian.org/pivot_root(2)>, for handling setup of the
root volume.
At boot time, the initial root volume is the contents of the initrd
(“initial RAM disk”) image loaded by the bootloader along with the
kernel. This contains, among other things, some minimal startup script
that interprets the “root=” option that was passed to the kernel as
its command line from the bootloader. At the end of initrd processing,
it finds this volume, mounts it on a temporary directory somewhere,
and uses pivot_root to swap that with the initrd root. The initrd
filesystem (which is not root any more) is now mounted on that
temporary directory and can be dismounted from it in the normal way,
and all further processing can continue with the new root filesystem
as “/”.
In a sense, the entry in /etc/fstab for the filesystem to mount on “/”
is redundant in that it can never be used: accessing it means being
able to open /etc/fstab in the first place, and you can only do that
if the proper “/” is already mounted.