LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 05-10-2006, 07:24 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 48
automounting CD-ROMs USB drives


Hi,

I have debian base install(sarge). What is the best way to mount CD-ROMS/USB jump drivers automatically when the system starts? Does the answer lies in .bashrc or .bash_profile?

Is there any tool(light weight) which does this job? What abt pmount?

Again, I am not planning to have GNOME or KDE or any other Graphical Environemnt. I just have text base login console.

Thanks
 
Old 05-10-2006, 07:28 PM   #2
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Rep: Reputation: 45
Hats off to those who can live without the GUI. :bows:
 
Old 05-10-2006, 07:34 PM   #3
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
The traditional way of automounting is just to edit /etc/fstab. Or you can use udev and autofs ... deb-admin article 126, and followup article 127.
 
Old 05-11-2006, 06:13 PM   #4
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by Simon Bridge
The traditional way of automounting is just to edit /etc/fstab. Or you can use udev and autofs ... deb-admin article 126, and followup article 127.
Ok I tried the /etc/fstab and here are the contents of my fstab but still it does not work. I have seen this working on other system but on my current system it does not. I am using Debian Sarge.
Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda12     /          ext3    defaults,errors=remount-ro 0  1
/dev/hdb        /media/cdrom0   iso9660 ro,user,auto    0       0
Is it something related to udev? I have hotplug,hal,udev installed on my system? I hope one of these packages are not coming in the way.
 
Old 05-11-2006, 07:25 PM   #5
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hdb1       /               ext3    defaults,errors=remount-ro 0       1
/dev/hda1       /boot           ext3    defaults        0       2
/dev/hda2       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  vfat    rw,user,noauto  0       0

\
My hdc is a CD/DVD combo.
You need the "noauto" flag to stop the cd mounting at boottime (when there may not be media in it). My system is Ubuntu Dapper - but the base system should behave similarily to debian.

I gave you a couple of links about how to automount using udev - and another about how to use autofs (which is what you want) for the same. Have you tried the suggestions there?
 
Old 05-11-2006, 07:37 PM   #6
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by Simon Bridge
Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hdb1       /               ext3    defaults,errors=remount-ro 0       1
/dev/hda1       /boot           ext3    defaults        0       2
/dev/hda2       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  vfat    rw,user,noauto  0       0

\
My hdc is a CD/DVD combo.
You need the "noauto" flag to stop the cd mounting at boottime (when there may not be media in it). My system is Ubuntu Dapper - but the base system should behave similarily to debian.

I gave you a couple of links about how to automount using udev - and another about how to use autofs (which is what you want) for the same. Have you tried the suggestions there?
Thanks for looking into this, but I don;t understand one thitng. If I give the flag 'noauto' then my CD-ROM drive won't boot automatically right? And I want the exact opposite of this. I won;t my CD-ROM drive to mount automatically. I have a CD in my CD-ROM drive during the boot.

Yes, I can try the udev/autofs way but frist I would like to resolve the issue with /etc/fstab because that is the most basic/common methods for console based system. Again, I may be wrong in what I am saying.

Your suggestions are most welcome.

Thanks
 
Old 05-11-2006, 07:48 PM   #7
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,807

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by kushalkoolwal
If I give the flag 'noauto' then my CD-ROM drive won't boot automatically right?
The 'noauto' flag means that the drive will not be mounted when you start the machine. It has nothing to do with automatic mounting.

I agree with Simon Bridge. You should set up autofs. It is truly what you want.

Last edited by rkelsen; 05-11-2006 at 07:54 PM.
 
Old 05-11-2006, 08:12 PM   #8
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by rkelsen
The 'noauto' flag means that the drive will not be mounted when you start the machine. It has nothing to do with automatic mounting.

I agree with Simon Bridge. You should set up autofs. It is truly what you want.
I will install the autofs and see how it goes but just to clear some confusion/doubts that I have in my mind I would like to know this:
Ok I see what you guys are trying to say. so if I have line like this exits in my fstab file:
Code:
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
where hdc = CDROM Drive, I will still have to give the command:
mount /dev/cdrom in order to mount the CDROM? Right?

In this entire thread when I say 'automatic mouting' I mean not giving the command:
mount /dev/cdrom # TO mount the CDROM when we log into the system

and still the CDROM drive gets mounted at /media/cdrom0.

Also from the man pages:
Quote:
The file /etc/fstab (see fstab(5)), may contain lines describing what devices are usually mounted where, using which options. This file is used in three ways:

(i) The command


mount -a [-t type] [-O optlist]

(usually given in a bootscript) causes all file systems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated, except for those whose line contains the noauto keyword. Adding the -F option will make mount fork, so that the filesystems are mounted simultaneously.
So that means if I give the option of auto my CD-ROM drive should get mounted automatically by the system during the boot time, right?

Please help me in clearing all this confusion.

Thank you once again.

Last edited by kushalkoolwal; 05-11-2006 at 08:39 PM.
 
Old 05-11-2006, 10:07 PM   #9
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Quote:
if I give the option of auto my CD-ROM drive should get mounted automatically by the system during the boot time, right?
Yes - provided there is media in the drive at the time. Otherwise you'll get errors in the syslog, it will try several times, then give up. This slows your boot process. Further: it will only mount the disk at boottime. You will not get to automount disks when you insert them into the drive. This will not happen. So it follows that this is not the solution you are looking for. You want a CD icon to appear on your desktop moments after you insert the disk into the drive. Maybe even open a window dor data cds, open a player for music cd's and open a dvd player for dvd movies.

