Friday, May 21, 2010

How to find the deleted open file without rebbot on solaris

How to find the deleted open file without rebbot on solaris

1. Use the following command to find out open but deleted files
find /proc/*/fd -type f -links 0 -exec ls -lrt {} \;

which looks for files with zero links, i.e. that have been deleted but
a running process still has the file open. Using the PID from the
/proc//fd/xxxxx names returned you can determine which process is keepomg the file open

2. using cat /dev/null to empty the open file to release the hidden storage
3. check fs storage using df before and after

Example:

bonnet(RAM)/proc>df -h
Filesystem size used avail capacity Mounted on
/ 0K 4.0G 11G 27% /
/RETUNL 500G 79G 421G 16% /RETUNL
/dev 15G 4.0G 11G 27% /dev
/newwork 590G 430G 160G 73% /newwork
/opt 20G 11M 20G 1% /opt
/u01 15G 10G 4.7G 69% /u01
/u02 180G 142G 38G 80% /u02
/var/core 38G 7.0G 31G 19% /var/core
proc 0K 0K 0K 0% /proc
ctfs 0K 0K 0K 0% /system/contract
mnttab 0K 0K 0K 0% /etc/mnttab
objfs 0K 0K 0K 0% /system/object
swap 209G 280K 209G 1% /etc/svc/volatile
/platform/SUNW,T5440/lib/libc_psr/libc_psr_hwcap2.so.1
15G 4.0G 11G 27% /platform/sun4v/lib/libc_psr.so.1
/platform/SUNW,T5440/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
15G 4.0G 11G 27% /platform/sun4v/lib/sparcv9/libc_psr.so.1
fd 0K 0K 0K 0% /dev/fd
swap 4.0G 155M 3.8G 4% /tmp
swap 209G 16K 209G 1% /var/run

bonnet(RAM)/proc>find /proc/*/fd -type f -links 0 -exec ls -lrt {} \;
-rw-r----- 0 oracle dba 0 May 4 06:54 /proc/11953/fd/8
-rw-r----- 0 oracle dba 0 May 4 06:57 /proc/7566/fd/8
-rw-r----- 0 oracle dba 24751652864 May 21 09:37 /proc/7566/fd/258
-rw-r----- 0 oracle dba 0 May 4 06:54 /proc/8755/fd/8
bonnet(RAM)/proc>cat /dev/null >/proc/7566/fd/258
bonnet(RAM)/proc>df -h
Filesystem size used avail capacity Mounted on
/ 0K 4.0G 11G 27% /
/RETUNL 500G 79G 421G 16% /RETUNL
/dev 15G 4.0G 11G 27% /dev
/newwork 590G 430G 160G 73% /newwork
/opt 20G 11M 20G 1% /opt
/u01 15G 10G 4.7G 69% /u01
/u02 180G 119G 61G 67% /u02
/var/core 38G 7.0G 31G 19% /var/core
proc 0K 0K 0K 0% /proc
ctfs 0K 0K 0K 0% /system/contract
mnttab 0K 0K 0K 0% /etc/mnttab
objfs 0K 0K 0K 0% /system/object
swap 209G 280K 209G 1% /etc/svc/volatile
/platform/SUNW,T5440/lib/libc_psr/libc_psr_hwcap2.so.1
15G 4.0G 11G 27% /platform/sun4v/lib/libc_psr.so.1
/platform/SUNW,T5440/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
15G 4.0G 11G 27% /platform/sun4v/lib/sparcv9/libc_psr.so.1
fd 0K 0K 0K 0% /dev/fd
swap 4.0G 155M 3.8G 4% /tmp
swap 209G 16K 209G 1% /var/run


Pay attention to /u02, 24Gb space is released.