DEFRAG(8)

NAME
[ex][2]defrag - defragment file systems.

SYNOPSIS
defrag | edefrag | e2defrag | xdefrag [ -Vdnrsv ] [ -b bad-inode ] [ -i inode-list ] [ -p pool-size ] /dev/name

DESCRIPTION
Defrag will reorganise data on a minix file system partition in order to improve the file system's performance. Edefrag is the equivalent program for the extended file system. E2defrag in its turn is designed for the second extended file system (versions 0.3 onwards). And the xdefrag program will operate on Xia FS filesystems.

Note that unlike the fsck program, defrag MUST NOT be run on a mounted file system device (unless invoked with the -r (readonly) option, which is always safe). Also note that if you defragment a partition containing a bootable kernel image, you will have to reinstall the boot loader for that image (since the location on disk of the image may have changed).

Remember, if defrag fails to complete for any reason (including power glitches, kernel bugs etc.), you will be left with a terminally sick, and possibly completely unreadable, filesystem, so backup any valuable data before you start.

OPTIONS

-V  Supply full version information. If you are sending bug reports, please include this information.

-d  Run in debugging mode. This will not be available if disabled at compile-time.

-n  No-picture more. Disables a pseudo-graphic picture and runs with an old-style printf output. Note that the picture option requires a proper terminfo database for your terminal, compatible with the ncurses package. If the picture option is used, -v and -s options are set automatically. Nevertheless you can increase amount of information output to the status line using several -v switches. This gives you a chance to improve the speed of your reading.

-r  Readonly mode. Defrag will scan the file system and simulate the job of defragmentation, but will not write to the file system. This can be used for debugging or testing. It may also be used to find out how much work defrag will have to do, in order to choose a sensible pool-size

-s  Summarise file system information and defrag performance statistics.

-v  Verbose - gives a progress report as defragmentation proceeds. If -v is given twice, then a more detailed report is supplied. The fullest report, when -v is given three times, also reports the inode priority list as it is read.

-b bad-inode
    Indicate which inode stores the badblock list on the filesystem being defragmented. This should be an inode whose data blocks are all bad blocks. The defragmenter will not move these blocks, and will prevent any other data from being placed there. The default for edefrag is -b 2, since mkefs always creates a bad block inode at inode 2. The minix filesystem does not have a bad block inode by default, but if you have created one, supply its inode number with this option.

-i inode-list
    As of version 0.4, defrag has a new facility which allows you to specify how to reorganise the data on your disk. The inode-list is an optional file giving a priority between -100 and 100 to each inode in the filesystem. Higher priorities will be allocated nearer the beginning of the disk than lower (more negative) priorities. Two inodes of equal priority will be allocated in the same sequence they had originally on the filesystem, to minimise file movement. All inodes have a default priority of zero if they are ommitted from the file or if no -i option is given. The file inode-list should contain a series of lines containing either a single number (which will be interpreted as an inode number), or a number prefixed immediately by an equals sign (which will be interpreted as a priority to be applied to the subsequent inode numbers).

-p number
    Selects the number of (1KB) buffers allocated to the defragmenter's buffer pool. These buffers are used when relocating data, so the more buffers allocated, the more efficient the relocation process. The number you choose will depend on how much physical and virtual memory you have available.

BUGS
Maybe, but then that's why you backed up your data first, isn't it?

AUTHORS

Written by Stephen Tweedie. Adaptation for the xia, ext2 filesystem and the picture option are done by Alexey Vovenko. Much of the initial version was developed from the fsck and efsck programs by Linus Torvalds and Remy Card. Send bug reports, fixes, improvements, comments and fan-mail to sct@dcs.ed.ac.uk.