I don't understand the fascination with using rc.local
to mount a drive, but it should work as long as you remember there are two different users involved: the root user for rc.local, and you (whoever you are, you didn't say). Here's a link that discusses this, but I haven't tried it.
I typically operate as user pi
, and I make an entry in fstab
for my 16 GB SanDisk USB drive. Here's what I do:
man fstab
, and read it... In perusing man fstab
, some of the documentation available online and advice on fstab
that's published, we soon recognize there are some decisions to be made - options to be selected. There are six (6) fields in a fstab
entry. Let's do them in order:
fs_spec
This is the most critical field. The oft-used specifications here are device node (e.g. /dev/sda1
), LABEL
and UUID
. There are several other specs, but these 3 are sufficient for now. Some advocate using the UUID
spec and point out that it is more unique and therefore safer than the device node. But we're going to use the LABEL
specification, and here's why: We can set it; we have control over the value of LABEL
, whereas we have no control over the so-called UUID
. In fact, for all types of FAT
partitions, they do not have a true UUID
. The identifier shown as UUID
by lsblk --fs
isn't actually a UUID
at all! This is a rather murky back alley.
fs_file
This is mount point we used earlier; in our case: /home/pi/mntThumbDrv
fs_vfstype
This is the file system type of the drive (or partition) to be mount
ed: vfat
fs_mntops
A comma-separated list of options. We'll use: rw,user,nofail
(no spaces) which will tell the OS that the drive is read & write, users may mount the drive, and no error will be flagged if the device is not present at boot time (and stop the boot process!).
fs_freq
A flag that determines if the file system will be dump
ed; 0
for our case
fs_passno
A flag that determines if the file system will be checked by fsck
, and the order it's to be checked; 0
for our case
After working our way through all the fields, our fstab
entry looks like this:
LABEL=SANDISK16GB /home/pi/mntThumbDrv vfat rw,user,nofail 0 0
Try this, and let us know if you run into issues. You may also wish to take a look at my GitHub page for more technical drivel on this subject. Also, keep in mind that much of this is now done under control of systemd
instead of mount
, but AFAIK the role of fstab
and the functionality of mounting a disk is similar to mount
.