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).

SystemRescueCD from ISO image

The new grub loader shipped with Ubuntu Lucid is able to boot systems directly from ISO images located in any hard disc partition.

Lets use this fact and have always the latest SystemRescueCD at hand, without having to burn a new CD, just by having its ISO on our Ubuntu partition.

There are some instructions on their web-site, but
  1. they don't work

  2. why not use grub's update mechanism to include the SystemRescueCD entry automatically, instead of having to add it by hand.


Therefore, grub offers to have some scripts in /etc/grub.d which are called during the update process and I'll give you here the steps for adding the ISO image as entry "magically".

Install instructions


  1. Download latest SystemRescueCD image from their web.

  2. Move it somewhere inside the /boot folder, for example I use a subfolder:
    sudo mkdir /boot/sysrcd
    sudo mv systemrescuecd*.iso /boot/sysrcd/

  3. Create a new file /etc/grub.d/50_sysrcd and put the following content:
    #!/bin/sh

    # Search for System Rescue CD iso file in /boot and add it as boot-entry.

    for iso in $(find /boot -name systemrescuecd*.iso)
    do
    isofile=`echo $iso`
    version=`echo $iso | cut -d "-" -f 3 | cut -d "." -f 1,2,3`
    echo "Found SystemRescueCD image: ${iso}" >&2
    cat << EOF
    menuentry "SystemRescueCd ${version}" {
    loopback loop ${isofile}
    linux (loop)/isolinux/rescuecd isoloop=${isofile}
    initrd (loop)/isolinux/initram.igz
    }
    EOF
    done

  4. Make it executable:

  5. sudo chmod a+x /etc/grub.d/50_sysrcd

  6. Now, we are ready to update the grub menu:
    sudo update-grub


That's it, now when you reboot your system, you should see the SystemRescueCD as latest entry and you can just boot it up.

You could also have several versions of the ISO images in /boot/sysrcd and this will give several grub entries.

Nice if you need to tweak your system partitions, need to recover something from your broken Windows partition, you just have the tools there, and it only occupies about 250 MB on your Linux partition.
And whenever you want to use a newer version, just download the new one, replace the old ISO, and update the grub menu again.

Troubleshooting


If you get these messages during update-grub
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst

and
Updating /boot/grub/menu.lst ... done

this means that you still using grub version 1, not the latest one.
In that case, you should first upgrade grub with
sudo aptitude install grub2

Create a bootable Live USB drive with UNetbootin


UNetbootin is a cross-platform utility that can create Live USB systems and can load a variety of system utilities or install various Linux distributions and other operating systems without a CD.

Install instructions

sudo add-apt-repository ppa:gezakovacs/ppa
sudo aptitude update
sudo aptitude install unetbootin

Remove Evolution

Personally, I prefer Thunderbird for mailing than the preinstalled Evolution.
If you share the same preference, surely you tried to remove Evolution from your system, just to run into a dead-end, because several packages depend on it, especially one meta package.
Evolution seems to be embedded into Ubuntu like IExplorer in Windows.

But yesterday I found some Spanish article explaining how to remove it from the system, leaving about 56 MB of free space on your system.
I just added two more packages to the de-installation instruction that where missing for my Ubuntu 9.10 system.

Deinstall instructions


sudo aptitude purge evolution-indicator evolution evolution-documentation-en evolution-common evolution-data-server evolution-webcal evolution-plugins evolution-couchdb evolution-exchange mail-notification-evolution