Wednesday, August 23, 2017

Auto-mounting external USB drive onto a linux OS

Yes, by default this will typically happen anyway.

However...

If like me and you have an app that starts up at boot time and needs access to a particular USB drive.... we find that in some cases the drive may not be accessible right at the moment our app needs it and so it fails to run as expected!

The fix???

Assuming you have the drive mounted at this moment, get a terminal and punch in..
$ cat /proc/mounts

Look through all the muck and find the drive of interest. For me it's...

/dev/sdb1 /media/mugwhy/blueDrive ext4 rw,nosuid,nodev,relatime,data=ordered 0 0

Yours will be different of course!!!

Take a copy of that to your clipboard!

Now launch your GUI Disk tool. Choose your drive from the list in the left. Now nosy around and look for the mount options. Make sure Automatic Mount is Off! Click OK and close the tool!

Now, in your terminal punch in...

$ sudo gedit /etc/fstab


You'll get a file loaded into a text editor.

At the end of the file add a comment such as...

# blah blah so I wont forget what the following is for...

then paste in the line from your clipboard!

Save the file and  re-boot!!

You-re done!!!

The drive should now get mounted at boot and before apps try to access it....

Note:
A small clue to let you know it's probably working.... Your computer may take a little longer to boot since it's now looking to boot from the USB drive (if it's bootable), then if not, boot will continue on as normal!  :)

Good luck!






No comments:

Post a Comment

Kotlin (Programming language)

Todo