LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices



Reply
 
Search this Thread
Old 11-08-2012, 04:18 PM   #1
alarazr
Member
 
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?

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

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Hi,

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
Code:
# file /etc/udev/rules.d/52-usb-memory.rules
#USB-Stick
SUBSYSTEMS=="usb", KERNEL=="sd?1", ACTION=="add", RUN+="/usr/local/bin/mount-usb.sh"
And I have a little script /usr/local/bin/mount-usb.sh which mounts the devices
Code:
#!/bin/bash

# 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
fi
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.

Markus

Last edited by markush; 11-08-2012 at 05:52 PM.
 
Old 11-08-2012, 09:33 PM   #3
frankbell
Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Mageia, Mint
Posts: 8,244

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

This is the best explanation I've found on fstab: http://www.tuxfiles.org/linuxhelp/fstab.html

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: http://www.cyberciti.biz/faq/linux-f...-update-fstab/
 
  


Reply

Tags
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 11:28 PM.

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