1

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.

1

/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.

| improve this answer | |
  • How would I automatically mount it but, if the USB is not found it moves on in boot? – Darkest N2O Nov 28 '17 at 16:11
1

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.

| improve this answer | |
  • Will tell you what my line of code is when I get home. – Darkest N2O Nov 28 '17 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? – Darkest N2O Nov 29 '17 at 20:57
  • try removing that line and running apt-get install usbmount as root – Dmitry Grigoryev Nov 30 '17 at 12:53
1

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.

| improve this answer | |
  • Thanks for the help, I will just stick with my way though. – Darkest N2O Dec 18 '17 at 9:33
0

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.

| improve this answer | |
  • Um, this is a bit of a convoluted way to do it - if you put in the nofail option then mount (location point) or mount (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. – SlySven Dec 18 '17 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. – Darkest N2O Dec 18 '17 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.