1 @c This is part of the paxutils manual.
2 @c Copyright (C) 2007--2022 Free Software Foundation, Inc.
3 @c This file is distributed under GFDL 1.1 or any later version
4 @c published by the Free Software Foundation.
6 @cindex Device numbers, changing
7 @cindex snapshot files, editing
8 @cindex snapshot files, fixing device numbers
9 Various situations can cause device numbers to change: upgrading your
10 kernel version, reconfiguring your hardware, loading kernel modules in a
11 different order, using virtual volumes that are assembled dynamically
12 (such as with @acronym{LVM} or @acronym{RAID}), hot-plugging drives
13 (e.g. external USB or Firewire drives), etc. In the majority of
14 cases this change is unnoticed by the users. However, it influences
15 @command{tar} incremental backups: the device number is stored in tar
16 snapshot files (@pxref{Snapshot Files}) and is used to determine whether
17 the file has changed since the last backup. If the device numbers
18 change for some reason, by default the next backup you run will be a
22 @pindex tar-snapshot-edit
23 To minimize the impact in these cases, GNU @command{tar} comes with
24 the @command{tar-snapshot-edit} utility for inspecting and updating
25 device numbers in snapshot files. (The utility, written by
26 Dustin J.@: Mitchell, is also available from the
27 @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/tar-snapshot-edit.html,
28 @GNUTAR{} home page}.)
30 To obtain a summary of the device numbers found in the snapshot file, run
33 $ @kbd{tar-snapshot-edit @var{snapfile}}
37 where @var{snapfile} is the name of the snapshot file (you can supply as many
38 files as you wish in a single command line). You can then compare the
39 numbers across snapshot files, or against those currently in use on the
40 live filesystem (using @command{ls -l} or @command{stat}).
42 Assuming the device numbers have indeed changed, it's often possible
43 to simply tell @GNUTAR{} to ignore the device number when processing the
44 incremental snapshot files for these backups, using the
45 @option{--no-check-device} option (@pxref{device numbers}).
47 Alternatively, you can use the @command{tar-edit-snapshot} script's
48 @option{-r} option to update all occurrences of the given device
49 number in the snapshot file(s). It takes a single argument
51 @samp{@var{olddev}-@var{newdev}}, where @var{olddev} is the device number
52 used in the snapshot file, and @var{newdev} is the corresponding new device
53 number. Both numbers may be specified in hex (e.g., @samp{0xfe01}),
54 decimal (e.g., @samp{65025}), or as a major:minor number pair (e.g.,
55 @samp{254:1}). To change several device numbers at once, specify them
56 in a single comma-separated list, as in
57 @option{-r 0x3060-0x4500,0x307-0x4600}.
59 Before updating the snapshot file, it is a good idea to create a backup
60 copy of it. This is accomplished by @samp{-b} option. The name of the
61 backup file is obtained by appending @samp{~} to the original file name.
65 $ @kbd{tar-snapshot-edit root_snap.0 boot_snap.0}
67 Detected snapshot file version: 2
69 Device 0x0000 occurs 1 times.
70 Device 0x0003 occurs 1 times.
71 Device 0x0005 occurs 1 times.
72 Device 0x0013 occurs 1 times.
73 Device 0x6801 occurs 1 times.
74 Device 0x6803 occurs 6626 times.
75 Device 0xfb00 occurs 1 times.
78 Detected snapshot file version: 2
80 Device 0x6801 occurs 3 times.
81 $ @kbd{tar-snapshot-edit -b -r 0x6801-0x6901,0x6803-0x6903 root_snap.0 boot_snap.0}
83 Detected snapshot file version: 2
88 Detected snapshot file version: 2