Creating a File System Large Enough to Hold Restored Files


Environment

OS Level: AIX Version 3.2.5
Type/Model: Unspecified

Problem

User is running out of space when attempting to restore files to a file system. How can the user find out how much space is being used to create a file system of the appropriate size?

Solution

Choose one of the following methods according to the type of archive. Regardless of which type of archive you have, if there are multiple file systems on the tape, after the cat command, pipe the file to run a search for the directory. Enter:
   [cat command] | grep [dir_name] | [rest of command]

For tar archives

  1. Enter the following command:
       tar -tvf /dev/rmt0 > /tmp/toc
    

  2. Create the file size.script. Enter:
       vi /tmp/size.script
    

  3. Enter the following script:
       #!/bin/ksh
       summ=0
       for i in `cat /tmp/toc | awk '{print $4}'`
               do
       ((summ=summ + i))
       done
       ((summ=summ / 512))
       echo "Size in 512 byte blocks="$summ
    

  4. Change the permissions of the script. Enter:
       chmod 744 /tmp/size.script
    
  5. Execute the script. Enter:
       /tmp/size.script
    

    Once the script completes, a number in 512 byte blocks should be displayed. This is the amount of space used by the restored files. Create the file system a little larger than the output.

For cpio archives

  1. Enter the following command:
       cpio -itcvB </dev/rmt0 >/tmp/toc
    

  2. Proceed as with the tar archive, entering the following script instead:
       #!/bin/ksh
       summ=0
       for i in `cat /tmp/toc |awk '{gsub ("^0", "512",$3); print $3}'`
       do
       ((summ=summ + i))
       done
       ((summ=summ / 512))
       echo "Size in 512 byte blocks="$summ  
    

For backup/restore

  1. Enter the following command:
       restore -Tqvf /dev/rmt0 >/tmp/toc
    

  2. Proceed as with the tar archive, entering the following script instead:
       #!/bin/ksh
       summ=0
       for i in `cat /tmp/toc |grep -v The |awk '{gsub ("^0", "512",$1); print $1}'`
       do
       ((summ=summ + i))
       done
       ((summ=summ / 512))
       echo "Size in 512 byte blocks="$summ
    



[ Doc Ref: 9563482332168     Publish Date: Apr. 28, 2000     4FAX Ref: none ]