LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 03: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, 04:51 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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 04:52 PM.
 
Old 11-08-2012, 08:33 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
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



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 07:12 AM
Slackware 12.2 automount external drives? Allamgir Slackware 3 08-21-2009 06:28 PM
How to automount windows drives in fc7 siddhi817 Linux - Newbie 1 05-07-2008 12:21 PM
Automount USB drives in KDE Xeratul Linux - Software 5 05-21-2007 04:03 PM
USB drives don't automount Ashrack Linux - Hardware 2 02-13-2007 01:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:59 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
Open Source Consulting | Domain Registration