Next Previous Contents

4. Usage

After you are sure your system is ready to use this script (read the installation section, otherwise you may DAMAGE your data!), run something like:

# e2sbf /dev/hda1
as superuser, where /dev/hda1 is your partition or a backup copy of it. The script should print a list of preliminary checks (to make sure that all needed tools are installed and that the bash is of the right version) and then a list of sectors the script is testing. In case a superblock is found, a line of ``*'' followed by ``Found: number'' is written on the screen, where number is the sector where the superblock was found, suitable for usage with the ``-b'' parameter of e2fsck. It is possible to specify a ``logfile'' as a second parameters in order to log the output of all the commands run. Here is an example output:
Looking for mke2fs: /sbin/mke2fs
Looking for e2fsck: /sbin/e2fsck
Looking for grep: /bin/grep
Looking for head: /usr/bin/head
Looking for tail: /usr/bin/tail
Looking for cut: /bin/cut
Looking for sed: /bin/sed
Looking for true: /bin/true

Testing bash abilities (any error here means that no support is present)...
   Testing for arithmetic support...OK.
   Testing for arrays support...OK.

Estimated positions:
        32768
        98304
        163840
Testing: 1
Testing: 2
Testing: 32768
**********************
Found: 32768
Some parameters are tunable on the first couple lines of the source of e2sbf. For example, with ``silent=on'' you can make e2sbf to be more silent while with ``stop_on_first_match=false'' you can tell e2sbf to scan the whole partition for all valid superblocks (in which case, you would probably use | grep 'Found:' |less). When this latest parameter is ``true'', e2sbf returns a status of 0 if a valid superblock is found, while a different number is returned for each different error (look at the script if you need the complete list of error codes).

Watch out that the script will really slow down when a superblock is found, since it will wait for e2fsck to terminate (it is really slow, especially if the file system is damaged).

If ``-n'' is correctly accepted by your e2fs tools, e2sbf will not modify your file system nor write on it in any case (finding a good superblock is a read-only test).


Next Previous Contents