LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   automounting CD-ROMs USB drives (https://www.linuxquestions.org/questions/debian-26/automounting-cd-roms-usb-drives-443617/)

kushalkoolwal 05-10-2006 06:24 PM

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

Penguin of Wonder 05-10-2006 06:28 PM

Hats off to those who can live without the GUI. :bows:

Simon Bridge 05-10-2006 06:34 PM

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.

kushalkoolwal 05-11-2006 05:13 PM

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.

Simon Bridge 05-11-2006 06:25 PM

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?

kushalkoolwal 05-11-2006 06:37 PM

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

rkelsen 05-11-2006 06:48 PM

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.

kushalkoolwal 05-11-2006 07:12 PM

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.

Simon Bridge 05-11-2006 09:07 PM

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.

rkelsen 05-11-2006 09:11 PM

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.

rkelsen 05-11-2006 09:21 PM

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.

Simon Bridge 05-11-2006 09:37 PM

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!)

Simon Bridge 05-11-2006 10:07 PM

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?

rkelsen 05-11-2006 11:19 PM

I'll post my auto.misc here when I get home from work.

rkelsen 05-12-2006 03:42 AM

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.


All times are GMT -5. The time now is 12:24 AM.