Showing posts with label disk. Show all posts
Showing posts with label disk. Show all posts

Disk Defragmentation

Defragmenting your disks file-systems can be important for several reasons:
  • Lots of fragments are slowing down your systems performance (especially true for any Windows systems).
  • You may want to shrink a partition and therefore need to move all files to get all available space at the end of the partition.
I needed to shrink my NTFS partition, because I want to give more space to my Ubuntu one, but even if it claimed to have 26 GB free, I could only shrink about 300 MB.
Why?
Because NTFS uses a MFT table for allocating, which could be anywhere and unfortunately, it will be in most cases at the end of the partition.
And almost any defragmentation program is able to move it.

Since I found Perfect Disk. It is not free-ware, but its one month evaluation was enough to finally claim all free space to the end of the partition and get it shrunk with GParted.

Until then, I tested several programs (because Windows XP internal tool isn't the optimum), and I'll list them here.

Perfect Disk


Perfect Disk is simply perfect. It makes it job as one thinks it should. Can defrag your MFT, pagefile, hyberfile in offline mode, its defragmentation algorithms seem to be very clever, can choose each algorithm automatically adapted to the file-systems state, scheduled tasks, during screensaver, and the interface is clean and nice.

O&O Defrag


O&O Defrag is similar to Perfect Disk, but finally wasn't able to move the MFT, but has more algorithms than Perfect Disk. It seems to be more slower during defragmentation than the other one. Isn't free-ware too.

MyDefrag


MyDefrag is freeware, and has a very different concept to other tools. Internally, it uses scripts that define the algorithm, and even if there are several ones included already, you could write your own ones. Its interface is ugly, but includes screensaver mode. Can handle floppies, USB disks, memory sticks, and anything else that looks like a disk to Windows.

Auslogic Disk Defrag


Auslogic tools is a simple disk defrag tool, with a nice interface. Does its job better than Windows included one and is free-ware too. Can defrag a single file or folder and includes a scheduler.

Defraggler


Use Defraggler to defrag your entire hard drive, or individual files - unique in the industry. This compact and portable Windows application supports NTFS and FAT32 file systems. Lets you specify one or more files, folders, or the whole drive to defragment. Very simple and supports quick defrag.

WinContig


WinContig is an easy-to-use stand-alone defragmentation tool that doesn't create any installation directories or Registry entries on your computer. Its purpose is to quick defrag files without the need to defrag the whole disk. In addition, WinContig allows you to group files into profiles, and also it accepts a number of optional command-line switches that you can use to control how the program operates.

SysInternal Tools


SysInternals also has some tools for defragmentation working directly on single files which can help out in some cases.

Contig


Contig is a single-file defragmenter that attempts to make files contiguous on disk. Its perfect for quickly optimizing files that are continuously becoming fragmented, or that you want to ensure are in as few fragments as possible.

PageDefrag


PageDefrag uses advanced techniques to provide you what commercial defragmenters cannot: the ability for you to see how fragmented your paging files and Registry hives are, and to defragment them. In addition, it defragments event log files and Windows 2000/XP hibernation files (where system memory is saved when you hibernate a laptop).

Duplicate file cleanup

CloneSpy (Windows)


CloneSpy can help you free up hard drive space by detecting and removing duplicate files. Duplicate files have exactly the same contents regardless of their name, date, time and location. Also, CloneSpy is able to find files that are not exactly identical, but have the same file name, or the file size differs only a bit.

FSlint (Linux)


FSlint is an utility to fix problems with filesystems' data, like duplicate files
is a toolkit to clean filesystem

fdupes (Linux)

FDupes uses md5sums and then a byte by byte comparison to find duplicate files within a set of directories. It has several useful options including recursion. This is the fastest one.
sudo aptitude install fdupes

You can instruct fdupes to delete duplicate files automatically, but you can't be sure it will delete always from the system folder.
Therefore, you could execute the following command:
fdupes -r a/ b/ | grep -o "^b/.*" | xargs -d '\n' rm ; find b/ -empty -delete

Linux shell commands

In an Ubuntu forum, they worked out a pipe of shell commands, to generate the same output as fdupes. So you don't have to install any software, but it's also much more slower (see benchmarks below).
find . ! -empty -type f -printf "%s " -exec ls -dQ {} \; | sort -n | uniq -D -w 1 | \
cut -d" " -f2- | \
xargs md5sum | sort | \
uniq -w32 -d --all-repeated=separate | \
cut -c35-


Benchmarks

722 groups
994 duplicate files
6205 files

FSlint 10 minutes
fdupes 5,5 minutes
Piped commands 13 minutes

Hard links


If you don't want to remove duplicates, but save memory you can use hardlink (or fdupes) on Linux which detects multiple copies of the same file and replaces them with hardlinks.
For example in my case:
Files:    5935
Linked:   991 files
Compared: 4022 files
Saved:    4.87 GiB
Duration: 12.6 minutes