Categoria: Tricks

Quick NFS on Raspberry

If for some reason you find problems with broken Samba sharing on Raspbian, or just want something faster and more transparent, there is the NFS alternative — which, at least for me, is cooler than Samba. To access it from Windows is a bit more involved, and I won’t cover it on this quickie, as I’m really only needing to access it remotely from another Linux machine anyway.

So, it was a bit tricky to get it running and mounting automatically, but after spending some time on Google and experimenting/resuming a lot of different random forum suggestions, I finally got it working nicely and also mounting automatically. Here I try to resume it in just a few steps (first on a Rasberry terminal):


sudo apt-get install nfs-kernel-server

Then open /etc/exports for editing:


sudo nano /etc/exports

And add this line to map the usb hdd that is there (you need to change the path to your mounted usb drive, of course):


/mnt/media01/Public 192.168.1.0/255.255.255.0(ro,sync,no_subtree_check,no_root_squash)

The first path is where I’ve an external usb hdd mounted on this Raspberry, and the mask after it allows all machines coming from 192.168.1.* (my internal network) to read from it normally through the network. I decided to mount it as read-only (ro flag). You should adapt these to your case.

To overcome the warning “NFS Server: Not starting: portmapper is not running” that happens on Raspbian, I needed to use this:


sudo update-rc.d rpcbind enable && sudo update-rc.d nfs-common enable
sudo service rpcbind restart
sudo /etc/init.d/nfs-kernel-server restart

instead of just restarting NFS. Check if the NFS server is properly running with this:


sudo /etc/init.d/nfs-kernel-server status

Ok, so if it’s now running properly on Raspbian, go to the Desktop Linux from where you want to access that Raspberry share, and install the common client:


sudo apt-get install nfs-common

Edit fstab to add the share on that machine:


sudo nano /etc/fstab

Then add the map to the share:


# maps to raspberry's music nfs
192.168.1.2:/mnt/media01/Public /media/Public nfs auto,user,ro,hard,intr 0 0

192.168.1.2 is my Raspberry ip, you should change that. Also do not forget to create the mounting point (/media/Public) locally.

This specific combination of Client and Server configuration should made it automatically mount the shared nfs drive for me at boot time. If you don’t want to reboot right now, you can mount manually with


sudo mount -a

In my case, I never turn the Raspberry off, so it’s always available. If your Raspberry is not going to be online 24/7, you may prefer to remove the “auto” flag from the fstab line, then always use the mount -a when you want to access it on a given session.

 

From the many places I visited, these were the more important for me to find a successful configuration:

1 – https://askubuntu.com/a/7124

2 – https://raspberrypi.stackexchange.com/questions/10403/nfs-server-not-starting-portmapper-is-not-running

3 – https://forum.manjaro.org/t/nfs-doent-mount-on-startup-with-kernel-4-13/34762/17


Solving Ubuntu stuck on Login Screen

After a simple apt-get update & apt-get upgrade, next time I booted Ubuntu 16.04LTS it was stuck on a login loop, not allowing me to enter the system normally. Searching on Google I found out that many people have had the same problem. I then tried almost everything that was suggested (except for some extremely risky ones which would not work anyway), but nothing fixed the problem for me.

In desperation I tried one thing that ended up working well, and I want to share my solution with you. First, at boot time (on that initial Grub boot selection screen), I chose the previous kernel to boot with. It booted normally, and I could now login to the system again. Then I went to http://kernel.ubuntu.com/~kernel-ppa/mainline and from the list found the latest Kernel available (it was v4.15.10 at this time), then downloaded these files:

linux-headers-4.15.10-041510_4.15.10-041510.201803152130_all.deb
linux-headers-4.15.10-041510-generic_4.15.10-041510.201803152130_amd64.deb
linux-image-4.15.10-041510-generic_4.15.10-041510.201803152130_amd64.deb

Note that those were two linux-headers (all and amd64, as I’m using 64bit Linux), plus the linux-image, all for the same 4.15.10 Kernel version. You may prefer to choose the low-latency Kernel but they’re really meant for some specific use cases of Linux, so I went with the standard generic one.

After getting the three files, I installed all them at once by typing inside their download directory:

sudo dpkg -i *.deb

Then rebooted. I don’t really know what exactly caused the login problem, or if what I did will solve that for everyone, but for me that fixed the login problem and I also ended up with the latest stable Kernel, while keeping my system intact. I don’t recommend blindly following most crazy suggestions you find out there (uninstalling parts of the system or installing more and more random packages). I believe that upgrading the Kernel was straightforward, did not add or remove any packages, and was safe because if it did not work, I could simply select another older Kernel at boot, and try something else again.

Good luck.


Quickly Install Samba on Raspberry (or any Linux, that is)

So, I wanted to quickly put some USB HDD shared on my network using a Raspberry Pi. This is something simple, but I wasted a bit of extra time to get working this time, so I’m posting here just in case I forget again in the future, or someone comes looking for the same quick…