Unmount Windows partitions on login

i’d like to automatically unmount my windows partitions everytime i login as root.

is there any shell script that can run automatically everytime i login ?

i have:
sda1-C-FAT32-WinXP
sda2-D-FAT32-my personal files

and would like to unmount them whenever i login as root as a security measure.

:expressionless:

Hi,

What about writing the commands to unmount the partitions in one of the root home .bash* files, for example, bash_login?

This file is only parsed when logging in, so I think it will do the trick.

Regards.

no, i mean, i’d like to put something in the kde4 autostart folder, so that it can be removed when necessary.

btw, how do i write a shell script to unmount partititions ?

thanks for the idea anyway…

It generally has to be done as root user.
What about you remove the mount point/s in Yast Partitioner. Then they won’t mount until you consciously mount them – kinda reverse the problem to your advantage.

On Tue, 19 Aug 2008 12:36:03 GMT
CurvyTail <CurvyTail@no-mx.forums.opensuse.org> wrote:

>
> carboncore;1858943 Wrote:
> > Hi,
> >
> > What about writing the commands to unmount the partitions in one of the
> > root home .bash* files, for example, bash_login?
> >
> > This file is only parsed when logging in, so I think it will do the
> > trick.
> >
> >
> > Regards.
> no, i mean, i’d like to put something in the kde4 autostart folder, so
> that it can be removed when necessary.
>
> btw, how do i write a shell script to unmount partititions ?
>
> thanks for the idea anyway…
>
>

Firstly… logging into the GUI as root is a VERY bad idea. But it’s your
system.

Ok…

Several methods:

It was mentioned that you could make the partitions not automount, but then
you’d forget and leave them mounted from being logged in as ‘curvy’, and then
they’d be there leering at you as root… ok, that’s out.

You could use commands in .bashrc, so that they’d be performed when you log
in as root, regardless of whether you log in via a console, ssh or GUI.

These commands would also work in the GUI, if placed into an executable
script stored in the .kde4/Autostart subdirectory.

We need to remember that you may have VFAT AND NTFS partions in your system.

The magic commands:

umount -t vfat -a
umount -t ntfs -a

If you put those two lines at the end of root’s .bashrc (<—notice the dot),
they’ll be executed ANYTIME root logs in.

(oh pooh! even when you ‘su - root’ stuff too! fun!!)

If you were to save these two lines in a text file as so:

#!/bin/bash

umount -t vfat -a
umount -t ntfs -a

and then

chmod +x myfile

(replace myfile with name of script you just created)

Then save this script into .kde/Autostart directory, they’d be started when
root logs in via KDE4 GUI. (this is probably what you’re looking for)

Something to think about:

If you have flash drives plugged into the system, they’re usually automounted
as needed… they are usually VFAT formatted (not mine!). These commands WILL
unmount those drives too. (oops!)

A better set of commands, which don’t use ‘wildcards’ to umount things would
be:

umount /dev/sda2
umount /dev/sdg4

or where-ever your partitions are mounted at. That would be much better
since it would be a selective pruning.

Oh, and if you’ll accept advice from someone who’s been using linux for a
few months or so…

Try VERY HARD to NEVER EVER EVER LOG IN AS ROOT.

su - … and sudo … are fine… but never STAY as root.

Hope this helps

Loni


L R Nix
lornix@lornix.com

ah…at last someone seems to understand me ! :slight_smile:

this is what i was looking for.

i occasionally login as root just to install windows apps under wine.

running a script from the autostart folder is what i am looking at.

thanks very much again…:wink:

On Wed, 20 Aug 2008 06:26:02 GMT
CurvyTail <CurvyTail@no-mx.forums.opensuse.org> wrote:

>
> lornix;1859271 Wrote:
> >
> > Then save this script into .kde/Autostart directory, they’d be started
> > when
> > root logs in via KDE4 GUI. (this is probably what you’re looking for)
> >
>
> ah…at last someone seems to understand me ! :slight_smile:
>
> this is what i was looking for.
>
> i occasionally login as root just to install windows apps under wine.
>
> running a script from the autostart folder is what i am looking at.
>
> thanks very much again…:wink:
>
>

Don’t understand the need to be root to install windows apps in wine… the
wine subdirectory into which any windows programs are installed is local to
each user… You could have something installed that someone else on your
system cannot touch nor even know about.

And once again… logging in as root is “not good” ™

Just occurred to me a VERY good example of WHY logging in as root is bad…

Let’s pretend you got hold of ‘weird’ version of some program for windows
which actually contained a virus or trojan. (Gee, that never happens!)

If you’re logged in as ‘curvy’… the ABSOLUTE MOST that program can corrupt
are your own files. NO ONE ELSE’S. You’re ‘mostly safe’. The system will
boot, life goes on, you just need to recover some files.

If you’re logged in as root… that same program can now infect or damage
ANYTHING on the ENTIRE system.

Goodness! Linux isn’t Windows… please don’t use it like windows. Not sure
how much sympathy you’d get when it was discovered that a virus in a program
you ran AS ROOT had trashed your system. Wine lets programs run as if they
were running in a real Windows system… so viruses work, trojans work…
they don’t get FAR, but they WILL work under WINE.

And the Wine environment does NOT give access to ANY drives or partitions
unless or until you configure Wine to be allowed to do so. This is set in
the ‘winecfg’ program. With this in mind, you wouldn’t even have to umount
the drives when playing with Wine either.

This means any virus/trojan/etc damage is limited to the .wine
subdirectory… so you’ve got even LESS to worry about, since fixing THAT
only involves a delete of the .wine subdir and restart of Wine program.

Just a friendly heads up…

Loni


L R Nix
lornix@lornix.com