Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an external USB drive which I want to be mounted automatically on boot when it is plugged in. With the current settings in fstab, mount will try to mount it even when it is not available, which produces a filesystem error. Is there an option for an fstab entry to declare that it should be mounted only when available? My current entry is as follows:

UUID=myawesomeid /media/usb1 ext3 rw,async,user,auto 0 2

share|improve this question
    
is the space between user, auto intentional? afair that is bad fstab syntax. –  Baarn Jul 17 '12 at 9:47
    
It would help to know the specific distribution of linux, too. –  Baarn Jul 17 '12 at 9:49
    
The space wasn't intentional but simply a copy+paste error (will edit it), the distribution is ArchLinux. –  evnu Jul 17 '12 at 9:58

2 Answers 2

up vote 5 down vote accepted

You want the nofail mount option.

man mount

nofail Do not report errors for this device if it does not exist.

share|improve this answer
    
instead of writing the man mount bit as a comment I edited it in, hope that is OK for you :) –  Baarn Jul 17 '12 at 15:13

change the auto option to noauto. This will not mount the device on startup, while the user option will mount it the moment you try access it from your file manager, i.e. mount on demand.

UUID=myawesomeid /media/usb1 ext3 rw,async,user,noauto 0 2

More on fstab options here.

Alternatively

No need for a fstab entry when udev/dbus/hal can auto mount removable devices for you. See The Manual on setting one of these up.

One configuration I find helpful on minimalst WM's like Openbox, is to run an auto-mounting FM as a daemon to handle removable devices for you. One example is to include thunar --daemon in your startup script.

As the exter fs is ext3, it will contain permission bits. Suggest taking ownership of the device if you are not the owner already:

sudo chown -R $USER /media/usb1
share|improve this answer
    
With that option, it won't even try to mount the device although it might be there. But I want it to try. It should also be able to mount the device on calling mount -a, which is disabled with noauto. –  evnu Jul 17 '12 at 10:14
    
Correct, that would be called 'explicit mounting'. See my edit for alternative solutions. –  invert Jul 17 '12 at 11:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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