LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   can i umount var filesystem?? (https://www.linuxquestions.org/questions/linux-kernel-70/can-i-umount-var-filesystem-562559/)

raklo 06-18-2007 12:02 AM

can i umount var filesystem??
 
hello,
i wanna umount the /var directory.ideally when i do that i will
show " device busy "
now if i kill all the processes that are working on the directory,
i should not get device busy error.
but how do i find ,which all processes are working on var directory???
so that i can kill them.

or is ther any other approach to it??

regards
rakesh

gilead 06-18-2007 12:31 AM

lsof can retrieve info on open files for a device - have you looked at man lsof yet to see if it does it in a way that you can use?

raklo 06-18-2007 12:53 AM

lsof gives me list of open files n sockets.
wot i want is list of processes that are working on /var directory,
i.e processes that are responsible for writing in /var/log/messages file
and all such other files.
so that if possible,i can kill them one by one to get out of device busy problem.

thanx for reply
regards

j-ray 06-18-2007 02:15 AM

i dont know whehter it is a good idea to umount /var completely but maybe you can simply
umount -l /var

FMC 06-18-2007 06:30 AM

Tha magic command is fuser:
Code:

catunda@fabio ~ $ fuser -vm /
                    USER        PID ACCESS COMMAND
                    root          1 ....m init
                    root        949 ....m udevd
                    root      3371 ....m dhcpcd
                    root      4193 ....m sshd
                    nx        4199 ....m sshd
                    ...

[]īs, FMC!

archtoad6 06-18-2007 09:49 AM

This would work on my MEPIS 3.3.2 system, if I let it.

The 1 tweak you might have to make is to adjust the field ("$9") that awk prints to your ver. of lsof.
Code:

dir='/var'
kill $(fuser `lsof $dir |awk '{print $9}'` 2>/dev/null)

If necessary, you make that kill -9.

raklo 06-19-2007 12:02 AM

many many thnx to all who replied.
but will the shell script that u've sent do that safely.
bcoz when i tried to kill processes that work on /var,
certain critical processes were killed and this led to an immediate logout.

though i m trying with ur alternative,if results come out ,will let u know.

nx5000 06-19-2007 04:25 AM

Why do you want to umount /var while running the system?
It's an essential directory..

You could go to runlevel 1 and unmount it, do your stuff, remount it and go back to your current runlevel.

raklo 06-19-2007 04:32 AM

i hv an embedded box that internally uses linux,
i m working on memory related issues,wherein i need
to think of alternatives to get up some more memory
if system goes out of memory,
so i m thinking of options that i can try,one of which is
getting space from /var.
i dont know whether this approach is correct or not,
nd ur feedback would be appreciated.

bigrigdriver 06-19-2007 04:36 AM

Quote:

so that if possible,i can kill them one by one to get out of device busy problem.
It might be more helpful to you if you told us more about the 'device busy' problem.

raklo 06-19-2007 05:01 AM

just type command
#umount /proc

or

#umount /var

n u will get a message
device is busy

this is wot device busy problem is all about.

nx5000 06-19-2007 06:26 AM

Unmounting /var will not change anything to disk space (you are mixing memory:RAM and disk space)
Unmounting will remove the hard disk partition /var from the filesystem hierarchy. The space will not be freed.

It all depends on what embend device you are working on.

You could completely remove /var. Because

-> The system is stable and you don't need any log anymore to analyze problems. /var keeps the logfile so it's interesting in case of crash
-> The system is not security-sensitive. /var also contains all connection access made to the board.
-> Most important: it is on flash. flash has limited Read/Write number. Every time somebody would connect to the webserver on the board for example, linux will happily write one line in /var/something. This is unacceptable for flash memory.

As said, remove /var completly. rm it and remove it from fstab. Then you have a new partition.
Or you have a running process that deletes some big uneeded files every xx hours/days.

FMC 06-19-2007 06:36 AM

Thats true, if you unmount /var the space will still be used!

And if you have flash memory you should mount your /var on RAM memory space, this way you can access log files while the machine is up, or you can manage syslog to log on a remote machine, anyway, do not freak your flash memory with logs! lol

[]īs, FMC!

raklo 06-19-2007 08:11 AM

yes wot u said is rite,if i directly umount /var it wont help me at all as far as memory is concerned,
but wot if i systematically kill all the processes that
r working on /var, and that do not have dependencies on other processes
and then umount it????

wont that case help me to some extent???

nx5000 06-19-2007 08:44 AM

"Mounting" is a logical operation, not physical.

In general, you first physically create the partition by allocating space and then you need to mount it to "insert" it to your /

1) You can only clear (or format if you prefer) an unmounted partition.
2) You can only unmount a partition if no files are opened on it.

So unmount will help you for 1) but nothing else.

Putting it in RAM is another solution.


All times are GMT -5. The time now is 03:00 PM.