Mounting USB drives quickly

A fstab entry makes mounting USB drives fairly painless
Created: 2019-01-13 Updated: 2019-05-25
I’ve got something I’m much happier with now: a Bash script called Mounty!

Do you want to mount and unmount USB drives as a regular user in Slackware (or other Linux distribution)?

This used to be my process:

<stick USB drive into computer>
$ lsblk
sdb ...
|-sdb1 ...
$ sudo mount /dev/sdb1 /mnt/usb-drive
$ # do stuff with drive using either `sudo` or `sudo -i`
$ sudo umount /mnt/usb-drive
$ # ooops, I'm still *in* /mnt/usb-drive
$ cd ~
$ sudo umount /mnt/usb-drive

I knew there had to be a better way, but in my defense, it worked and I probably only stick a USB drive into my computer about once a month.

Still, whenever I did this, it often seemed to be when I was about to rush out the door somewhere or somebody needed something transferred to a Windows PC quickly or whatever, so the awkwardness of the process was often quite frustrating.

So I finally set out to acquire a better process today.

fstab is not just for booting

It turns out, if you make the right entry in /etc/fstab, you can allow non-superusers to mount and access drives at any time.


# usb mounting goodness in my /etc/fstab:
/dev/sdb1        /mnt/usb         auto        rw,user          0   0

Let’s break this down:


This is always the device path for a USB drive when it is plugged into my system. Yours may not be the same.


This is the path where you can visit the mounted file system. This can be any directory you like, but it needs to exist first. Feel free to substitute usb for whatever directory you would like. I prefer short names for frequently used things.


The file system type - I’ve yet to have 'auto' fail on a USB drive


Mount as read/write and allow regular users to do it!

The final two 0 values say "don’t mark this device for dump (backup)" and "don’t check this device on startup with fsck."

By the way, how do you check which device path to use (in place of my /dev/sdb1)? Try lsblk to list block devices. Plug in your USB drive a couple times to confirm that it always appears as the same device.

Mounting as a regular user

Now that we have our entry in fstab, we can use a much shorter incantation to mount a USB drive:

$ mount /dev/usb

Since mount can find a fstab entry for that path, it doesn’t need the device path.

You can, of course, further shorten this with a shell alias or script. For now, just being able to mount the device as my regular user is a huge leap forward.

Note to self: Amazon Kindle

The Kindle is easily addressed with this:


# mkdir /mnt/kindle
# usb mounting goodness in my /etc/fstab:
/dev/sdb         /mnt/kindle         auto        rw,user          0   0


$ mount /mnt/kindle
$ cd documents