Mounting a drive - not using fstab or root
David Ryder
davaweb at bigpond.net.au
Thu May 29 00:08:26 BST 2008
Thanks everybody for replying. My questions are below:
> > Date: Wed, 28 May 2008 09:27:12 +1000
> > From: David Ryder <davaweb at bigpond.net.au>
> > Subject: Mounting a drive - not using fstab or root
> > To: Ubuntu-au mailing list <ubuntu-au at lists.ubuntu.com>
> > Message-ID: <1211930832.7171.22.camel at ubuntu-server.dryder.org.CEDARS>
> > Content-Type: text/plain; charset=UTF-8
> >
> > Hi,
> > HARDY
> > I have a drive which at various times in the day and week, I want to
> > mount/umount, via cron and a script, in ?/media or another
> > folder /media/this-drive-folder/. Because I want to use different
> > folders at different mount times (for valid business reasons) the drive
> > can not be in fstab, as I understand it, because then I would not have
> > the choice of which folder to mount it in.
> >
> > But - mount wants root only to mount. I think users can mount fstab
> > drives if noauto, user (or suid using sudoers?) are used but that does
> > not overcome my mount location needs.
> >
> > So, the crux of all this is, is it possible to mount an ntfs drive that
> > is not in fstab, as a user in a script, without needing sudo?
> >
> > Thanks,
> > David>
> >
> >
> Hi David,
> The only way I know to do what you're trying to do is to
> add a line in /etc/sudoers for the user that will be mounting the drive.
> Using the command - sudo visudo - in a terminal you can add the line -
> [username] ALL = NOPASSWD: /bin/mount, /bin/umount
> where [username] is the users' login name. The user will need admin
> rights and you will still need to have sudo mount in you're script but
> it won't ask for a password.
> Hope it helps.
> Paul
Thanks Paul. This *seems* easy to me - but when I type sudo visudo I
get the terminal and file but no way of editing or saving it. Please may
I ask how to type these commands in the file in terminal and where is
the 'Save' ability?
Also, presumably the entry would go in the section:
# User privilege specification
root ALL=(ALL) ALL
myusername ALL = NOPASSWD /bin/mount, /bin/umount
Problem - having opened it once I now get the message when opening it:
"E325: ATTENTION
Found a swap file by the name "/etc/.sudoers.tmp.swp"
owned by: root dated: Thu May 29 07:11:32 2008
file name: /etc/sudoers.tmp
modified: YES
user name: root host name: ubuntu-server
process ID: 14019
While opening file "/etc/sudoers.tmp"
dated: Fri May 23 09:43:58 2008
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/sudoers.tmp"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file
"/etc/.sudoers.tmp.swp"
to avoid this message.
"/etc/sudoers.tmp" 23 lines, 470 characters
Press ENTER or type command to continue"
Can I just delete /etc/sudoers.tmp and restore /etc/sudoers from last
night's backup to overcome this?
Thanks.
>
>
> Hi David,
>
> You could take a look at the "pmount/pumount" commands ...
> you will need to install the "pmount" package first
>
> Regards,
>
> Lawson Hanson
Thanks Lawson.
It says pmoun/pumount is a wrapper for removeable drives - these are fixed discs, not
unpluggable usb/hot swap drives. I find that often the word 'removeable' has
different meanings in documentation - the drive in question is simply a non ubuntu
drive in the same box. Is that 'removeable'?
>
>
>
> That's like a red flag to a bull. There's *always* more than one way
> to
> do it. :-)
>
> Here are two more suggestions:
>
> 1. Use autofs with two mount points defined, each addressing the same
> device. e.g., put this in /etc/auto.master:
>
> /mymedia /etc/auto.mymedia --timeout=10 # seconds
>
> and this in /etc/auto.mymedia:
>
> cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
> hd1 -fstype=auto :/dev/sda
> hd2 -fstype=ext3 :/dev/sda
>
> Then when you want to use the drive, just cd to /mymedia/hd1 and it
> will
> be ready to go.
>
> 2. Use manual mounting:
>
> /dev/sda /mymedia/hd1 ext3 user,noauto 0 0
> /dev/sda /mymedia/hd2 ext3 user,noauto 0 0
Thanks Paul.
The fstab entry, taken out, was:
LABEL=hardy-backups /media/hardy-backups ntfs-3g defaults,locale=en_AU.UTF-8 0 0
Would this then be:
LABEL=hardy-backups /media/hardy-backups ntfs-3g user,noauto 0 0
because if so, I have already tried that and it doesn't work. Is there still
an issue with user,noauto?
> Then you can just 'mount /mymedia/hd1' as a normal user, and neither
> point will mount automatically when the system boots.
My scripts rely on the LABEL to mount the drive
and a different mount point, described in the scripts, for different uses, eg,
mount LABEL=hardy-backups /media/loc1,
mount LABEL=hardy-backups /media/loc2 to mount and
umount /media/loc1/ to unmount.
> Note that if this is a USB or similar device (firewire, eSATA), you'll
> probably need to disable automatic mounting of devices with the GNOME
> tools. (I can't remember how to do this.)
>
The drive is IDE but may change to a SATA (internal).
>
> Paul
Many thanks all.
David
More information about the ubuntu-au
mailing list