Xsan 2 Administrator Guide - Defragmenting a File, Folder, or Volume (snfsdefrag)

background image

Defragmenting a File, Folder, or Volume (snfsdefrag)

Use the

snfsdefrag

command to defragment a file by reallocating its data in a single

extent. This can improve read and write performance for a file by increasing disk
efficiency and reducing file metadata management overhead.

To defragment a file or folder:

$ snfsdefrag [-D] [-d] [-q] [-s] [-v] [-K affinity] [-k affinity] [-m

count

] [-r] target

To report file extents without defragmenting:

$ snfsdefrag -e [-K affinity] [-r] target [target] [...]

background image

120

Appendix B

Using the Command Line

To display an extent count without defragmenting:

$ snfsdefrag -c [-K affinity] [-r] target [target] [...]

To prune a file (remove allocated extents beyond the end of file):

$ snfsdefrag -p [-D] [-v] [-q] [-K affinity] [-m count] [-r] target

[target] [...]

To list files that are candidates for defragmentation:

$ snfsdefrag -l [-D] [-v] [-K affinity] [-m count] [-r]
target

[target] [...]

Parameter

Description

-c

Display an extent count but don’t defragment
target.

-D

Display debugging messages.

-d

Operate on files with other than the current
depth.

-e

Report extents without defragmenting.

-K affinity

Only operate on files with the specified storage
pool affinity.

affinity

– the affinity key (in Xsan, the affinity

key is the same as the name of the storage pool)
You can use the

cvadmin show long

command to see a storage pool’s affinity key.

-k affinity

Allocate new extents on the storage pool with
this affinity.

-l

List files that might benefit from
defragmentation.

-m count

Only operate on files with more than

count

extents.

-p

Prune instead of defragment.

-q

Suppress messages.

-r [target]

Operate recursively to defragment all files in all
folders within the specified target folder.

-s

Allocate new extents on block boundaries.

-v

Display all available information and status
during defragmentation.

Examples

Count the extents in the file datafile:

$ snfsdefrag -c datafile

background image

Appendix B

Using the Command Line

121

List the extents:

$ snfsdefrag -e datafile

Defragment the file datafile:

$ snfsdefrag datafile

Defragment every file in the folder /datafolder/ (or any folder within /datafolder/) that
has more than one extent:

$ snfsdefrag -r datafolder

Recover unused preallocated disk space assigned to every file in folder /datafolder/:

$ snfsdefrag -rp datafolder