29

I need to mount usb flash drive to automatically during OS startup also tried

mount /dev/sdb2 /media 

but after rebooting not able to see mounted drive please suggest.

lsusb
Bus 001 Device 003: ID 0411:00a2 BUFFALO INC. (formerly MelCo., Inc.)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

df -h
/dev/sda1
/dev/sdb2
1
35

Edit your fstab via

sudo nano /etc/fstab

and add the line below

UUID=0e281f8d-1117-451d-9b1b-b07405a631bc /media auto nosuid,nodev,nofail 0 0

Replace the UUID in my example above with the UUID of your partition

sudo blkid /dev/sdb2 | awk -F'"' '{print $2}'

Note, the entry in your fstab doesn't mount the drive if it's not present during startup.

2
  • 5
    I have a question, If I want to mount every usb (with out specific UID)How can I change the fstab?
    – H.Ghassami
    May 27 '17 at 8:06
  • 2
    @H.Ghassami use /dev/sdXX instead of UUID=...
    – Matthieu
    Sep 16 '20 at 16:12
14

You can use Ubuntu Disks utility. Open the Dash and search for Disks.

Select your USB key in the menu on the left, click the gears and select Edit Mount options :

enter image description here

From here simply check : Mount at startup :

enter image description here

2
  • 2
    Thanks for the update I want to use it using command line, monitor is not connected with server to do this graphically interface. Oct 8 '15 at 14:21
  • 2
    Refer here then.
    – hg8
    Oct 8 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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