View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-08-2012, 04:18 PM   #1
Registered: Jul 2012
Location: UK
Distribution: Debian x64
Posts: 65

Rep: Reputation: Disabled
How can I automount my drives in Debian?

Hey all.

If I try to access my USB drives, Windows partition or external HDD, I get a 'Not Authorized' message in pcmanfm. I can sudo mount /dev/sda2 /media/Windows and it works fine, but how can I make it do this automatically?

Old 11-08-2012, 05:51 PM   #2
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,976

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850

there are at least two ways to achieve this. The first would be to include the drives into your /etc/fstab file. Read the manpage for fstab, you will find the necessary information there (I've never used this feature and cannot help here).

The second way would be to use udev-rules. I have an udev-rule for my USB-memory-sticks
# file /etc/udev/rules.d/52-usb-memory.rules
SUBSYSTEMS=="usb", KERNEL=="sd?1", ACTION=="add", RUN+="/usr/local/bin/"
And I have a little script /usr/local/bin/ which mounts the devices

# USB-Stick mounten
sleep 5
device=`dmesg | grep -e sd.: | tail -n 1 | sed -n 's/.*sd.:\s\+\?\(.*\)/\1/i p'`
name=`dmesg | grep -i product: | tail -n 1 | sed -n 's/.*product:\s\+\(.*\)/\1/i p' | sed -n 's/\ /_/g p'`

if [ ! -d /media/$name ]; then 
    mkdir /media/$name
mount /dev/$device /media/$name
This solution doesn't set any permissions, root is the owner of the devices and the normal user has only read-permission. But one can easily change this with the udev-rule.


Last edited by markush; 11-08-2012 at 05:52 PM.
Old 11-08-2012, 09:33 PM   #3
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Mageia, Mint, FreeBSD
Posts: 9,830
Blog Entries: 6

Rep: Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944Reputation: 1944
I normally put them in fstab.

This is the best explanation I've found on fstab:

It's easier if you use the UUID, which I think post-dates that article. That ensures that they always mount to the same mountpoint.

Here's a good explanation of how to use the UUID to mount a device in fstab:


automount, debian, externalharddrive, pcmanfm, usbdrive

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can't get autofs to automount CD Drives bret381 Linux - Newbie 2 12-20-2009 08:12 AM
Slackware 12.2 automount external drives? Allamgir Slackware 3 08-21-2009 07:28 PM
How to automount windows drives in fc7 siddhi817 Linux - Newbie 1 05-07-2008 01:21 PM
Automount USB drives in KDE Xeratul Linux - Software 5 05-21-2007 05:03 PM
USB drives don't automount Ashrack Linux - Hardware 2 02-13-2007 02:22 PM

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration