SysAdminDay

Ara
03
2009

Basic Linux Tips #2 – lsof and fuser commands -

LINUX1-emreyasarSystem admins frequently get “device is busy” error while trying to umount a partition.

Probably you are getting rid of this problem by using “umount -f” comand at the end of your patience i think.

But I advise you being more polite while working around umount command.

At this point you can find the files are being used by using lsof command.

For example:

[emreyasar@testserver ~]# umount /mnt

umount: /mnt: device is busy

Let’s look who is using /mnt folder

[emreyasar@testserver ~]# lsof /mnt
COMMAND   PID  USER   FD   TYPE DEVICE       SIZE  NODE NAME
squid   12562 squid  142w   REG    8,6 1086241246 98209 /mnt/access.log

We see that the process with PID 12562 initiated by squid account is using /mnt/access.log file.

You can use fuser command for getting a shorter result.

[emreyasar@testserver ~]# fuser /mnt/*

/mnt/access.log:    12562

If you can stop the related porcess normally you  do this and then you may umount the filesystem. If you can’t do by this way it’s time to be a bit rude.

You can use kill command for killing the process or you may try this:

fuser -sk /mnt

The command above will kill all the processes which are using /mnt folder.

If you could not killed the related process(es) now you must try

umount -f /mnt

command.

Yaziyi gonderen Admin - Emre Yasar in: Genel, Linux | Etiketler: , , ,

Yorum yok »

RSS feed for comments on this post. TrackBack URL


Yorum yaz

  

Altyapi WP Temadown Wp Tr Temayapim TheBuckmaker Cevirmen Otel