[Wolves] Mounting a windows partition as a normal user on boot

Aquarius aquarius-lists at kryogenix.org
Tue Mar 23 22:26:21 GMT 2004


Adam Sweet spoo'd forth:
> Is there an easy way to do mount a windows partition
> on the local machine as a normal user, drinky, at boot
> time? Or will I have to add the necessary script to
> something like .bashrc so it does it when I log in?
> 
> I'd rather have it at boot, so the permissions belong
> to drinky and it cannot be mounted by someone else
> before drinky logs in.

Do not put it in .bashrc. That runs every time you start a bash
shell, including, critically, every time you start an xterm.

> My fstab line for the partition is:
> 
> /dev/hda1       /home/drinky/windows    vfat    user,noauto             0       0
> 
> I tried stuff like user=drinky, minus the noauto
> option but it didn't work. Googling and reading my
> rapidly growing Linux library didn't turn anything up
> that seemed right.
> 
> Worst case scenario can I just put a line like
> 
> mount ~/windows

In your init scripts, which will probably be in /etc/init.d,
there will be a script which mounts all your filesystems (this
is what makes sure that /usr and /var and so on are there). On
my Debian box, it's /etc/init.d/mountall.sh. Looking at that,
there's this line in mine:
mount -av -t nonfs,nosmbfs,noncpfs,noproc

That mounts all filesystems (-a) except those specified (nosmbfs,
etc, etc). Since that isn't mounting yours, you can either edit
that script so that it *does* mount your Windows partition, or
you can add a new init script which *will* mount it; just put a
new script in /etc/init.d/mountmywindows.local or somewhere that
mounts it (look at the other scripts in /etc/init.d for an idea
how those scripts work, but they're just bash scripts; most of
the stuff in them is to print errors to the screen).

You then need to make that script actually *run* in the runlevel
that the computer boots into. This will probably be runlevel 2.
On a Debian machine, you use update-rc.d for this:
# update-rc.d mountmywindows.local defaults

But, but, but, I hear you say, that'll mount it as root! Yep,
because the initscripts run as root. So, in the script, do 
su -c "mount /home/drinky/windows" drinky
which should run it as you.

Note that all this advice is for Debian. Initscripts are very
system-specific, so if you're a RedHat or SuSE guy (I forget) then
you'll have to ask someone else for advice...

Aq.

-- 
;; It appears that /dev/null is a conforming XSL processor.



More information about the Wolves mailing list