petepots
Posts: 64
Joined: Mon Sep 08, 2014 9:19 am
Location: Surrey, UK

bad fstab file, can you start the pi

Thu May 26, 2016 11:14 am

Guys

A simple question, say you make a mistake or have a network drive that has not come up to speed or not on line and in the code of fstab you have automount for example:

How can you start the pi to correcct the errors without using fstab

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: bad fstab file, can you start the pi

Thu May 26, 2016 11:36 am

I don't think it should prevent you from booting, it might just pause booting for a minute so the network can "time out", but it should give you a login prompt at the end.

MikeDK
Posts: 86
Joined: Thu Mar 19, 2015 12:01 pm

Re: bad fstab file, can you start the pi

Thu May 26, 2016 12:48 pm

that's why i like to use autofs for network and usb... ;)

mounts defined via autofs are mounted only if someone on the system wants to access data on them


regards,
MikeDK

petepots
Posts: 64
Joined: Mon Sep 08, 2014 9:19 am
Location: Surrey, UK

Re: bad fstab file, can you start the pi

Fri May 27, 2016 12:15 pm

Thank you Topguy and MikeDK

Mike I will try what you said, its just if I put on the Pi and network drive at the same time the pi will fire up first, and also if I wanted to do work on the pi and not bother with the network drive I wanted to be sure the pi would continue to boot.

So in the fstab file I put:

Code: Select all

//[my ip address]/Peter /home/pi/wdmycloud cifs username=[me],password=[guess haha],uid=1000,gid=1000,iocharset=utf8,autofs 0 0
Now doing this does not mount the drive

Thanks again Guys

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: bad fstab file, can you start the pi

Fri May 27, 2016 1:08 pm

For a local drive that may or may not be available via USB I use: "nofail,x-systemd.device-timeout=10"
- nofail: if the USB drive is not present, boot will pause for a while and continue. Without this option the system would go to failsafe mode if the drive was missing.
- x-systemd.device-timeout=10: the length of the pause in seconds. 0 means infinite, not good. A very small value didn't work for me because there is a race condition (...) with fsck disk checking at boot.
To sum up: on this system, boot will take X seconds if the drive is connected, and X+10 seconds if it is not. Boot will succeed in any case.

Option "x-systemd-automount", the one y'all talking about in this thread is a bit treacherous in my experience. I think it tries to do a "hard" mount when you access the path, meaning it locks-up until the mount has succeeded. Or it is a soft mount with a very long timeout indeed. I don't know if you can set an automount timeout in systemd.
The real McCoy is the automounter "autofs v5", in package autofs. It is a bit tricky but once you've wrapped your head around the way this works, you'll see it does more than systemd.

Also, stay away from option "nobootwait", it does lockup the machine...
I'm writing this looking at a machine that has autofs 5, I'm pretty sure I've tested various combinations of autofs, systemd-automount, nofail, etc. to make sure it boots up to normal state within a reasonable time. My reco for volatile USB devices is to use nofail.
Last edited by epoch1970 on Sat May 28, 2016 1:30 am, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

petepots
Posts: 64
Joined: Mon Sep 08, 2014 9:19 am
Location: Surrey, UK

Re: bad fstab file, can you start the pi

Fri May 27, 2016 9:05 pm

Yes I could try this written by KenR. I would put this in the fstab

if ! ( ping -c 1 My_ROUTER_IP ) > /dev/null
then
echo "network is NOT up so wait"
sleep 2
else
echo "Network is UP"
sudo mount -a
break
fi

I just dont want to break the pi, I just want to break out of the program if say the network was down

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: bad fstab file, can you start the pi

Sat May 28, 2016 1:25 am

Well, first you can't put what you want in Fstab. This file has a mandatory format because it is being parsed by programs. Fstab is a static file, you can't put a program in it.
Second the program you propose allows to delay boot by 2 seconds. That is not a very powerful remedy to the variety of boot circumstances. For example, what if the file server is powered off?

I would recommend you try and exhaust the possibilities offered by mount options in fstab, select the best combination and then, perhaps, add some secret sauce as a script.

If you add something to /etc/rc.local, this will get executed dead last at boot time. In other words, the system is fully up when rc.local is executed. (But I still don't think it is the place to put a mount. Mounts belong to fstab or to autofs and a handful of other programs.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

petepots
Posts: 64
Joined: Mon Sep 08, 2014 9:19 am
Location: Surrey, UK

Re: bad fstab file, can you start the pi

Tue May 31, 2016 11:27 am

epoch1970 wrote:Well, first you can't put what you want in Fstab. This file has a mandatory format because it is being parsed by programs. Fstab is a static file, you can't put a program in it.
Second the program you propose allows to delay boot by 2 seconds. That is not a very powerful remedy to the variety of boot circumstances. For example, what if the file server is powered off?

I would recommend you try and exhaust the possibilities offered by mount options in fstab, select the best combination and then, perhaps, add some secret sauce as a script.

If you add something to /etc/rc.local, this will get executed dead last at boot time. In other words, the system is fully up when rc.local is executed. (But I still don't think it is the place to put a mount. Mounts belong to fstab or to autofs and a handful of other programs.)
Thank you so much for your help, there does not seem to be a definitive answer to this At the moment all I do is to start the pi, wait till the network drive is up and running then run a sudo mount -a command, job done, but really thats not the right answer but it works

MikeDK
Posts: 86
Joined: Thu Mar 19, 2015 12:01 pm

Re: bad fstab file, can you start the pi

Tue May 31, 2016 11:52 am

petepots wrote:Thank you Topguy and MikeDK

Mike I will try what you said, its just if I put on the Pi and network drive at the same time the pi will fire up first, and also if I wanted to do work on the pi and not bother with the network drive I wanted to be sure the pi would continue to boot.

So in the fstab file I put:

Code: Select all

//[my ip address]/Peter /home/pi/wdmycloud cifs username=[me],password=[guess haha],uid=1000,gid=1000,iocharset=utf8,autofs 0 0
Now doing this does not mount the drive

Thanks again Guys
Hi again ... I will try to give you an example configuration of an autofs setup... (do the following commands as root user):

first, install autofs with

Code: Select all

apt-get update
apt-get install autofs
then create a credentials file:

Code: Select all

touch /root/.credentials.peter
chmod 600 /root/.credentials.peter
now edit the file and put your login information into it:

Code: Select all

username=[me]
password=[guess haha]
edit the file /etc/auto.master and add following line after the first comment block:

Code: Select all

/volume /etc/auto.volume
create the file /etc/auto.volume:

Code: Select all

nano /etc/auto.volume
with this content:

Code: Select all

Peter -fstype=cifs,rw,credentials=/root/.credentials.peter ://[my ip address]/Peter
now some final stuff:

Code: Select all

mkdir /volume
ln -s /volume/Peter /mnt/Peter
service autofs restart
Now, if everything is correct (please forgive any typos, I was writing this from memory), then a simple "cd /mnt/Peter" will mount the drive.
When booting the pi, it will not mount the drive ... it will be mounted only if someone is accessing the mount point on the pi...


regards,
MikeDK

petepots
Posts: 64
Joined: Mon Sep 08, 2014 9:19 am
Location: Surrey, UK

Re: bad fstab file, can you start the pi

Thu Jun 02, 2016 3:04 pm

Thank you very much MikeDK

I will try that, very kind of you to spend your time doing that for me

Return to “Troubleshooting”