sexta-feira, 9 de maio de 2014

Desfragmentando os arquivos no Linux

Ao contrário do que alguns pensam, o sistema de arquivos do Linux fragmenta, sim, embora seja em uma escala bem menor do que o FAT e o NTFS. E, por isso mesmo, é recomendável desfragemtá-lo de vez em quando. E para fazer isso existe o Defragfs, que pode ser baixado no endereço http://sourceforge.net/projects/defragfs/files/.

Agora descompacte o arquivo.

$ tar jzvf defragfs-1.1.1.gz

Agora é só executá-lo passando como parâmetro uma pasta. Aconselho também a usar os parâmetros -a (automático) e -f (forçar). É necessário ter permissões de root.

# ./defragfs-1.1.1 /var -af

defragfs 1.1.1, Released under GPLv3 by John Robson , March 2011 (help: $ defragfs / -h)

Analysis in progress...

.....................................................................................................................................................................................................................................................................................................................................................................................

Statistics for /var

Total Files: 372257
Total Fragmented Files: 611
Total Fragments: 3990
Fragments per Fragmented File: 6.53027823240589

File Fragmentation Rate: 0.164133918233908 %
Avg File Fragments (1 is best): 1.01071840153442

Most Fragmented Files(for details see /tmp/frags-result):
/var/lib/ntop/hostSerials.db: 1694 extents found
/var/log/openfire/stats.txt: 291 extents found
/var/log/dibbler/dibbler-server.log: 98 extents found
/var/log/error: 84 extents found
/var/lib/ntop/topTalkers.db: 69 extents found
/var/log/wtmp.1: 35 extents found
/var/spool/squid/core: 34 extents found
/var/cache/apt/archives/sauerbraten-data_0.0.20100728+repack-1_all.deb: 31 extents found
/var/log/snort/tcpdump.log.1399460602: 30 extents found
/var/log/icecast/icecast.log: 30 extents found

You need a defragmentation or Your are using -f parameter!

Please specify the percentage of files should be defrag (1-100) [0.164133918233908] or hit Enter.
Preparing defragmentation, please wait...

Files to be defragmented: 611

You need AT LEAST 1897.443 Megabytes temporarily used for defragmentation (at the directory where you specified), continue (Y/N)? [Y]
OK, please drink a cup of tea and wait...

File Number - File Name (Size Mb) [actual extents] - extents after defrag attempt

611 - /var/lib/ntop/hostSerials.db (86.465) [1742] - !
610 - /var/log/openfire/stats.txt (131.006) [291] - 5 3 3
609 - /var/log/dibbler/dibbler-server.log (1219.222) [98] - 6 1
608 - /var/log/error (10.705) [84] - 2 1
607 - /var/lib/ntop/topTalkers.db (6.617) [70] - 46 46
606 - /var/log/wtmp.1 (0.164) [35] - 1
605 - /var/spool/squid/core (4.234) [34] - 34
...
5 - /var/log/gdm3/:0.log.1 (0.059) [11] - 1
4 - /var/log/gdm3/:0-greeter.log.4 (0.039) [2] - 1
3 - /var/log/gdm3/:0-greeter.log (0.037) [3] - 1
2 - /var/log/gdm3/:0-greeter.log.2 (0.034) [2] - 1
1 - /var/log/gdm3/:0-greeter.log.1 (0.037) [2] - 1

Done!