[Hampshire] Using NFS root with raspberry pi.

2023-10-10 Thread Tom Gamble via Hampshire
Hi,

On my Raspberry Pis I’ve had a few issues with SD Cards failing so thought 
there would be some mileage in using an NFS root.  So if an SD card fails I can 
just pop a new card in and my root fs will still be good. 

The research I’ve done more or less says 

On the NFS Server set up the directory that will be your nfs root fs copy the 
contents of the rootfs on the SD Card to the directory.
edit the the /etc/fstab to reflect the nfsmount.

Change the /boot/cmdline.txt from the default to 

console=serial0,115200 console=tty1 root=/dev/nfs 
nfsroot=NFSHOSTIP:/path/to/nfsroot,tcp rw vers=3 ip=dhcp rootfstype=nfs
elevator=deadline rootwait

Now when you boot from that SDCard it should have too on the NFS filesystem.

When I tried it the pi hung for a while and then spat out the error 
 
VFS: Unable to mount root fs via NFS

followed by a kernel panic. 

So to try and understand what i had done wrongly I put the codlin.txt back to 
default and booted using the the rootfs on the SD card. 
I was able to mount the NFSroot on /media/nfsroot using the command 

# mount -t nfs NFSHOSTIP://path/to/nfsroot /media/nfsroot

I also added the following line to /etc/fstab 

NFSHOSTIP:/path/to/nfsroot /media/nfsroot  nfs defaults 0 0 

that allowed the NFSroot to mount using mount -a

rebooting the Pi also resulted in the NFSroot getting mounted on /media/nfsroot

So I’m pretty sure that my nfs configuration is good. 

When booting from the the default cmdline.txt and mounting the NFS filesystem  

# grep rpc.mountd /var/log/syslog 

does not give any messages.

However,  attempting to boot NFSroot the message

Oct 10 12:37:06 NFSHOST rpc.mountd[628]: authenticated mount request from 
CLIENTIP for /path/to/nfsroot (/path/to/nfsroot)

(Obviously I have anonymised the hostnames and ipaddresses.)

Further research suggested that the solution that message was to add 
“no_root_squash” as one of the options to the /etc/exports line but that is 
there anyway. 

I’ve mostly worked with the Red Hat, Fedora and Centos distros so my Debian 
knowledge a bit limited by comparison also even though I’ve used NFS a fair bit 
I’ve never really had any problems with it till now.

Can anyone give me some pointers as to where I can look for more information on 
what is going wrong.

Oh I nearly forgot. I’m running Bullseye on both the NFS server and the Pi and 
they both have the same nfs versions. 



Cheers.
Tom.


-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Using NFS root with raspberry pi.

2023-10-10 Thread James Dutton via Hampshire
On Tue, 10 Oct 2023 at 13:04, Tom Gamble via Hampshire
 wrote:
>
> Hi,
>
> On my Raspberry Pis I’ve had a few issues with SD Cards failing so thought 
> there would be some mileage in using an NFS root.  So if an SD card fails I 
> can just pop a new card in and my root fs will still be good.
>

Hi,

I have not tried your approach before. I have only done something
called netboot.
This is where you boot without an SD card at all.
There are some hints on how to do it here:
https://raspberrytips.com/network-boot-with-raspberry-pi/
Now, I have not actually done it with a Raspberry PI, only with Linux
servers and embedded systems, but the principles are the same.
You set up a DHCP server, with parameters that tell it where to find
the linux kernel and initrd files etc. it then tftp gets them or http
gets them.
An interesting aspect of this, is that booting over a 1Gbps network is
actually quicker than booting from an SD card.
Also if the device crashes, as the files are not stored on the crashed
device, the files do not become corrupted at all, so it's really
helpful when doing kernel development on an embedded system. It not
only reboots quicker, but no files are corrupted, and you get to see
the last logs before it crashed.

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Using NFS root with raspberry pi.

2023-10-10 Thread Tom Gamble via Hampshire
Hi James,

Thank you for your response I do like the idea of booting over the network 
using PXE however I don’t currently have tufts server set up so was using NFS a 
what I thought would be a quick solution. 

Tell me if you set up the PI to PXE boot can you revery back to the Standard SD 
boot t it won’t PXE boot?

Tom.


> On 10 Oct 2023, at 21:14, James Dutton  wrote:
> 
> On Tue, 10 Oct 2023 at 13:04, Tom Gamble via Hampshire
>  wrote:
>> 
>> Hi,
>> 
>> On my Raspberry Pis I’ve had a few issues with SD Cards failing so thought 
>> there would be some mileage in using an NFS root.  So if an SD card fails I 
>> can just pop a new card in and my root fs will still be good.
>> 
> 
> Hi,
> 
> I have not tried your approach before. I have only done something
> called netboot.
> This is where you boot without an SD card at all.
> There are some hints on how to do it here:
> https://raspberrytips.com/network-boot-with-raspberry-pi/
> Now, I have not actually done it with a Raspberry PI, only with Linux
> servers and embedded systems, but the principles are the same.
> You set up a DHCP server, with parameters that tell it where to find
> the linux kernel and initrd files etc. it then tftp gets them or http
> gets them.
> An interesting aspect of this, is that booting over a 1Gbps network is
> actually quicker than booting from an SD card.
> Also if the device crashes, as the files are not stored on the crashed
> device, the files do not become corrupted at all, so it's really
> helpful when doing kernel development on an embedded system. It not
> only reboots quicker, but no files are corrupted, and you get to see
> the last logs before it crashed.


-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--