Mount an external drive at boot time only if it is plugged in
You're all on the right trail. I've found a way that is a little more clean and better form.
The correct option to add in fstab
is nofail
, however, it needs to come after auto
. If you change it to noauto
, it will never mount during boot. If you add nobootwait
to the bootloader, you could potentially miss something serious, such as mounting the partition before fsck
finishes checking it, or not mounting a partition that is used in the boot process.
After making the above change, The system will start normally (and mount the volume) if the device is plugged in while the system is shutdown. It will also boot normally if the device is not present at boot time.
The only inconvenience is that if you connect the device while the system is running, depending on configuration (too many variables to test), the device may not mount immediately. This can be remedied with a simple mount -a
or mount /specific_device
or a reboot.
I had the same issue - I've done one extra step
If you use the nofail
option in /etc/fstab
, the system will look for your disk (and partition) at boot time. If the device is plugged, the filesystem will be mounted. If not, the boot will continue as normal.
See arch wiki: https://wiki.archlinux.org/index.php/Fstab
Example
UUID=XXXXXXXXXXXXXXX /myhdd ntfs auto,nofail,noatime,rw,user 0 0
I've tried to boot the system with and without the device plugged, and it works ok.
What I've not achieved is to automount when disk is plugged after boot (when isn't plugged at boot). I must use mount -a
as root to mount all again.
does the noauto option let the boot process continue?
it doesn't automatically mount if present, but it does get it known if present so a simple mount /jgdata works...then a scripted mount /jdata wouldn't need an output check, just catch the error and keep booting
edit: upon some further reading bootwait is probably a more correct option to pass...(usually used for network shares that might not be present until later in the boot process, but it might still cause a hang, idk)
and the mount script could be added like so: https://stackoverflow.com/questions/2062543/running-a-script-with-the-help-of-grub-and-menu-lst