The fstab entry by itself will not automount your disks. You need to configure udev and/or autofs as suggested. Please read the article on this and you'll see.

Let me be pedantic for a moment: you do not mount devices. You mount file systems. Removable media devices usually do not contain file-systems unless there is media inserted into them. For this reason, it can be quite misleading to talk about "mounting a cdrom drive" or "mounting a cd rom". Though we usually know what we mean. Also, for this reason, it is inappropriate to attempt to mount fs on media unless we know it is present. (You could get erzats automounting by setting the mount -a command in cron for every few seconds... <shudder>)

CD drives and USB media stuff inform the kernel when there is media inserted. We can poll for this message, or trap it, and so intellegently time a mount command to correspond to when media is inserted. (Floppy drives usually don't do this... so you won't find many distros automounting floppies.)

The thing that handles this is autofs ... with usb devices, you want to be able to find the media at the same place each time (if a pendrive is /dev/sda then you want to always find it there). The thing that handles this is called udev.

To exploit this, though, you need a 2.6 kernel or a very recent 2.4 kernel with autofs enabled. So I reiterate: this information is in the articles I supplied. Do read them all the way through before your next post. Thank you.

Last edited by Simon Bridge; 05-11-2006 at 10:12 PM.
 
Old 05-11-2006, 10:11 PM   #10
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,807

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by kushalkoolwal
if I have line like this exits in my fstab file:
Code:
/dev/hdc  /media/cdrom0  iso9660  user,noauto,unhide,ro  0 0
where hdc = CDROM Drive, I will still have to give the command:
mount /dev/cdrom in order to mount the CDROM? Right?
If you have that line, you'll be able to mount the cd with "mount /media/cdrom0"

Note: I've made some changes. You can't mount CDs read/write, so you must include the "ro" option. You'll still be able to write CDs, because you don't have to mount a CD to write it.

The "unhide" option helps when trying to read CDs burned by other OSes. You don't really need udf support. I've never had problems mounting DVDs as iso9660 filesystems. udf is only really used by movies, and mounting a movie DVD is pretty pointless most of the time. You don't have to mount a DVD to play it. The same goes for CDs.
Quote:
Originally Posted by kushalkoolwal
So that means if I give the option of auto my CD-ROM drive should get mounted automatically by the system during the boot time, right?
Right, but you must have a CD in there or it'll spit out an error.

Last edited by rkelsen; 05-11-2006 at 10:12 PM.
 
Old 05-11-2006, 10:21 PM   #11
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,807

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by Simon Bridge
(Floppy drives usually don't do this... so you won't find many distros automounting floppies.)
Actually, you can use autofs to auto-mount floppies. It is much faster than mounting them manually.
 
Old 05-11-2006, 10:37 PM   #12
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Quote:
Originally Posted by rkelsen
Actually, you can use autofs to auto-mount floppies.
Really - I havn't got it going - ever. Can you point out a howto? (Hmmm ... interesting, autofs seems to be something that has gone awol with the upgrade to dapper!)

Last edited by Simon Bridge; 05-11-2006 at 10:50 PM.
 
Old 05-11-2006, 11:07 PM   #13
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
It seems dapper is using udev entirely for automounting and autofs isn't even installed.

apt-get install autofs
(installs fine)

it is activate on reboot or by
sudo /etc/init.d/autofs start

but I have to set up the correct maps.
sudo gedit /etc/auto.master
... uncomment the bits that seem right.
/etc/auto.misc has an entry for floppy, so uncomment that and also the key=/misc line in auto.master ... nope, dosn't seem to do the trick.

What did I miss?
I'll have to go look in my other box running breezy - AFAIK: that is running autofs by default.

I did find this:
http://lists.debian.org/debian-user/.../msg00684.html
... but the represented auto.master file looks nothing like mine. Perhaps I need the floppy option in auto.master?
 
Old 05-12-2006, 12:19 AM   #14
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,807

Rep: Reputation: 234Reputation: 234Reputation: 234
I'll post my auto.misc here when I get home from work.
 
Old 05-12-2006, 04:42 AM   #15
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,807

Rep: Reputation: 234Reputation: 234Reputation: 234
I have this line in my /etc/auto.master file:

Code:
/mnt/auto	/etc/auto.misc
And this line in my /etc/auto.misc file:

Code:
floppy  -fstype=auto,user,umask=000  :/dev/fd0
All my autofs mounts happen under /mnt/auto. With this setup, if I insert a floppy disc and type "cd /mnt/auto/floppy" the floppy is auto-mounted.
 
  


Reply


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
automounting pen drives saini_mw Linux - Hardware 2 04-03-2006 01:33 AM
FC3 usb stick automounting mightyMile Linux - Hardware 1 01-17-2006 04:07 PM
how does usb automounting work? m_yates Ubuntu 1 12-24-2005 10:35 PM
usb automounting wi_slacker Slackware 6 05-05-2004 01:30 AM
Automounting Raid drives voldermort Linux - Newbie 3 10-02-2003 10:52 AM


All times are GMT -5. The time now is 11:53 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