[Previous] [Contents] [Index] [Next]

Scdir

Scdir can save and restore a directory tree. This utility is useful when you are restoring a tape onto a new disk or when you want to defragment a hard disk.

Scdir is a 32-bit program for use with Linux 2.0.30 version and later.

Scdir has three uses. It can create a report on a directory tree and recreate a directory tree from a previously created report. It can also create a complete directory path even when intermediate portions of the path are missing.

SecondCopy will run scdir when it is needed, so scdir must be in the search path.

When making a report, scdir reads lines from stdin, interprets the lines as directory names, and prints a detailed report to stdout. In the reverse procedure, scdir reads report lines from stdin and recreates the directory with correct information.

To see the available actions, type:

$ scdir ?<Enter>

$ scdir ?

Copyright (C) 1993-1998 Brown Computer Company. All rights reserved.
scdir version 0.06 11 September 1998
This program will create a directory tree report, recreate a directory
tree, or make a single directory whose path has missing components.
use       find / -type d | scdir report >dir.report
or        scdir recreate <dir.report
or        scdir mkdir [path/]name
or        scdir help
or        scdir ?
where:
commands  usage
---------------
report    report creates a report on every line read from stdin
recreate  recreate makes one directory for each line read from stdin
mkdir     mkdir creates a directory, including missing portions of its
          path, path and name specify a new directory
help      prints this message
?         prints this message
$

Scdir makes the restoration of an entire tape volume easier and eliminates fragmentation on a hard disk.

If an entire disk must be restored, it is likely that the directories, as well as the files, are missing. Scdir creates an ascii version of the disk's directory tree that can be used to rebuild the tree after a hard disk failure. The information in the directory report allows the directories to be created with the correct size, owner, and permissions. When the restoration is complete, the directories will not have any extents and they will be placed sequentially on the disk. Later traversals of the directory tree will proceed much more quickly.

# find / -type d ! -pname '/proc/*' | scdir report >/tmp/dir.report <Enter>

This command creates a file containing one line for each directory. Each line contains the group, member, attributes, permissions, number of files, the status, the date, and the name of the directory. For convenience, the report created with this command should be saved at the beginning of the same tape that will be used for holding the files.

The superuser prompt is needed because directories have permissions too.

The next three commands create a tape with the directory tree stored as the first file on the tape. The disk files follow.

# find / -type d ! -pname '/proc/*' | scdir report >/tmp/dir.report <Enter>

# secondcopy /dev/st0 "init XYZ" save <Enter>
/tmp/dir.report<Enter>
^d

# find / -type d ! -pname '/proc/*' | secondcopy /dev/st0 save <Enter>

If the entire tape needs to be restored onto a disk that is still bootable, but which does not have directories on it, use the commands:

# secondcopy /dev/st0 restore <Enter>
/tmp/dir.report <Enter>
^d

# scdir recreate </tmp/dir.report <Enter>

# secondcopy /dev/st0 restore <Enter>
*<Enter>
^d

These three commands will copy all of the files from the tape onto the hard disk. Neither the files nor the directories will have extents.

If all is lost, including the ability to boot up, you must boot from floppy and utilize a restore option called "-prefix".

The preceding examples use the find program to generate the list of directories. The /proc directory and its descendents are skipped because in Linux these directories are created and manipulated whenever processes are started. They do not need to be recreated by scdir.

The last command available to scdir is the mkdir command. This command will create the path named on the command line. The function is similar to the "mkdir" program but scdir has the ability to create missing portions of the path. Type:

# scdir mkdir /tmp/a/b/c/d/e/f <Enter>

Scdir will create /tmp/a/b/c/d/e/f even if /tmp/a/b/c/d/e, or any other branch in the tree is missing. The directory will be owned by the user who invoked the program. The directory will be created with the default size of ten directory entries, so the directory will fragment, or gain its first extent, when the eleventh item is added.

[Previous] [Contents] [Index] [Next]