The SWAMI
of VSE/VSAM

 

Space Allocation Questions and Answers
How can I defragment the space owned by VSAM?

VSAM Managed Space can become fragmented.

As files are defined, space is allocated to them. Later, files are deleted and the space they occupy becomes free for use by other file allocation requests. Depending on the size and distribution of the free and used space allocations within the VSAM space, fragmentation may occur.

There is no VSAM defragmentation command. Using IDCAMS commands, however, VSAM space can be defragmented:

  1. Use IDCAMS BACKUP to make a copy of all files with extents on the volume containing the space to be defragmented.
  2. Use IDCAMS DELETE CLUSTER to delete all the files that were backed up. The output of the BACKUP command will contain a list of these files.
  3. Use IDCAMS RESTORE to restore all the files that were backed up and deleted.

IDCAMS RESTORE will delete files as they are being restored, but this will only release the space owned by one file at a time, leaving significant space fragmentation. To allow the space to be defragmented, all the files in the space should be deleted before the RESTORE command is processed.

You may want to consider making a second BACKUP because of the (unlikely) possibility that the first BACKUP output copy is unreadable, and you will be DELETEing the files!

Clearly this is fairly simple, and it could be readily automated using a REXX procedure, among other techniques.

   
 
Up to the
Q and A
Page
Up to the
Allocation
Q and A Page
E-Mail
The Swami
Go to
The Swami's
Home
 

This entire site -- including all its pages and content --
are the intellectual property of and copyright © 2002-2003 by
Dan Janda, theswami@epix.net