Deutsch   English   Français   Italiano  
<vmvm45$25d2c$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: The Natural Philosopher <tnp@invalid.invalid>
Newsgroups: comp.sys.raspberry-pi
Subject: Re: How to boot from SD but run from USB?
Date: Fri, 24 Jan 2025 09:22:13 +0000
Organization: A little, after lunch
Lines: 59
Message-ID: <vmvm45$25d2c$1@dont-email.me>
References: <nfra6l-cif1.ln1@q957.zbmc.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Jan 2025 10:22:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="5af49c680f799441de4f1696bcbc9123";
	logging-data="2274380"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18YG7qDVMJsi3HGqy0oxCLeLEVVVNWRDYw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:V/C3QKO80TiSCo2sc+wTjHbpuC8=
Content-Language: en-GB
In-Reply-To: <nfra6l-cif1.ln1@q957.zbmc.eu>
Bytes: 3074

On 23/01/2025 22:12, Chris Green wrote:
> Is it simply a matter of leaving /boot on the SD card and changing /
> to being a USB drive or does one need to edit something in /boot
> somewhere?

AFAICR what you do is simply edit a file and tell it that / is not where 
it thinks it is

But it depends on exactly what you want to happen

The boot process is as follows (I think: Others will correct If I've got 
it wrong)

The  Pi firmware looks on the SD card for a Vfat partition, and in there 
is a file called cmdline.txt

e.g.
console=serial0,115200 console=tty1 root=PARTUUID=778a9e44-02 
rootfstype=ext4 fs
ck.repair=yes rootwait noswap=1

That file tells the boot loader wher the root directory is to be found 
that it is to  grab the kernel off

the key thing is root=PARTUUID=

Now if the SD card does not have such a partition, the boot loader will 
look to see if e.g. a USB drive has, and use that instead.

Now on whatever partition it uses as the first stage root, it will have 
/etc/fstab
e.g.

proc            /proc           proc    defaults          0       0
PARTUUID=778a9e44-01  /boot/firmware  vfat    defaults          0       2
PARTUUID=778a9e44-02  /               ext4    defaults,noatime  0       1

And at this point the booting system may, if you want, mount an entirely 
different root filesystem and carry on.

So if you edit the /etc/fstab on the SD card, and change the PARTUUID to 
a different drive, it will mount that instead. And never touch the SD 
card afterwards.

The easy way to do that is to boot the thing as normal, edit the fstab 
file to match the ID of the  USB device and reboot, making sure that 
yiou have copied everything on te root partition of the SD card to the USB.

But frankly its almost always easier to install everything on the USB 
drive and remove the SDcard altogether.



-- 
There is something fascinating about science. One gets such wholesale 
returns of conjecture out of such a trifling investment of fact.

Mark Twain