dump

package: dump

title: dump(8)

summary: ext2/3/4 filesystem backup

text:
# dump(8)

## NAME
dump - ext2/3/4 filesystem backup

## SYNOPSIS
dump [-level#] [-ackMnqSuv] [-A file] [-B records] [-b blocksize] [-d density] [-D file] [-e inode numbers] [-E file] [-f file] [-F script] [-h level] [-I nr errors] [-jcompression level] [-L label] [-Q file] [-s feet] [-T date] [-y] [-zcompression level] files-to-dump

dump [-W | -w]

## DESCRIPTION
Dump examines files on an ext2/3/4 filesystem and determines which files need to be backed up. These files are copied to the given disk, tape or other storage medium for safe keeping (see the -f option below for doing remote backups). A dump that is larger than the output medium is broken into multiple volumes. On most media the size is determined by writing until an end-of-media indication is returned.

On media that cannot reliably return an end-of-media indication (such as some cartridge tape drives), each volume is of a fixed size; the actual size is determined by specifying cartridge media, or via the tape size, density and/or block count options below. By default, the same output file name is used for each volume after prompting the operator to change media.

files-to-dump is either a mountpoint of a filesystem or a list of files and directories to be backed up as a subset of a filesystem. In the former case, either the path to a mounted filesystem or the device of an unmounted filesystem can be used. In the latter case, certain restrictions are placed on the backup: -u is not allowed, the only dump level that is supported is 0 and all the files and directories must reside on the same filesystem.

## OPTIONS
The following options are supported by dump:

-level#

The dump level (any integer). A level 0, full backup, specified by -0 guarantees the entire file system is copied (but see also the -h option below). A level number above 0, incremental backup, tells dump to copy all files new or modified since the last dump of a lower level. The default level is 0. Historically only levels 0 to 9 were usable in dump, this version is able to understand any integer as a dump level.

-a

“auto-size”. Bypass all tape length calculations, and write until an end-of-media indication is returned. This works best for most modern tape drives, and is the default. Use of this option is particularly recommended when appending to an existing tape, or using a tape drive with hardware compression (where you can never be sure about the compression ratio).

-A archive_file

Archive a dump table-of-contents in the specified archive_file to be used by restore(8) to determine whether a file is in the dump file that is being restored.

-b blocksize

The number of kilobytes per dump record. The default blocksize is 10, unless the -d option has been used to specify a tape density of 6250BPI or more, in which case the default blocksize is 32. Th maximal value is 1024. Note however that, since the IO system slices all requests into chunks of MAXBSIZE (which can be as low as 64kB), you can experience problems with dump(8) and restore(8) when using a higher value, depending on your kernel and/or libC versions.

-B records

The number of 1 kB blocks per volume. Not normally required, as dump can detect end-of-media. When the specified size is reached, dump waits for you to change the volume. This option overrides the calculation of tape size based on length and density. If compression is on this limits the size of the compressed output per volume. Multiple values may be given as a single argument separated by commas. Each value will be used for one dump volume in the order listed; if dump creates more volumes than the number of values given, the last value will be used for the remaining volumes. This is useful for filling up already partially filled media (and then continuing with full size volumes on empty media) or mixing media of different sizes.

-c

Change the defaults for use with a cartridge tape drive, with a density of 8000 bpi, and a length of 1700 feet. Specifying a cartridge drive overrides the end-of-media detection.

-d density

Set tape density to density. The default is 1600BPI. Specifying a tape density overrides the end-of-media detection.

-D file

Set the path name of the file storing the information about the previous full and incremental dumps. The default location is /etc/dumpdates.

-e inodes

Exclude inodes from the dump. The inodes parameter is a comma separated list of inode numbers (you can use stat(1) to find the inode number for a file or directory).

-E file

Read list of inodes to be excluded from the dump from the text file file. The file file should be an ordinary file containing inode numbers separated by newlines.

-f file

Write the backup to file; file may be a special device file like /dev/st0 (a tape drive), /dev/rsd1c (a floppy disk drive), an ordinary file, or - (the standard output). Multiple file names may be given as a single argument separated by commas. Each file will be used for one dump volume in the order listed; if the dump requires more volumes than the number of names given, the last file name will used for all remaining volumes after prompting for media changes. If the name of the file is of the form host:file or user@host:file dump writes to the named file on the remote host (which should already exist, dump doesn't create a new remote file) using rmt(8). The default path name of the remote rmt(8) program is /etc/rmt; this can be overridden by the environment variable RMT.

-F script

Run script at the end of each tape (except for the last one). The device name and the current volume number are passed on the command line. The script must return 0 if dump should continue without asking the user to change the tape, 1 if dump should continue but ask the user to change the tape. Any other exit code will cause dump to abort. For security reasons, dump reverts back to the real user ID and the real group ID before running the script.

-h level

Honor the user nodump flag UF_NODUMP only for dumps at or above the given level. The default honor level is 1, so that incremental backups omit such files but full backups retain them.

-I nr errors

By default, dump will ignore the first 32 read errors on the file system before asking for operator intervention. You can change this using this flag to any value. This is useful when running dump on an active filesystem where read errors simply indicate an inconsistency between the mapping and dumping passes.

A value of 0 means that all read errors will be ignored.

-jcompression level

Compress every block to be written on the tape using bzlib library. This option will work only when dumping to a file or pipe or, when dumping to a tape drive, if the tape drive is capable of writing variable length blocks. You will need at least the 0.4b24 version of restore in order to extract compressed tapes. Tapes written using compression will not be compatible with the BSD tape format. The (optional) parameter specifies the compression level bzlib will use. The default compression level is 2. If the optional parameter is specified, there should be no white space between the option letter and the parameter.

-k

Use Kerberos authentication to talk to remote tape servers. (Only available if this option was enabled when dump was compiled.)

-L label

The user-supplied text string label is placed into the dump header, where tools like restore(8) and file(8) can access it. Note that this label is limited to be at most LBLSIZE (currently 16) characters, which must include the terminating \0.

-m

If this flag is specified, dump will optimise the output for inodes having been changed but not modified since the last dump ('changed' and 'modified' have the meaning defined in stat(2) ). For those inodes, dump will save only the metadata, instead of saving the entire inode contents. Inodes which are either directories or have been modified since the last dump are saved in a regular way. Uses of this flag must be consistent, meaning that either every dump in an incremental dump set have the flag, or no one has it.

If you use this option, be aware that many programs that unpack files from archives (e.g. tar, rpm, unzip, dpkg) may set files' mtimes to dates in the past. Files installed in this way may not be dumped correctly using "dump -m" if the modified mtime is earlier than the previous level dump.

Tapes written using such 'metadata only' inodes will not be compatible with the BSD tape format or older versions of restore.

-M

Enable the multi-volume feature. The name specified with f is treated as a prefix and dump writes in sequence to <prefix>001, <prefix>002 etc. This can be useful when dumping to files on an ext2/3/4 partition, in order to bypass the 2GB file size limitation.

-n

Whenever dump requires operator attention, notify all operators in the group operator by means similar to a wall(1).

-q

Make dump abort immediately whenever operator attention is required, without prompting in case of write errors, tape changes etc.

-Q file

Enable the Quick File Access support. Tape positions for each inode are stored into the file file which is used by restore (if called with parameter -Q and the filename) to directly position the tape at the file restore is currently working on. This saves hours when restoring single files from large backups, saves the tapes and the drive's head.

It is recommended to set up the st driver to return logical tape positions rather than physical before calling dump/restore with parameter -Q. Since not all tape devices support physical tape positions those tape devices return an error during dump/restore when the st driver is set to the default physical setting. Please see the st(4) man page, option MTSETDRVBUFFER , or the mt(1) man page, on how to set the driver to return logical tape positions.

Before calling restore with parameter -Q, always make sure the st driver is set to return the same type of tape position used during the call to dump. Otherwise restore may be confused.

This option can be used when dumping to local tapes (see above) or to local files.

-s feet

Attempt to calculate the amount of tape needed at a particular density. If this amount is exceeded, dump prompts for a new tape. It is recommended to be a bit conservative on this option. The default tape length is 2300 feet. Specifying the tape size overrides end-of-media detection.

-S

Size estimate. Determine the amount of space that is needed to perform the dump without actually doing it, and display the estimated number of bytes it will take. This is useful with incremental dumps to determine how many volumes of media will be needed.

-T date

Use the specified date as the starting time for the dump instead of the time determined from looking in /etc/dumpdates . The format of date is the same as that of ctime(3) followed by an rfc822 timezone specification: either a plus or minus sign followed by two digits for the number of hours and two digits for the minutes. For example, -0800 for eight hours west of Greenwich or +0230 for two hours and a half east of Greenwich. This timezone offset takes into account daylight savings time (if applicable to the timezone): UTC offsets when daylight savings time is in effect will be different than offsets when daylight savings time is not in effect. For backward compatibility, if no timezone is specified, a local time is assumed. This option is useful for automated dump scripts that wish to dump over a specific period of time. The -T option is mutually exclusive from the -u option.

-u

Update the file /etc/dumpdates after a successful dump. The format of /etc/dumpdates is readable by people, consisting of one free format record per line: filesystem name, increment level and ctime(3) format dump date followed by a rfc822 timezone specification (see the -u option for details). If no timezone offset is specified, times are interpreted as local. Whenever the file is written, all dates in the file are converted to the local time zone, without changing the UTC times. There may be only one entry per filesystem at each level. The file /etc/dumpdates may be edited to change any of the fields, if necessary.

-v

The -v (verbose) makes dump to print extra information which could be helpful in debug sessions.

-W

Dump tells the operator what file systems need to be dumped. This information is gleaned from the files /etc/dumpdates and /etc/fstab. The -W option causes dump to print out, for all file systems in /etc/dumpdates , and recognized file systems in /etc/mtab and /etc/fstab. the most recent dump date and level, and highlights those that should be dumped. If the -W option is set, all other options are ignored, and dump exits immediately.

-w

Is like -W, but prints only recognized filesystems in /etc/mtab and /etc/fstab which need to be dumped.

-y

Compress every block to be written to the tape using the lzo library. This doesn't compress as well as the zlib library but it's much faster. This option will work only when dumping to a file or pipe or, when dumping to a tape drive, if the tape drive is capable of writing variable length blocks. You will need at least the 0.4b34 version of restore in order to extract compressed tapes. Tapes written using compression will not be compatible with the BSD tape format.

-zcompression level

Compress every block to be written on the tape using zlib library. This option will work only when dumping to a file or pipe or, when dumping to a tape drive, if the tape drive is capable of writing variable length blocks. You will need at least the 0.4b22 version of restore in order to extract compressed tapes. Tapes written using compression will not be compatible with the BSD tape format. The (optional) parameter specifies the compression level zlib will use. The default compression level is 2. If the optional parameter is specified, there should be no white space between the option letter and the parameter.

Dump requires operator intervention on these conditions: end of tape, end of dump, tape write error, tape open error or disk read error (if there is more than a threshold of nr errors). In addition to alerting all operators implied by the -n key, dump interacts with the operator on dump's control terminal at times when dump can no longer proceed, or if something is grossly wrong. All questions dump poses must be answered by typing “yes” or “no”, appropriately.

Since making a dump involves a lot of time and effort for full dumps, dump checkpoints itself at the start of each tape volume. If writing that volume fails for some reason, dump will, with operator permission, restart itself from the checkpoint after the old tape has been rewound and removed, and a new tape has been mounted.

Dump tells the operator what is going on at periodic intervals, including usually low estimates of the number of blocks to write, the number of tapes it will take, the time to completion, and the time to the tape change. The output is verbose, so that others know that the terminal controlling dump is busy, and will be for some time.

In the event of a catastrophic disk event, the time required to restore all the necessary backup tapes or files to disk can be kept to a minimum by staggering the incremental dumps. An efficient method of staggering incremental dumps to minimize the number of tapes follows:

—

Always start with a level 0 backup, for example:

/sbin/dump -0u -f /dev/st0 /usr/src

This should be done at set intervals, say once a month or once every two months, and on a set of fresh tapes that is saved forever.

—

After a level 0, dumps of active file systems are taken on a daily basis, with this sequence of dump levels:

3 2 5 4 7 6 9 8 9 9 ...

For the daily dumps, it should be possible to use a fixed number of tapes for each day, used on a weekly basis. Each week, a level 1 dump is taken, and the daily Hanoi sequence repeats beginning with 3. For weekly dumps, another fixed set of tapes per dumped file system is used, also on a cyclical basis.

After several months or so, the daily and weekly tapes should get rotated out of the dump cycle and fresh tapes brought in.

Another backup strategy is the Tower of Hanoi sequence, which reuses older tapes in a way that for newer dates the available restore points are more frequent, then for older dates (see https://en.wikipedia.org/wiki/Backup_rotation_scheme for additional information).

(The 4.3BSD option syntax is implemented for backward compatibility but is not documented here.)

## ENVIRONMENT
TAPE

If no -f option was specified, dump will use the device specified via TAPE as the dump device. TAPE may be of the form tapename, host:tapename, or user@host:tapename.

RMT

The environment variable RMT will be used to determine the pathname of the remote rmt(8) program.

RSH

Dump uses the contents of this variable to determine the name of the remote shell command to use when doing remote backups (rsh, ssh etc.). If this variable is not set, rcmd(3) will be used, but only root will be able to do remote backups.

## FILES
/dev/st0

default tape unit to dump to

/etc/dumpdates

dump date records

/etc/fstab

dump table: file systems and frequency

/etc/mtab

dump table: mounted file systems

/etc/group

to find group operator

## SEE ALSO
fstab(5), restore(8), rmt(8)

## DIAGNOSTICS
Many, and verbose.

## COMPATIBILITY
The format of the /etc/dumpdates file has changed in release 0.4b34, however, the file will be read correctly with either pre-0.4b34 or 0.4b34 and later versions of dump provided that the machine on which dump is run did not change timezones (which should be a fairly rare occurrence).

## EXIT STATUS
Dump exits with zero status on success. Startup errors are indicated with an exit code of 1; abnormal termination is indicated with an exit code of 3.

## BUGS
It might be considered a bug that this version of dump can only handle ext2/3/4 filesystems. Specifically, it does not work with FAT filesystems.

Fewer than 32 read errors (change this with -I) on the filesystem are ignored. If noticing read errors is important, the output from dump can be parsed to look for lines that contain the text 'read error'.

When a read error occurs, dump prints out the corresponding physical disk block and sector number and the ext2/3/4 logical block number. It doesn't print out the corresponding file name or even the inode number. The user has to use debugfs(8), commands ncheck and icheck to translate the ext2blk number printed out by dump into an inode number, then into a file name.

Each reel requires a new process, so parent processes for reels already written just hang around until the entire tape is written.

The estimated number of tapes is not correct if compression is on.

It would be nice if dump knew about the dump sequence, kept track of the tapes scribbled on, told the operator which tape to mount when, and provided more assistance for the operator running restore.

Dump cannot do remote backups without being run as root, due to its security history. Presently, it works if you set it setuid (like it used to be), but this might constitute a security risk. Note that you can set RSH to use a remote shell program instead.

## AUTHOR
The dump/restore backup suite was ported to Linux's Second Extended File System by Remy Card <card@Linux.EU.Org>. He maintained the initial versions of dump (up and including 0.4b4, released in January 1997).

Starting with 0.4b5, the new maintainer is Stelian Pop <stelian@popies.net>.

## AVAILABILITY
The dump/restore backup suite is available from <https://dump.sourceforge.io>

## HISTORY
A dump command appeared in Version 6 AT&T UNIX.


rdump

title: rdump(8)

text:
# rdump(8)

See the file dump.8.

branch: sisyphus


restore

title: restore(8)

text:
# restore(8)

## NAME
restore - restore files or file systems from backups made with dump

## SYNOPSIS
restore -C [-cdHklMvVy] [-b blocksize] [-D filesystem] [-f file] [-F script] [-L limit] [-s fileno] [-T directory]

restore -i [-acdhHklmMNouvVy] [-A file] [-b blocksize] [-f file] [-F script] [-Q file] [-s fileno] [-T directory]

restore -P file [-acdhHklmMNuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory] [-X filelist] [ file ... ]

restore -R [-cdHklMNuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]

restore -r [-cdHklMNuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]

restore -t [-cdhHklMNuvVy] [-A file] [-b blocksize] [-f file] [-F script] [-Q file] [-s fileno] [-T directory] [-X filelist] [ file ... ]

restore -x [-adchHklmMNouvVy] [-A file] [-b blocksize] [-f file] [-F script] [-Q file] [-s fileno] [-T directory] [-X filelist] [ file ... ]

## DESCRIPTION
The restore command performs the inverse function of dump(8). A full backup of a file system may be restored and subsequent incremental backups layered on top of it. Single files and directory subtrees may be restored from full or partial backups. Restore works across a network; to do this see the -f flag described below. Other arguments to the command are file or directory names specifying the files that are to be restored. Unless the -h flag is specified (see below), the appearance of a directory name refers to the files and (recursively) subdirectories of that directory.

Exactly one of the following flags is required:

-C

This mode allows comparison of files from a dump. Restore reads the backup and compares its contents with files present on the disk. It first changes its working directory to the root of the filesystem that was dumped and compares the tape with the files in its new current directory. See also the -L flag described below.

-i

This mode allows interactive restoration of files from a dump. After reading in the directory information from the dump, restore provides a shell like interface that allows the user to move around the directory tree selecting files to be extracted. The available commands are given below; for those commands that require an argument, the default is the current directory.

add [arg]

The current directory or specified argument is added to the list of files to be extracted. If a directory is specified, then it and all its descendants are added to the extraction list (unless the -h flag is specified on the command line). Files that are on the extraction list are prepended with a “*” when they are listed by ls.

cd arg

Change the current working directory to the specified argument.

delete [arg]

The current directory or specified argument is deleted from the list of files to be extracted. If a directory is specified, then it and all its descendants are deleted from the extraction list (unless the -h flag is specified on the command line). The most expedient way to extract most of the files from a directory is to add the directory to the extraction list and then delete those files that are not needed.

extract

All files on the extraction list are extracted from the dump. Restore will ask which volume the user wishes to mount. The fastest way to extract a few files is to start with the last volume and work towards the first volume.

help

List a summary of the available commands.

ls [arg]

List the current or specified directory. Entries that are directories are appended with a “/”. Entries that have been marked for extraction are prepended with a “*”. If the verbose flag is set, the inode number of each entry is also listed.

pwd

Print the full pathname of the current working directory.

quit

Restore immediately exits, even if the extraction list is not empty.

setmodes

All directories that have been added to the extraction list have their owner, modes, and times set; nothing is extracted from the dump. This is useful for cleaning up after a restore has been prematurely aborted.

verbose

The sense of the -v flag is toggled. When set, the verbose flag causes the ls command to list the inode numbers of all entries. It also causes restore to print out information about each file as it is extracted.

-P file

Restore creates a new Quick File Access file file from an existing dump file without restoring its contents.

-R

Restore requests a particular tape of a multi-volume set on which to restart a full restore (see the -r flag below). This is useful if the restore has been interrupted.

-r

Restore (rebuild) a file system. The target file system should be made pristine with mke2fs(8), mounted, and the user cd'd into the pristine file system before starting the restoration of the initial level 0 backup. If the level 0 restores successfully, the -r flag may be used to restore any necessary incremental backups on top of the level 0. The -r flag precludes an interactive file extraction and can be detrimental to one's health (not to mention the disk) if not used carefully. An example:

mke2fs /dev/sda1 mount /dev/sda1 /mnt

cd /mnt

restore rf /dev/st0

Note that restore leaves a file restoresymtable in the root directory to pass information between incremental restore passes. This file should be removed when the last incremental has been restored.

Restore, in conjunction with mke2fs(8) and dump(8), may be used to modify file system parameters such as size or block size.

-t

The names of the specified files are listed if they occur on the backup. If no file argument is given, the root directory is listed, which results in the entire content of the backup being listed, unless the -h flag has been specified. Note that the -t flag replaces the function of the old dumpdir(8) program. See also the -X option below.

-x

The named files are read from the given media. If a named file matches a directory whose contents are on the backup and the -h flag is not specified, the directory is recursively extracted. The owner, modification time, and mode are restored (if possible). If no file argument is given, the root directory is extracted, which results in the entire content of the backup being extracted, unless the -h flag has been specified. See also the -X option below.

## OPTIONS
The following additional options may be specified:

-a

In -i or -x mode, restore does ask the user for the volume number on which the files to be extracted are supposed to be (in order to minimise the time by reading only the interesting volumes). The -a option disables this behaviour and reads all the volumes starting with 1. This option is useful when the operator does not know on which volume the files to be extracted are and/or when he prefers the longer unattended mode rather than the shorter interactive mode.

-A archive_file

Read the table of contents from archive_file instead of the media. This option can be used in combination with the -t, -i, or -x options, making it possible to check whether files are on the media without having to mount the media.

-b blocksize

The number of kilobytes per dump record. If the -b option is not specified, restore tries to determine the media block size dynamically.

-c

Normally, restore will try to determine dynamically whether the dump was made from an old (pre-4.4) or new format file system. The -c flag disables this check, and only allows reading a dump in the old format.

-d

The -d (debug) flag causes restore to print debug information.

-D filesystem

The -D flag allows the user to specify the filesystem name when using restore with the -C option to check the backup.

-f file

Read the backup from file; file may be a special device file like /dev/st0 (a tape drive), /dev/sda1 (a disk drive), an ordinary file, or - (the standard input). If the name of the file is of the form host:file or user@host:file, restore reads from the named file on the remote host using rmt(8).

-F script

Run script at the beginning of each tape. The device name and the current volume number are passed on the command line. The script must return 0 if restore should continue without asking the user to change the tape, 1 if restore should continue but ask the user to change the tape. Any other exit code will cause restore to abort. For security reasons, restore reverts back to the real user ID and the real group ID before running the script.

-h

Extract the actual directory, rather than the files that it references. This prevents hierarchical restoration of complete subtrees from the dump.

-H hash_size

Use a hashtable having the specified number of entries for storing the directories entries instead of a linked list. This hashtable will considerably speed up inode lookups (visible especially in interactive mode when adding/removing files from the restore list), but at the price of much more memory usage. The default value is 1, meaning no hashtable is used.

-k

Use Kerberos authentication when contacting the remote tape server. (Only available if this options was enabled when restore was compiled.)

-l

When doing remote restores, assume the remote file is a regular file (instead of a tape device). If you're restoring a remote compressed file, you will need to specify this option or restore will fail to access it correctly.

-L limit

The -L flag allows the user to specify a maximal number of miscompares when using restore with the -C option to check the backup. If this limit is reached, restore will abort with an error message. A value of 0 (the default value) disables the check.

-m

Extract by inode numbers rather than by file name. This is useful if only a few files are being extracted, and one wants to avoid regenerating the complete pathname to the file.

-M

Enables the multi-volume feature (for reading dumps made using the -M option of dump). The name specified with -f is treated as a prefix and restore tries to read in sequence from <prefix>001, <prefix>002 etc.

-N

The -N flag causes restore to perform a full execution as requested by one of -i, -R, -r, t or x command without actually writing any file on disk.

-o

The -o flag causes restore to automatically restore the current directory permissions without asking the operator whether to do so in one of -i or -x modes.

-Q file

Use the file file in order to read tape position as stored using the dump Quick File Access mode, in one of -i, -x or -t mode.

It is recommended to set up the st driver to return logical tape positions rather than physical before calling dump/restore with parameter -Q. Since not all tape devices support physical tape positions those tape devices return an error during dump/restore when the st driver is set to the default physical setting. Please see the st(4) man page, option MTSETDRVBUFFER , or the mt(1) man page, on how to set the driver to return logical tape positions.

Before calling restore with parameter -Q, always make sure the st driver is set to return the same type of tape position used during the call to dump. Otherwise restore may be confused.

This option can be used when restoring from local or remote tapes (see above) or from local or remote files.

-s fileno

Read from the specified fileno on a multi-file tape. File numbering starts at 1.

-T directory

The -T flag allows the user to specify a directory to use for the storage of temporary files. The default value is /tmp. This flag is most useful when restoring files after having booted from a floppy. There might be little or no space on the floppy filesystem, but another source of space might exist.

-u

When creating certain types of files, restore may generate a warning diagnostic if they already exist in the target directory. To prevent this, the -u (unlink) flag causes restore to remove old entries before attempting to create new ones.

-v

Normally restore does its work silently. The -v (verbose) flag causes it to type the name of each file it treats preceded by its file type.

-V

Enables reading multi-volume non-tape mediums like CDROMs.

-X filelist

Read list of files to be listed or extracted from the text file filelist in addition to those specified on the command line. This can be used in conjunction with the -t or -x commands. The file filelist should contain file names separated by newlines. filelist may be an ordinary file or - (the standard input).

-y

Do not ask the user whether to abort the restore in the event of an error. Always try to skip over the bad block(s) and continue.

(The 4.3BSD option syntax is implemented for backward compatibility but is not documented here.)

## DIAGNOSTICS
Complains if it gets a read error. If y has been specified, or the user responds y, restore will attempt to continue the restore.

If a backup was made using more than one tape volume, restore will notify the user when it is time to mount the next volume. If the -x or -i flag has been specified, restore will also ask which volume the user wishes to mount. The fastest way to extract a few files is to start with the last volume, and work towards the first volume.

There are numerous consistency checks that can be listed by restore. Most checks are self-explanatory or can “never happen”. Common errors are given below:

Converting to new file system format

A dump tape created from the old file system has been loaded. It is automatically converted to the new file system format.

<filename>: not found on tape

The specified file name was listed in the tape directory, but was not found on the tape. This is caused by tape read errors while looking for the file, and from using a dump tape created on an active file system.

expected next file <inumber>, got <inumber>

A file that was not listed in the directory showed up. This can occur when using a dump created on an active file system.

Incremental dump too low

When doing an incremental restore, a dump that was written before the previous incremental dump, or that has too low an incremental level has been loaded.

Incremental dump too high

When doing an incremental restore, a dump that does not begin its coverage where the previous incremental dump left off, or that has too high an incremental level has been loaded.

Tape read error while restoring <filename>

Tape read error while skipping over inode <inumber>

Tape read error while trying to resynchronize

A tape (or other media) read error has occurred. If a file name is specified, its contents are probably partially wrong. If an inode is being skipped or the tape is trying to resynchronize, no extracted files have been corrupted, though files may not be found on the tape.

resync restore, skipped <num> blocks

After a dump read error, restore may have to resynchronize itself. This message lists the number of blocks that were skipped over.

## EXIT STATUS
Restore exits with zero status on success. Tape errors are indicated with an exit code of 1.

When doing a comparison of files from a dump, an exit code of 2 indicates that some files were modified or deleted since the dump was made.

## ENVIRONMENT
If the following environment variable exists it will be utilized by restore:

TAPE

If no -f option was specified, restore will use the device specified via TAPE as the dump device. TAPE may be of the form tapename, host:tapename or user@host:tapename.

TMPDIR

The directory given in TMPDIR will be used instead of /tmp to store temporary files.

RMT

The environment variable RMT will be used to determine the pathname of the remote rmt(8) program.

RSH

Restore uses the contents of this variable to determine the name of the remote shell command to use when doing a network restore (rsh, ssh etc.). If this variable is not set, rcmd(3) will be used, but only root will be able to do a network restore.

## FILES
/dev/st0

the default tape drive

/tmp/rstdir*

file containing directories on the tape

/tmp/rstmode*

owner, mode, and time stamps for directories

./restoresymtable

information passed between incremental restores

## SEE ALSO
dump(8), mount(8), mke2fs(8), rmt(8)

## BUGS
Restore can get confused when doing incremental restores from dumps that were made on active file systems.

A level 0 dump must be done after a full restore. Because restore runs in user code, it has no control over inode allocation; thus a full dump must be done to get a new set of directories reflecting the new inode numbering, even though the content of the files is unchanged.

The temporary files /tmp/rstdir* and /tmp/rstmode* are generated with a unique name based on the date of the dump and the process ID (see mktemp(3)), except when -r or -R is used. Because -R allows you to restart a -r operation that may have been interrupted, the temporary files should be the same across different processes. In all other cases, the files are unique because it is possible to have two different dumps started at the same time, and separate operations shouldn't conflict with each other.

To do a network restore, you have to run restore as root or use a remote shell replacement (see RSH variable). This is due to the previous security history of dump and restore. ( restore is written to be setuid root, but we are not certain all bugs are gone from the code - run setuid at your own risk.)

At the end of restores in -i or -x modes (unless -o option is in use), restore will ask the operator whether to set the permissions on the current directory. If the operator confirms this action, the permissions on the directory from where restore was launched will be replaced by the permissions on the dumped root inode. Although this behaviour is not really a bug, it has proven itself to be confusing for many users, so it is recommended to answer 'no', unless you're performing a full restore and you do want to restore the permissions on '/'.

It should be underlined that because it runs in user code, restore , when run with the -C option, sees the files as the kernel presents them, whereas dump sees all the files on a given filesystem. In particular, this can cause some confusion when comparing a dumped filesystem a part of which is hidden by a filesystem mounted on top of it.

## AUTHOR
The dump/restore backup suite was ported to Linux's Second Extended File System by Remy Card <card@Linux.EU.Org>. He maintained the initial versions of dump (up and including 0.4b4, released in January 1997).

Starting with 0.4b5, the new maintainer is Stelian Pop <stelian@popies.net>.

## AVAILABILITY
The dump/restore backup suite is available from <https://dump.sourceforge.io>

## HISTORY
The restore command appeared in 4.2BSD.


rrestore

title: rrestore(8)

text:
# rrestore(8)

See the file restore.8.


btrfs-extent-same

package: duperemove

title: btrfs-extent-same(8)

summary: directly access the FIDEDUPRANGE ioctl

text:
# btrfs-extent-same(8)

## NAME
btrfs-extent-same - directly access the FIDEDUPRANGE ioctl

## SYNOPSIS
btrfs-extent-same extent-len file1 offset1 file2 offset2 [...]

## DESCRIPTION
btrfs-extent-same is a wrapper around the FIDEDUPRANGE ioctl. extent-len and all offsets should be specified in bytes.

## SEE ALSO
•

filesystems(5)

•

btrfs(8)

•

ioctl_fideduprange(2)

•

xfs_io(8)


duperemove

title: duperemove(8)

text:
# duperemove(8)

## NAME
duperemove - Find duplicate regions in files and submit them for deduplication

## SYNOPSIS
duperemove options files...

## DESCRIPTION
duperemove is a simple tool for finding duplicated regions in files and submitting them for deduplication. When given a list of files it will hash their contents and compare those hashes to each other, finding and categorizing regions that match each other. When given the -d option, duperemove will submit those regions for deduplication using the Linux kernel FIDEDUPERANGE ioctl.

duperemove computes hashes for each files extents as well as for the whole file’s content. Optionally, per-block hashes can be computed.

duperemove can store the hashes it computes in a hashfile. If given an existing hashfile, duperemove will only compute hashes for those files which have changed since the last run. Thus you can run duperemove repeatedly on your data as it changes, without having to re-checksum unchanged data. For more on hashfiles see the --hashfile option below as well as the Examples section.

duperemove can also take input from the fdupes program, see the --fdupes option below.

## GENERAL
Duperemove has two major modes of operation, one of which is a subset of the other.

### Readonly / Non-deduplicating Mode
When run without -d (the default) duperemove will print out one or more tables of matching extents it has determined would be ideal candidates for deduplication. As a result, readonly mode is useful for seeing what duperemove might do when run with -d.

Generally, duperemove does not concern itself with the underlying representation of the extents it processes. Some of them could be compressed, undergoing I/O, or even have already been deduplicated. In dedupe mode, the kernel handles those details and therefore we try not to replicate that work.

### Deduping Mode
This functions similarly to readonly mode with the exception that the duplicated extents found in our “read, hash, and compare” step will actually be submitted for deduplication. Extents that have already been deduped will be skipped. An estimate of the total data deduplicated will be printed after the operation is complete. This estimate is calculated by comparing the total amount of shared bytes in each file before and after the dedupe.

## OPTIONS

### Common options
files can refer to a list of regular files and directories or be a hyphen (-) to read them from standard input. If a directory is specified, all regular files within it will also be scanned. Duperemove can also be told to recursively scan directories with the -r switch.

-r

Enable recursive dir traversal.

-d

De-dupe the results - only works on btrfs and xfs. Use this option twice to disable the check and try to run the ioctl anyway.

--hashfile=hashfile

Use a file for storage of hashes instead of memory. This option drastically reduces the memory footprint of duperemove and is recommended when your data set is more than a few files large. Hashfiles are also reusable, allowing you to further reduce the amount of hashing done on subsequent dedupe runs.

If hashfile does not exist it will be created. If it exists, duperemove will check the file paths stored inside of it for changes. Files which have changed will be rescanned and their updated hashes will be written to the hashfile. Deleted files will be removed from the hashfile.

New files are only added to the hashfile if they are discoverable via the files argument. For that reason you probably want to provide the same files list and -r arguments on each run of duperemove. The file discovery algorithm is efficient and will only visit each file once, even if it is already in the hashfile.

Adding a new path to a hashfile is as simple as adding it to the files argument.

When deduping from a hashfile, duperemove will avoid deduping files which have not changed since the last dedupe.

-B N, --batchsize=N

Run the deduplication phase every N files newly scanned. This greatly reduces memory usage for large dataset, or when you are doing partial extents lookup, but reduces multithreading efficiency.

Because of that small overhead, its value shall be selected based on the average file size and blocksize.

The default is a sane value for extents-only lookups, while you can go as low as 1 if you are running duperemove on very large files (like virtual machines etc).

By default, batching is set to 1024.

-h

Print numbers in human-readable format.

-q

Quiet mode. Duperemove will only print errors and a short summary of any dedupe.

-v

Be verbose.

--help

Prints help text.

### Advanced options
--fdupes

Run in fdupes mode. With this option you can pipe the output of fdupes to duperemove to dedupe any duplicate files found. When receiving a file list in this manner, duperemove will skip the hashing phase.

-L

Print all files in the hashfile and exit. Requires the --hashfile option. Will print additional information about each file when run with -v.

-R files ..

Remove file from the db and exit. Duperemove will read the list from standard input if a hyphen (-) is provided. Requires the --hashfile option.

Note: If you are piping filenames from another duperemove instance it is advisable to do so into a temporary file first as running duperemove simultaneously on the same hashfile may corrupt that hashfile.

--skip-zeroes

Read data blocks and skip any zeroed blocks, useful for speedup duperemove, but can prevent deduplication of zeroed files.

-b size

Use the specified block size for reading file extents. Defaults to 128K.

--io-threads=N

Use N threads for I/O. This is used by the file hashing and dedupe stages. Default is automatically detected based on number of host cpus.

--cpu-threads=N

Use N threads for CPU bound tasks. This is used by the duplicate extent finding stage. Default is automatically detected based on number of host cpus.

Note: Hyperthreading can adversely affect performance of the extent finding stage. If duperemove detects an Intel CPU with hyperthreading it will use half the number of cores reported by the system for cpu bound tasks.

--dedupe-options=options

Comma separated list of options which alter how we dedupe. Prepend `no' to an option in order to turn it off.

[no]partial

Duperemove can often find more dedupe by comparing portions of extents to each other. This can be a lengthy, CPU intensive task so it is turned off by default. Using --batchsize is recommended to limit the negative effects of this option.

The code behind this option is under active development and as a result the semantics of the partial argument may change.

[no]same

Defaults to on. Allow dedupe of extents within the same file.

[no]only_whole_files

Defaults to off. Duperemove will only work on full file. Both extent-based and block-based deduplication will be disabled. The hashfile will be smaller, some operations will be faster, but the deduplication efficiency will indeed be reduced.

--read-hashes=hashfile

This option is primarily for testing. See the --hashfile option if you want to use hashfiles.

Read hashes from a hashfile. A file list is not required with this option. Dedupe can be done if duperemove is run from the same base directory as is stored in the hash file (basically duperemove has to be able to find the files).

--write-hashes=hashfile

This option is primarily for testing. See the --hashfile option if you want to use hashfiles.

Write hashes to a hashfile. These can be read in at a later date and deduped from.

--debug

Print debug messages, forces -v if selected.

--hash-threads=N

Deprecated, see --io-threads above.

--exclude=PATTERN

You can exclude certain files and folders from the deduplication process. This might be benefical for skipping subvolume snapshot mounts, for instance. Unless you provide a full path for exclusion, the exclude will be relative to the current working directory. Another thing to keep in mind is that shells usually expand glob pattern so the passed in pattern ought to also be quoted. Taking everything into consideration the correct way to pass an exclusion pattern is duperemove --exclude "/path/to/dir/file*" /path/to/dir

## EXAMPLES

### Simple Usage
Dedupe the files in directory /foo, recurse into all subdirectories. You only want to use this for small data sets:

```
duperemove -dr /foo

```

Use duperemove with fdupes to dedupe identical files below directory foo:

```
fdupes -r /foo | duperemove --fdupes

```

### Using Hashfiles
Duperemove can optionally store the hashes it calculates in a hashfile. Hashfiles have two primary advantages - memory usage and re-usability. When using a hashfile, duperemove will stream computed hashes to it, instead of main memory.

If Duperemove is run with an existing hashfile, it will only scan those files which have changed since the last time the hashfile was updated. The files argument controls which directories duperemove will scan for newly added files. In the simplest usage, you rerun duperemove with the same parameters and it will only scan changed or newly added files - see the first example below.

Dedupe the files in directory foo, storing hashes in foo.hash. We can run this command multiple times and duperemove will only checksum and dedupe changed or newly added files:

```
duperemove -dr --hashfile=foo.hash foo/

```

Don’t scan for new files, only update changed or deleted files, then dedupe:

```
duperemove -dr --hashfile=foo.hash

```

Add directory bar to our hashfile and discover any files that were recently added to foo:

```
duperemove -dr --hashfile=foo.hash foo/ bar/

```

List the files tracked by foo.hash:

```
duperemove -L --hashfile=foo.hash

```

## FAQ

### Is duperemove safe for my data?
Yes. To be specific, duperemove does not deduplicate the data itself. It simply finds candidates for dedupe and submits them to the Linux kernel FIDEDUPERANGE ioctl. In order to ensure data integrity, the kernel locks out other access to the file and does a byte-by-byte compare before proceeding with the dedupe.

### Is is safe to interrupt the program (Ctrl-C)?
Yes. The Linux kernel deals with the actual data. On Duperemove’ side, a transactional database engine is used. The result is that you should be able to ctrl-c the program at any point and re-run without experiencing corruption of your hashfile. In case of a bug, your hashfile may be broken, but your data never will.

### I got two identical files, why are they not deduped?
Duperemove by default works on extent granularity. What this means is if there are two files which are logically identical (have the same content) but are laid out on disk with different extent structure they won’t be deduped. For example if 2 files are 128k each and their content are identical but one of them consists of a single 128k extent and the other of 2 * 64k extents then they won’t be deduped. This behavior is dependent on the current implementation and is subject to change as duperemove is being improved.

### What is the cost of deduplication?
Deduplication will lead to increased fragmentation. The blocksize chosen can have an effect on this. Larger blocksizes will fragment less but may not save you as much space. Conversely, smaller block sizes may save more space at the cost of increased fragmentation.

### How can I find out my space savings after a dedupe?
Duperemove will print out an estimate of the saved space after a dedupe operation for you.

You can get a more accurate picture by running `btrfs fi df' before and after each duperemove run.

Be careful about using the `df' tool on btrfs - it is common for space reporting to be `behind' while delayed updates get processed, so an immediate df after deduping might not show any savings.

### Why is the total deduped data report an estimate?
At the moment duperemove can detect that some underlying extents are shared with other files, but it can not resolve which files those extents are shared with.

Imagine duperemove is examining a series of files and it notes a shared data region in one of them. That data could be shared with a file outside of the series. Since duperemove can’t resolve that information it will account the shared data against our dedupe operation while in reality, the kernel might deduplicate it further for us.

### Why are my files showing dedupe but my disk space is not shrinking?
This is a little complicated, but it comes down to a feature in Btrfs called bookending. The Btrfs wiki explains this in detail.

Essentially though, the underlying representation of an extent in Btrfs can not be split (with small exception). So sometimes we can end up in a situation where a file extent gets partially deduped (and the extents marked as shared) but the underlying extent item is not freed or truncated.

### Is there an upper limit to the amount of data duperemove can process?
Duperemove is fast at reading and cataloging data. Dedupe runs will be memory limited unless the --hashfile option is used. --hashfile allows duperemove to temporarily store duplicated hashes to disk, thus removing the large memory overhead and allowing for a far larger amount of data to be scanned and deduped. Realistically though you will be limited by the speed of your disks and cpu. In those situations where resources are limited you may have success by breaking up the input data set into smaller pieces.

When using a hashfile, duperemove will only store duplicate hashes in memory. During normal operation then the hash tree will make up the largest portion of duperemove memory usage. As of Duperemove v0.11 hash entries are 88 bytes in size. If you know the number of duplicate blocks in your data set you can get a rough approximation of memory usage by multiplying with the hash entry size.

Actual performance numbers are dependent on hardware - up to date testing information is kept on the duperemove wiki (see below for the link).

### How large of a hashfile will duperemove create?
Hashfiles are essentially sqlite3 database files with several tables, the largest of which are the files and extents tables. Each extents table entry is about 72 bytes though that may grow as features are added. The size of a files table entry depends on the file path but a good estimate is around 270 bytes per file. The number of extents in a data set is directly proportional to file fragmentation level.

If you know the total number of extents and files in your data set then you can calculate the hashfile size as:

```
Hashfile Size = Num Hashes * 72 + Num Files * 270

```

Using a real world example of 1TB (8388608 128K blocks) of data over 1000 files:

```
8388608 * 72 + 270 * 1000 = 755244720 or about 720MB for 1TB spread over 1000 files.

```

Note that none of this takes database overhead into account.

## NOTES
Deduplication is currently only supported by the btrfs and xfs filesystem.

The Duperemove project page can be found on github

There is also a wiki

## SEE ALSO
•

hashstats(8)

•

filesystems(5)

•

btrfs(8)

•

xfs(8)

•

fdupes(1)

•

ioctl_fideduprange(2)


hashstats

title: hashstats(8)

text:
# hashstats(8)

## NAME
hashstats - Print information about a duperemove hashfile

## SYNOPSIS
hashstats options hashfile

## DESCRIPTION
hashfile extracts stats or raw data from a hashfile. The hashfile should be a file generated by running duperemove(8) with the --hashfile or --write-hashes option.

## OPTIONS
-n NUM

Print top NUM hashes, sorted by bucket size. Default is 10.

-a

Print all hashes (overrides -n, above)

-B

Show blocks hashes. By default, extents hashes are shown.

-b

Print info on each block within our hash buckets.

-l

Print a list of all files

## SEE ALSO
•

duperemove(8)


show-shared-extents

title: show-shared-extents(8)

summary: Show extents that are shared.

text:
# show-shared-extents(8)

## Name
show-shared-extents - Show extents that are shared.

## SYNOPSIS
show-shared-extents files ...

## DESCRIPTION
Count the sum of bytes shared in a file.

An extent is reported as shared if it has more than one reference.

## SEE ALSO
•

filefrag(8)


badblocks

title: badblocks(8)

summary: search a device for bad blocks

text:
# badblocks(8)

## NAME
badblocks - search a device for bad blocks

## SYNOPSIS
badblocks [ -svwnfBX ] [ -b block_size ] [ -c blocks_at_once ] [ -d read_delay_factor ] [ -e max_bad_blocks ] [ -i input_file ] [ -o output_file ] [ -p num_passes ] [ -t test_pattern ] device [ last_block ] [ first_block ]

## DESCRIPTION
badblocks is used to search for bad blocks on a device (usually a disk partition). device is the special file corresponding to the device (e.g /dev/hdc1). last_block is the last block to be checked; if it is not specified, the last block on the device is used as a default. first_block is an optional parameter specifying the starting block number for the test, which allows the testing to start in the middle of the disk. If it is not specified the first block on the disk is used as a default.

Important note: If the output of badblocks is going to be fed to the e2fsck or mke2fs programs, it is important that the block size is properly specified, since the block numbers which are generated are very dependent on the block size in use by the file system. For this reason, it is strongly recommended that users not run badblocks directly, but rather use the -c option of the e2fsck and mke2fs programs.

## OPTIONS
-b block_size

Specify the size of blocks in bytes. The default is 1024.

-c number of blocks

is the number of blocks which are tested at a time. The default is 64.

-d read delay factor

This parameter, if passed and non-zero, will cause bad blocks to sleep between reads if there were no errors encountered in the read operation; the delay will be calculated as a percentage of the time it took for the read operation to be performed. In other words, a value of 100 will cause each read to be delayed by the amount the previous read took, and a value of 200 by twice the amount.

-e max bad block count

Specify a maximum number of bad blocks before aborting the test. The default is 0, meaning the test will continue until the end of the test range is reached.

-f

Normally, badblocks will refuse to do a read/write or a non-destructive test on a device which is mounted, since either can cause the system to potentially crash and/or damage the file system even if it is mounted read-only. This can be overridden using the -f flag, but should almost never be used --- if you think you're smarter than the badblocks program, you almost certainly aren't. The only time when this option might be safe to use is if the /etc/mtab file is incorrect, and the device really isn't mounted.

-i input_file

Read a list of already existing known bad blocks. Badblocks will skip testing these blocks since they are known to be bad. If input_file is specified as "-", the list will be read from the standard input. Blocks listed in this list will be omitted from the list of new bad blocks produced on the standard output or in the output file. The -b option of dumpe2fs(8) can be used to retrieve the list of blocks currently marked bad on an existing file system, in a format suitable for use with this option.

-n

Use non-destructive read-write mode. By default only a non-destructive read-only test is done. This option must not be combined with the -w option, as they are mutually exclusive.

-o output_file

Write the list of bad blocks to the specified file. Without this option, badblocks displays the list on its standard output. The format of this file is suitable for use by the -l option in e2fsck(8) or mke2fs(8).

-p num_passes

Repeat scanning the disk until there are no new blocks discovered in num_passes consecutive scans of the disk. Default is 0, meaning badblocks will exit after the first pass.

-s

Show the progress of the scan by writing out rough percentage completion of the current badblocks pass over the disk. Note that badblocks may do multiple test passes over the disk, in particular if the -p or -w option is requested by the user.

-t test_pattern

Specify a test pattern to be read (and written) to disk blocks. The test_pattern may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word "random", which specifies that the block should be filled with a random bit pattern. For read/write (-w) and non-destructive (-n) modes, one or more test patterns may be specified by specifying the -t option for each test pattern desired. For read-only mode only a single pattern may be specified and it may not be "random". Read-only testing with a pattern assumes that the specified pattern has previously been written to the disk - if not, large numbers of blocks will fail verification. If multiple patterns are specified then all blocks will be tested with one pattern before proceeding to the next pattern.

-v

Verbose mode. Will write the number of read errors, write errors and data- corruptions to stderr.

-w

Use write-mode test. With this option, badblocks scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on every block of the device, reading every block and comparing the contents. This option may not be combined with the -n option, as they are mutually exclusive.

-B

Use buffered I/O and do not use Direct I/O, even if it is available.

-X

Internal flag only to be used by e2fsck(8) and mke2fs(8). It bypasses the exclusive mode in-use device safety check.

## WARNING
Never use the -w option on a device containing an existing file system. This option erases data! If you want to do write-mode testing on an existing file system, use the -n option instead. It is slower, but it will preserve your data.

The -e option will cause badblocks to output a possibly incomplete list of bad blocks. Therefore it is recommended to use it only when one wants to know if there are any bad blocks at all on the device, and not when the list of bad blocks is wanted.

## AUTHOR
badblocks was written by Remy Card <Remy.Card@linux.org>. Current maintainer is Theodore Ts'o <tytso@alum.mit.edu>. Non-destructive read/write test implemented by David Beattie <dbeattie@softhome.net>.

## AVAILABILITY
badblocks is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.

## SEE ALSO
e2fsck(8), mke2fs(8)


debugfs

title: debugfs(8)

summary: ext2/ext3/ext4 file system debugger

text:
# debugfs(8)

## NAME
debugfs - ext2/ext3/ext4 file system debugger

## SYNOPSIS
debugfs [ -DVwcin ] [ -b blocksize ] [ -s superblock ] [ -f cmd_file ] [ -R request ] [ -d data_source_device ] [ -z undo_file ] [ device ]

## DESCRIPTION
The debugfs program is an interactive file system debugger. It can be used to examine and change the state of an ext2, ext3, or ext4 file system.

device is a block device (e.g., /dev/sdXX) or a file containing the file system.

## OPTIONS
-w

Specifies that the file system should be opened in read-write mode. Without this option, the file system is opened in read-only mode.

-n

Disables metadata checksum verification. This should only be used if you believe the metadata to be correct despite the complaints of e2fsprogs.

-c

Specifies that the file system should be opened in catastrophic mode, in which the inode and group bitmaps are not read initially. This can be useful for file systems with significant corruption, but because of this, catastrophic mode forces the file system to be opened read-only.

-i

Specifies that device represents an ext2 image file created by the e2image program. Since the ext2 image file only contains the superblock, block group descriptor, block and inode allocation bitmaps, and the inode table, many debugfs commands will not function properly. Warning: no safety checks are in place, and debugfs may fail in interesting ways if commands such as ls, dump, etc. are tried without specifying the data_source_device using the -d option. debugfs is a debugging tool. It has rough edges!

-d data_source_device

Used with the -i option, specifies that data_source_device should be used when reading blocks not found in the ext2 image file. This includes data, directory, and indirect blocks.

-b blocksize

Forces the use of the given block size (in bytes) for the file system, rather than detecting the correct block size automatically. (This option is rarely needed; it is used primarily when the file system is extremely badly damaged/corrupted.)

-s superblock

Causes the file system superblock to be read from the given block number, instead of using the primary superblock (located at an offset of 1024 bytes from the beginning of the file system). If you specify the -s option, you must also provide the blocksize of the file system via the -b option. (This option is rarely needed; it is used primarily when the file system is extremely badly damaged/corrupted.)

-f cmd_file

Causes debugfs to read in commands from cmd_file, and execute them. When debugfs is finished executing those commands, it will exit.

-D

Causes debugfs to open the device using Direct I/O, bypassing the buffer cache. Note that some Linux devices, notably device mapper as of this writing, do not support Direct I/O.

-R request

Causes debugfs to execute the single command request, and then exit.

-V

print the version number of debugfs and exit.

-z undo_file

Before overwriting a file system block, write the old contents of the block to an undo file. This undo file can be used with e2undo(8) to restore the old contents of the file system should something go wrong. If the empty string is passed as the undo_file argument, the undo file will be written to a file named debugfs-device.e2undo in the directory specified via the E2FSPROGS_UNDO_DIR environment variable. WARNING: The undo file cannot be used to recover from a power or system crash.

## SPECIFYING FILES
Many debugfs commands take a filespec as an argument to specify an inode (as opposed to a pathname) in the file system which is currently opened by debugfs. The filespec argument may be specified in two forms. The first form is an inode number surrounded by angle brackets, e.g., <2>. The second form is a pathname; if the pathname is prefixed by a forward slash ('/'), then it is interpreted relative to the root of the file system which is currently opened by debugfs. If not, the pathname is interpreted relative to the current working directory as maintained by debugfs. This may be modified by using the debugfs command cd.

## COMMANDS
This is a list of the commands which debugfs supports.

blocks filespec

Print the blocks used by the inode filespec to stdout.

bmap [ -a ] filespec logical_block [physical_block]

Print or set the physical block number corresponding to the logical block number logical_block in the inode filespec. If the -a flag is specified, try to allocate a block if necessary.

block_dump '[ -x ] [-f filespec] block_num

Dump the file system block given by block_num in hex and ASCII format to the console. If the -f option is specified, the block number is relative to the start of the given filespec. If the -x option is specified, the block is interpreted as an extended attribute block and printed to show the structure of extended attribute data structures.

cat filespec

Dump the contents of the inode filespec to stdout.

cd filespec

Change the current working directory to filespec.

chroot filespec

Change the root directory to be the directory filespec.

close [-a]

Close the currently open file system. If the -a option is specified, write out any changes to the superblock and block group descriptors to all of the backup superblocks, not just to the master superblock.

clri filespec

Clear the contents of the inode filespec.

copy_inode source_inode destination_inode

Copy the contents of the inode structure in source_inode and use it to overwrite the inode structure at destination_inode.

dirsearch filespec filename

Search the directory filespec for filename.

dirty [-clean]

Mark the file system as dirty, so that the superblocks will be written on exit. Additionally, clear the superblock's valid flag, or set it if -clean is specified.

dump [-p] filespec out_file

Dump the contents of the inode filespec to the output file out_file. If the -p option is given set the owner, group and permissions information on out_file to match filespec.

dump_mmp [mmp_block]

Display the multiple-mount protection (mmp) field values. If mmp_block is specified then verify and dump the MMP values from the given block number, otherwise use the s_mmp_block field in the superblock to locate and use the existing MMP block.

dx_hash [-cv] [-h hash_alg] [-s hash_seed] filename

Calculate the directory hash of filename. The -c option will casefold the filename before calculating the hash. The -v option will make the dx_hash command more verbose and print the hash algorithm and hash seed to calculate the hash. If a file system is open, use the hash_seed and default hash_algorithm used by the file system, although these can be overridden by the -h and -s options. The hash algorithm specified with -h may be legacy, half_md4, or tea. The hash seed specified with -s must be in UUID format.

dump_extents [-n] [-l] filespec

Dump the extent tree of the inode filespec. The -n flag will cause dump_extents to only display the interior nodes in the extent tree. The -l flag will cause dump_extents to only display the leaf nodes in the extent tree.

(Please note that the length and range of blocks for the last extent in an interior node is an estimate by the extents library functions, and is not stored in file system data structures. Hence, the values displayed may not necessarily by accurate and does not indicate a problem or corruption in the file system.)

dump_unused

Dump unused blocks which contain non-null bytes.

ea_get [-f outfile]|[-xVC] [-r] filespec attr_name

Retrieve the value of the extended attribute attr_name in the file filespec and write it either to stdout or to outfile.

ea_list filespec

List the extended attributes associated with the file filespec to standard output.

ea_set [-f infile] [-r] filespec attr_name attr_value

Set the value of the extended attribute attr_name in the file filespec to the string value attr_value or read it from infile.

ea_rm filespec attr_names...

Remove the extended attribute attr_name from the file filespec.

expand_dir filespec

Expand the directory filespec.

fallocate filespec start_block [end_block]

Allocate and map uninitialized blocks into filespec between logical block start_block and end_block, inclusive. If end_block is not supplied, this function maps until it runs out of free disk blocks or the maximum file size is reached. Existing mappings are left alone.

feature [fs_feature] [-fs_feature] ...

Set or clear various file system features in the superblock. After setting or clearing any file system features that were requested, print the current state of the file system feature set.

filefrag [-dvr] filespec

Print the number of contiguous extents in filespec. If filespec is a directory and the -d option is not specified, filefrag will print the number of contiguous extents for each file in the directory. The -v option will cause filefrag print a tabular listing of the contiguous extents in the file. The -r option will cause filefrag to do a recursive listing of the directory.

find_free_block [count [goal]]

Find the first count free blocks, starting from goal and allocate it. Also available as ffb.

find_free_inode [dir [mode]]

Find a free inode and allocate it. If present, dir specifies the inode number of the directory which the inode is to be located. The second optional argument mode specifies the permissions of the new inode. (If the directory bit is set on the mode, the allocation routine will function differently.) Also available as ffi.

freeb block [count]

Mark the block number block as not allocated. If the optional argument count is present, then count blocks starting at block number block will be marked as not allocated.

freefrag [-c chunk_kb]

Report free space fragmentation on the currently open file system. If the -c option is specified then the filefrag command will print how many free chunks of size chunk_kb can be found in the file system. The chunk size must be a power of two and be larger than the file system block size.

freei filespec [num]

Free the inode specified by filespec. If num is specified, also clear num-1 inodes after the specified inode.

get_quota quota_type id

Display quota information for given quota type (user, group, or project) and ID.

help

Print a list of commands understood by debugfs.

htree_dump filespec

Dump the hash-indexed directory filespec, showing its tree structure.

icheck block ...

Print a listing of the inodes which use the one or more blocks specified on the command line.

inode_dump [-b]|[-e]|[-x] filespec

Print the contents of the inode data structure in hex and ASCII format. The -b option causes the command to only dump the contents of the i_blocks array. The -e option causes the command to only dump the contents of the extra inode space, which is used to store in-line extended attributes. The -x option causes the command to dump the extra inode space interpreted and extended attributes. This is useful to debug corrupted inodes containing extended attributes.

imap filespec

Print the location of the inode data structure (in the inode table) of the inode filespec.

init_filesys device blocksize

Create an ext2 file system on device with device size blocksize. Note that this does not fully initialize all of the data structures; to do this, use the mke2fs(8) program. This is just a call to the low-level library, which sets up the superblock and block descriptors.

journal_close

Close the open journal.

journal_open [-c] [-v ver] [-f ext_jnl]

Opens the journal for reading and writing. Journal checksumming can be enabled by supplying -c; checksum formats 2 and 3 can be selected with the -v option. An external journal can be loaded from ext_jnl.

journal_run

Replay all transactions in the open journal.

journal_write [-b blocks] [-r revoke] [-c] file

Write a transaction to the open journal. The list of blocks to write should be supplied as a comma-separated list in blocks; the blocks themselves should be readable from file. A list of blocks to revoke can be supplied as a comma-separated list in revoke. By default, a commit record is written at the end; the -c switch writes an uncommitted transaction.

kill_file filespec

Deallocate the inode filespec and its blocks. Note that this does not remove any directory entries (if any) to this inode. See the rm(1) command if you wish to unlink a file.

lcd directory

Change the current working directory of the debugfs process to directory on the native file system.

list_quota quota_type

Display quota information for given quota type (user, group, or project).

ln filespec dest_file

Create a link named dest_file which is a hard link to filespec. Note this does not adjust the inode reference counts.

logdump [-acsOS] [-b block] [-n num_trans ] [-i filespec] [-f journal_file] [output_file]

Dump the contents of the ext3 journal. By default, dump the journal inode as specified in the superblock. However, this can be overridden with the -i option, which dumps the journal from the internal inode given by filespec. A regular file containing journal data can be specified using the -f option. Finally, the -s option utilizes the backup information in the superblock to locate the journal.

The -S option causes logdump to print the contents of the journal superblock.

The -a option causes the logdump to print the contents of all of the descriptor blocks. The -b option causes logdump to print all journal records that refer to the specified block. The -c option will print out the contents of all of the data blocks selected by the -a and -b options.

The -O option causes logdump to display old (checkpointed) journal entries. This can be used to try to track down journal problems even after the journal has been replayed.

The -n option causes logdump to continue past a journal block which is missing a magic number. Instead, it will stop only when the entire log is printed or after num_trans transactions.

ls [-l] [-c] [-d] [-p] [-r] filespec

Print a listing of the files in the directory filespec. The -c flag causes directory block checksums (if present) to be displayed. The -d flag will list deleted entries in the directory. The -l flag will list files using a more verbose format. The -p flag will list the files in a format which is more easily parsable by scripts, as well as making it more clear when there are spaces or other non-printing characters at the end of filenames. The -r flag will force the printing of the filename, even if it is encrypted.

list_deleted_inodes [limit]

List deleted inodes, optionally limited to those deleted within limit seconds ago. Also available as lsdel.

This command was useful for recovering from accidental file deletions for ext2 file systems. Unfortunately, it is not useful for this purpose if the files were deleted using ext3 or ext4, since the inode's data blocks are no longer available after the inode is released.

modify_inode filespec

Modify the contents of the inode structure in the inode filespec. Also available as mi.

mkdir filespec

Make a directory.

mknod filespec [p|[[c|b] major minor]]

Create a special device file (a named pipe, character or block device). If a character or block device is to be made, the major and minor device numbers must be specified.

ncheck [-c] inode_num ...

Take the requested list of inode numbers, and print a listing of pathnames to those inodes. The -c flag will enable checking the file type information in the directory entry to make sure it matches the inode's type.

open [-weficD] [-b blocksize] [-d image_filename] [-s superblock] [-z undo_file] device

Open a file system for editing. The -f flag forces the file system to be opened even if there are some unknown or incompatible file system features which would normally prevent the file system from being opened. The -e flag causes the file system to be opened in exclusive mode. The -b, -c, -d, -i, -s, -w, and -D options behave the same as the command-line options to debugfs.

orphan_inodes

List the orphan inodes in the file system.

punch filespec start_blk [end_blk]

Delete the blocks in the inode ranging from start_blk to end_blk. If end_blk is omitted then this command will function as a truncate command; that is, all of the blocks starting at start_blk through to the end of the file will be deallocated.

symlink filespec target

Make a symbolic link.

pwd

Print the current working directory.

quit

Quit debugfs

rdump directory[...] destination

Recursively dump directory, or multiple directories, and all its contents (including regular files, symbolic links, and other directories) into the named destination, which should be an existing directory on the native file system.

rm pathname

Unlink pathname. If this causes the inode pointed to by pathname to have no other references, deallocate the file. This command functions as the unlink() system call.

rmdir filespec

Remove the directory filespec.

setb block [count]

Mark the block number block as allocated. If the optional argument count is present, then count blocks starting at block number block will be marked as allocated.

set_block_group bgnum field value

Modify the block group descriptor specified by bgnum so that the block group descriptor field field has value value. Also available as set_bg.

set_current_time time

Set current time in seconds since Unix epoch to use when setting file system fields.

seti filespec [num]

Mark inode filespec as in use in the inode bitmap. If num is specified, also set num-1 inodes after the specified inode.

set_inode_field filespec field value

Modify the inode specified by filespec so that the inode field field has value value. The list of valid inode fields which can be set via this command can be displayed by using the command: set_inode_field -l Also available as sif.

set_mmp_value field value

Modify the multiple-mount protection (MMP) data so that the MMP field field has value value. The list of valid MMP fields which can be set via this command can be displayed by using the command: set_mmp_value -l Also available as smmp.

set_super_value field value

Set the superblock field field to value. The list of valid superblock fields which can be set via this command can be displayed by using the command: set_super_value -l Also available as ssv.

show_debugfs_params

Display debugfs parameters such as information about currently opened file system.

show_super_stats [-h]

List the contents of the super block and the block group descriptors. If the -h flag is given, only print out the superblock contents. Also available as stats.

stat filespec

Display the contents of the inode structure of the inode filespec.

supported_features

Display file system features supported by this version of debugfs.

testb block [count]

Test if the block number block is marked as allocated in the block bitmap. If the optional argument count is present, then count blocks starting at block number block will be tested.

testi filespec

Test if the inode filespec is marked as allocated in the inode bitmap.

undel <inode_number> [pathname]

Undelete the specified inode number (which must be surrounded by angle brackets) so that it and its blocks are marked in use, and optionally link the recovered inode to the specified pathname. The e2fsck command should always be run after using the undel command to recover deleted files.

Note that if you are recovering a large number of deleted files, linking the inode to a directory may require the directory to be expanded, which could allocate a block that had been used by one of the yet-to-be-undeleted files. So it is safer to undelete all of the inodes without specifying a destination pathname, and then in a separate pass, use the debugfs link command to link the inode to the destination pathname, or use e2fsck to check the file system and link all of the recovered inodes to the lost+found directory.

unlink pathname

Remove the link specified by pathname to an inode. Note this does not adjust the inode reference counts.

write source_file out_file

Copy the contents of source_file into a newly-created file in the file system named out_file.

zap_block [-f filespec] [-o offset] [-l length] [-p pattern] block_num

Overwrite the block specified by block_num with zero (NUL) bytes, or if -p is given use the byte specified by pattern. If -f is given then block_num is relative to the start of the file given by filespec. The -o and -l options limit the range of bytes to zap to the specified offset and length relative to the start of the block.

zap_block [-f filespec] [-b bit] block_num

Bit-flip portions of the physical block_num. If -f is given, then block_num is a logical block relative to the start of filespec.

## ENVIRONMENT VARIABLES
DEBUGFS_PAGER, PAGER

The debugfs program always pipes the output of the some commands through a pager program. These commands include: show_super_stats (stats), list_directory (ls), show_inode_info (stat), list_deleted_inodes (lsdel), and htree_dump. The specific pager can explicitly specified by the DEBUGFS_PAGER environment variable, and if it is not set, by the PAGER environment variable.

Note that since a pager is always used, the less(1) pager is not particularly appropriate, since it clears the screen before displaying the output of the command and clears the output the screen when the pager is exited. Many users prefer to use the less(1) pager for most purposes, which is why the DEBUGFS_PAGER environment variable is available to override the more general PAGER environment variable.

## AUTHOR
debugfs was written by Theodore Ts'o <tytso@mit.edu>.

## SEE ALSO
dumpe2fs(8), tune2fs(8), e2fsck(8), mke2fs(8), ext4(5)


title: dumpe2fs(8)

text:
# dumpe2fs(8)

## NAME
dumpe2fs - dump ext2/ext3/ext4 file system information

## SYNOPSIS
dumpe2fs [ -bfghixV ] [ -o superblock=superblock ] [ -o blocksize=blocksize ] device

## DESCRIPTION
dumpe2fs prints the super block and blocks group information for the file system present on device.

The device specifier can either be a filename (i.e., /dev/sda1), or a LABEL or UUID specifier: "LABEL=volume-label" or "UUID=uuid". (i.e., LABEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).

Note: When used with a mounted file system, the printed information may be old or inconsistent.

## OPTIONS
-b

print the blocks which are reserved as bad in the file system.

-o superblock=superblock

use the block superblock when examining the file system. This option is not usually needed except by a file system wizard who is examining the remains of a very badly corrupted file system.

-o blocksize=blocksize

use blocks of blocksize bytes when examining the file system. This option is not usually needed except by a file system wizard who is examining the remains of a very badly corrupted file system.

-f

force dumpe2fs to display a file system even though it may have some file system feature flags which dumpe2fs may not understand (and which can cause some of dumpe2fs's display to be suspect).

-g

display the group descriptor information in a machine readable colon-separated value format. The fields displayed are the group number; the number of the first block in the group; the superblock location (or -1 if not present); the range of blocks used by the group descriptors (or -1 if not present); the block bitmap location; the inode bitmap location; and the range of blocks used by the inode table.

-h

only display the superblock information and not any of the block group descriptor detail information.

-i

display the file system data from an image file created by e2image, using device as the pathname to the image file.

-m

If the mmp feature is enabled on the file system, check if device is in use by another node, see e2mmpstatus(8) for full details. If used together with the -i option, only the MMP block information is printed.

-x

print the detailed group information block numbers in hexadecimal format

-V

print the version number of dumpe2fs and exit.

## EXIT CODE
dumpe2fs exits with a return code of 0 if the operation completed without errors. It will exit with a non-zero return code if there are any errors, such as problems reading a valid superblock, bad checksums, or if the device is in use by another node and -m is specified.

## BUGS
You may need to know the physical file system structure to understand the output.

## AUTHOR
dumpe2fs was written by Remy Card <Remy.Card@linux.org>. It is currently being maintained by Theodore Ts'o <tytso@alum.mit.edu>.

## AVAILABILITY
dumpe2fs is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.

## SEE ALSO
e2fsck(8), e2mmpstatus(8), mke2fs(8), tune2fs(8). ext4(5)


title: e2freefrag(8)

text:
# e2freefrag(8)

## NAME
e2freefrag - report free space fragmentation information

## SYNOPSIS
e2freefrag [ -c chunk_kb ] [ -h ] filesys

## DESCRIPTION
e2freefrag is used to report free space fragmentation on ext2/3/4 file systems. filesys is the file system device name (e.g. /dev/hdc1, /dev/md0). The e2freefrag program will scan the block bitmap information to check how many free blocks are present as contiguous and aligned free space. The percentage of contiguous free blocks of size and of alignment chunk_kb is reported. It also displays the minimum/maximum/average free chunk size in the file system, along with a histogram of all free chunks. This information can be used to gauge the level of free space fragmentation in the file system.

## OPTIONS
-c chunk_kb

If a chunk size is specified, then e2freefrag will print how many free chunks of size chunk_kb are available in units of kilobytes (Kb). The chunk size must be a power of two and be larger than file system block size.

-h

Print the usage of the program.

## EXAMPLE
\# e2freefrag /dev/vgroot/lvhome

Device: /dev/vgroot/lvhome

Blocksize: 4096 bytes

Total blocks: 1504085

Free blocks: 292995 (19.5%)

Min. free extent: 4 KB

Max. free extent: 24008 KB

Avg. free extent: 252 KB

HISTOGRAM OF FREE EXTENT SIZES:

Extent Size Range : Free extents Free Blocks Percent

4K... 8K- : 704 704 0.2%

8K... 16K- : 810 1979 0.7%

16K... 32K- : 843 4467 1.5%

32K... 64K- : 579 6263 2.1%

64K... 128K- : 493 11067 3.8%

128K... 256K- : 394 18097 6.2%

256K... 512K- : 281 25477 8.7%

512K... 1024K- : 253 44914 15.3%

1M... 2M- : 143 51897 17.7%

2M... 4M- : 73 50683 17.3%

4M... 8M- : 37 52417 17.9%

8M... 16M- : 7 19028 6.5%

16M... 32M- : 1 6002 2.0%

## AUTHOR
This version of e2freefrag was written by Rupesh Thakare, and modified by Andreas Dilger <adilger@sun.com>, and Kalpak Shah.

## SEE ALSO
debugfs(8), dumpe2fs(8), e2fsck(8)