About these ads

Deleted file in Linux but didn’t reclaim space in filesystem

The reason that the space in the filesystem wasn’t reclaimed is because the file was opened and in use by another application

root@linux:~ # lsof /bkpcvrd | grep deleted
dsmc 21215 root 11r REG 253,9 4268860136 1097761 /bkpcvrd/pbh020/export/pbh020_20111001.dmp.gz (deleted)
dsmc 30379 root 8r REG 253,9 4268860136 1097761 /bkpcvrd/pbh020/export/pbh020_20111001.dmp.gz (deleted)
dsmc 32691 root 9r REG 253,9 4268860136 1097761 /bkpcvrd/pbh020/export/pbh020_20111001.dmp.gz (deleted)

Check the directory where the file descriptors for the PID is

root@linux:/proc/21215/fd # ls -l
total 12
l-wx—— 1 root root 64 2011-10-04 10:09 0 -> /dev/null
l-wx—— 1 root root 64 2011-10-04 10:09 1 -> /root/nohup.out
lrwx—— 1 root root 64 2011-10-04 10:09 10 -> socket:/[32923523]
lr-x—— 1 root root 64 2011-10-04 10:09 11 -> /bkpcvrd/pbh020/export/pbh020_20111001.dmp.gz (deleted)
l-wx—— 1 root root 64 2011-10-04 10:09 2 -> /dev/null
l-wx—— 1 root root 64 2011-10-04 10:09 3 -> /opt/tivoli/tsm/client/ba/bin/dsmerror.log
l-wx—— 1 root root 64 2011-10-04 10:09 4 -> /opt/tivoli/tsm/client/ba/bin/dsmsched.log
lrwx—— 1 root root 64 2011-10-04 10:09 5 -> socket:/[31319408]
lrwx—— 1 root root 64 2011-10-04 10:09 6 -> socket:/[31319409]
lrwx—— 1 root root 64 2011-10-04 10:09 7 -> socket:/[33998182]
lrwx—— 1 root root 64 2011-10-04 10:09 8 -> socket:/[33083683]
lr-x—— 1 root root 64 2011-10-04 10:09 9 -> /usr/oradata/orapbh020/tbd1/LENEL_DATA.D001
You previously saw that the there is a link and in the end it says deleted. Type > in the number that was shown in that line

root@linux:/proc/21215/fd # > 11

List the other file descriptors

root@linux:/proc/30379/fd # ls -l
total 11
lrwx—— 1 root root 64 2011-10-04 10:09 0 -> /dev/console
l-wx—— 1 root root 64 2011-10-04 10:09 1 -> /dev/null
lrwx—— 1 root root 64 2011-10-04 10:09 10 -> socket:/[33912163]
lr-x—— 1 root root 64 2011-10-04 10:09 11 -> /usr/oradata/orapbh020/tbd1/LENEL_DATA.D001
l-wx—— 1 root root 64 2011-10-04 10:09 2 -> /dev/null
l-wx—— 1 root root 64 2011-10-04 10:09 3 -> /opt/tivoli/tsm/client/ba/bin/dsmerror.log
l-wx—— 1 root root 64 2011-10-04 10:09 4 -> /opt/tivoli/tsm/client/ba/bin/dsmsched.log
lrwx—— 1 root root 64 2011-10-04 10:09 5 -> socket:/[21055400]
lrwx—— 1 root root 64 2011-10-04 10:09 6 -> socket:/[31339242]
lrwx—— 1 root root 64 2011-10-04 10:09 7 -> socket:/[33078656]
lrwx—— 1 root root 64 2011-10-04 10:09 9 -> socket:/[32744402]

root@linux:/proc/32691/fd # ls -l
total 11
l-wx—— 1 root root 64 2011-10-04 10:09 0 -> /dev/null
l-wx—— 1 root root 64 2011-10-04 10:09 1 -> /opt/tivoli/tsm/client/ba/bin/nohup.out
lr-x—— 1 root root 64 2011-10-04 10:09 10 -> /bkpcvrd/pbh020/export/pbh020_20111002.dmp.gz
l-wx—— 1 root root 64 2011-10-04 10:09 2 -> /dev/null
l-wx—— 1 root root 64 2011-10-04 10:09 3 -> /opt/tivoli/tsm/client/ba/bin/dsmerror.log
l-wx—— 1 root root 64 2011-10-04 10:09 4 -> /opt/tivoli/tsm/client/ba/bin/dsmsched.log
lrwx—— 1 root root 64 2011-10-04 10:09 5 -> socket:/[33364746]
lrwx—— 1 root root 64 2011-10-04 10:09 6 -> socket:/[33364747]
lrwx—— 1 root root 64 2011-10-04 10:09 7 -> socket:/[33365181]
lrwx—— 1 root root 64 2011-10-04 10:09 8 -> socket:/[33365142]
lr-x—— 1 root root 64 2011-10-04 10:09 9 -> /bkpcvrd/pbh020/export/pbh020_20111003.dmp.gz

The space is now reclaimed

root@linux:~ # df -h /bkpcvrd
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-bkpcvrdlv
17G 8.2G 7.3G 53% /bkpcvrd

Listing the open files in the filesystem to see if there is still an open file with the deleted status

root@linux:~ # lsof /bkpcvrd | grep deleted
root@linux:~ #

About these ads
Follow

Get every new post delivered to your Inbox.

Join 304 other followers

%d bloggers like this: