1832935 Members
2953 Online
110048 Solutions
New Discussion

mount error

 
SOLVED
Go to solution
Leovino A. Trinidad, Jr
Frequent Advisor

mount error

Hi!

I have a problem unmounting a drive when running it in a script:

#!/bin/sh
mount /dev/hda1 /x

umount /dev/hda1

In some point umount does not run. If I check the mounting after the script run the drive (dev/hda1) is still mounted.

Hope you could help.

Regards,

LAT
5 REPLIES 5
Francisco J. Soler
Honored Contributor

Re: mount error

Hi LAT,

This , run some process that are still running when you try to umount it?

If there are process running, it is not possible to umount the drive.

Verify the processes with a
ps ax | grep mount_point
or
ps ax | grep /dev/hda1, to see what process are running.

Frank.
Linux?. Yes, of course.
Leovino A. Trinidad, Jr
Frequent Advisor

Re: mount error

Hi Frank!

By-the-way thanks for the additional infor regarding proc.. it's helpful.

The "other scripts" is just copying a file in the other drive.

Is it possible to set a delay to unmount the drive?

Thanks!

Regards,

LAT

Francisco J. Soler
Honored Contributor
Solution

Re: mount error

Hi LAT,

Inside the scripts you can execute a command if the previous one has finished succesfully or not, this is made by the && and || operators.

For example:

echo "Hi" > /tmp/dump && echo "Correct"

This outputs the word "Correct" in the standard output and create a new file in /tmp directory with the word Hi.

On the other hand, suppose the following:

chmod 000 /tmp/dump # no write permission in file

echo "Hi" > /tmp/dump || echo "Correct"

this outputs the following:

bash: /tmp/dump: Permision denied
Correct


The "Correct word is output because the first echo fails.

Well, this means that you can make the in a subprocess and follow with the && command with the umount.

This is only a idea.

About the delay, you can do a delay with the command sleep.

sleep 5 # sets a 5 seconds delay before continue.

Regards.
Frank.

Linux?. Yes, of course.
Steven E. Protter
Exalted Contributor

Re: mount error

You can't umount an fs with open processes.

I don't even know if this command is in Linux but you need the equivalent.

fuser -cu fsname

lists processes.

fuser -cuk fsname kills the suckers.

Then you can umount.

There is a Linux equivalent.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Caesar_3
Esteemed Contributor

Re: mount error

Hello!

What you need is fuser -uc
You will get the PIDs that use the mount point
then run ps aux | grep PID
and you will see who use the mount point.

Caesar