I have a USB drive mounted via /etc/fstab
on boot. I was wondering if there is a way to boot up the RPi and skip the mount process if the USB stick is not found. Right now if I don't put the USB stick into the RPi, it will search for 1min 30sec before going into emergency mode and locking me out of my RPi unless I put in the USB stick.
4 Answers
/etc/fstab
has a noauto
option which will prevent the configured device or partition from being mounted automatically upon boot.
$man fstab
The fourth field (fs_mntops).
This field describes the mount options associated with the filesystem.
...
noauto do not mount when "mount -a" is given (e.g., at boot time)
Usually, but not always, noauto
is paired with user
. In this way, an unprivileged user may mount the file system. So, an /etc/fstab
line something like this:
# <file system> <mount point> <type> <options>
UUID=xxxxx-xx-x /mnt/usb vfat noauto,user,rw
Will allow the USB memory stick to be mounted by a user ... but will not be automatically mounted at boot.
-
How would I automatically mount it but, if the USB is not found it moves on in boot? Commented Nov 28, 2017 at 16:11
-
Good answer. I think most PIs that run into emergency mode have either a problem with the
user
privileges being insufficient or with the boot sequence being too short.– eDonkeyCommented Jul 27, 2022 at 7:23
You should remove the offending line from /etc/fstab
and mount your USB stick using udev
rules. If you run a GUI, the auto-mount should already be handled by your file manager. If it isn't, or you're running headless, try installing a mount helper, e.g. usbmount
. Of course, you can also write a custom udev
rule manually.
-
Will tell you what my line of code is when I get home. Commented Nov 28, 2017 at 15:54
-
this it my line: UUID=xxxx-xxxx /mnt/usb vfat auto 0 2 . What i dont know anything about udev. Could you tell em something i could do? Commented Nov 29, 2017 at 20:57
-
try removing that line and running
apt-get install usbmount
as root Commented Nov 30, 2017 at 12:53
The nofail
option in /etc/fstab
will allow the drive to be skipped if it cannot be found despite it being listed with the auto
which is one of the values included in the default
setting for many file-system types...
This answers the OP comment on @RubberStamp 's answer.
-
Thanks for the help, I will just stick with my way though. Commented Dec 18, 2017 at 9:33
Thanks for all the help. I found out a way. All you have to do is DONT EDIT the /etc/fstab folder, make a new text editor file, and write mount -a (location point). Then save it as mount.sh and put it in your desktop.
Then in terminal type Sudo nano chmod -x mount.sh
Then type Sudo nano /etc/rc.local
At the bottom before exit code 0 type /home/pi/mount.sh
Save it, then reboot. The USB drive if present should automatically be mounted if plugged in before booting. If you forget to place your USB drive before booting, insert the USB drive and double click on the mount.sh file and click run in terminal. Very simple easy way.
-
Um, this is a bit of a convoluted way to do it - if you put in the
nofail
option thenmount (location point)
ormount (device name)
will mount the device at the location - and GUI tools will also pick up on the details recorded in/etc/fstab
. If you do not modify that file the normal boot up will still hang around for that 90 seconds if the device is not present IMHO.– SlySvenCommented Dec 18, 2017 at 10:24 -
👍 to be honest, the reason why I did this is I could also mount a USB by double clicking on the file to mount it. It helps if I forget to put in the USB. If I don't do the nofail option, that creates an extra layer of security:) It's basically like, if a special USB is not inserted, then don't boot. Commented Dec 18, 2017 at 19:18