Tar level-1 dumps are the same size as level-0 dumps

From wiki.zmanda.com
Revision as of 19:54, 15 June 2007 by Dustin (talk | contribs) (writeup of the situation as I understand it)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Problem

After a hardware change, level-1 dumps are level-0 sized, because GNU tar sees every file as changed. For a highly leveraged Amanda installation, where the total data being backed up is much larger than available tape storage, this can cause dumps to fail badly, as Amanda cannot fit dumps for all DLEs on tape.

Explanation

Amanda uses index files not only to find files on tapes, but to allow GNU tar to calculate what has changed on a partition from day to day. When tar runs, it takes an index file describing the previous dump as input, and produces a new index file describing the new run.

Among other data about files that are backed up, GNU tar's index files contain the device number of the device on which the file is located. For example, if the /data partition is on /dev/sda2, then the device number might be 8,2; you can see the device numbers with ls, operating directly on the underlying device:

# df /data
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2               988244    698452    239592  75% /data
# ls -al /dev/sda2
brw-rw---- 1 root disk 8, 2 May 23 00:27 /dev/sda2

This particular problem occurs when the device number for a particular piece of hardware changes. Some device numbers, notably those for device mapper (used by the Logical Volume Manager on Linux), are assigned dynamically at boot time, and changing a machine's hardware configuration (by e.g., adding a new USB CD drive) can affect those numbers. The result is that, on the next run, tar sees different device numbers for every file, and interprets that to mean that the file has changed.

Solutions

There are a few long-term solutions to this problem that may occur, but are not currently planned:

  • the kernel developers can assign permanent numbers for LVM and the other dynamic but common devices in the LANANA
  • GNU tar could have an option to ignore device numbers, although there are legitimate arguments for including them in the indices

You can also stabilize the device numbers yourself on Linux, at least for the device mapper, assuming you're using modules. Just add

options dm-mod major=238

to /etc/modprobe.conf.

Finally, if your device numbers have changed, and you need to manually update the index files, you can do that too. Tar contains a Perl script which can "edit" index files, swapping one device number for another. See http://www.gnu.org/software/tar/utils/tar-snapshot-edit.html (the utility is not posted, as of this writing, but should be there soon; consult the amanda mailing lists if you need a copy immediately).

Links