| 1 |
// This document describes all aspects of the system disk layout generation in |
| 2 |
// Relax-and-Recover. |
| 3 |
|
| 4 |
= Layout configuration |
| 5 |
Jeroen Hoekx <[email protected]> |
| 6 |
2011-09-10 |
| 7 |
|
| 8 |
== General overview |
| 9 |
The disk layout generation code in Relax-and-Recover is responsible for the |
| 10 |
faithful recreation of the disk layout of the original system. It gathers |
| 11 |
information about any component in the system layout. Components supported in |
| 12 |
Relax-and-Recover include: |
| 13 |
|
| 14 |
- Partitions |
| 15 |
- Logical volume management (LVM) |
| 16 |
- Software RAID (MD) |
| 17 |
- Encrypted volumes (LUKS) |
| 18 |
- Multipath disks |
| 19 |
- Swap |
| 20 |
- Filesystems |
| 21 |
- Btrfs Volumes |
| 22 |
- DRBD |
| 23 |
- HP SmartArray controllers |
| 24 |
|
| 25 |
Relax-and-Recover detects dependencies between these components. |
| 26 |
|
| 27 |
During the rescue media creation phase, Relax-and-Recover centralizes all |
| 28 |
information in one file. During recovery, that file is used to generate the |
| 29 |
actual commands to recreate the components. Relax-and-Recover allows |
| 30 |
customizations and manual editing in all these phases. |
| 31 |
|
| 32 |
== Layout information gathered during rescue image creation |
| 33 |
Layout information is stored in +/var/lib/rear/layout/disklayout.conf+. The term 'layout file' in this document refers to this particular file. |
| 34 |
|
| 35 |
Consider the information from the following system as an example: |
| 36 |
---------------------------------- |
| 37 |
disk /dev/sda 160041885696 msdos |
| 38 |
#disk /dev/sdb 320072933376 msdos |
| 39 |
#disk /dev/sdc 1999696297984 msdos |
| 40 |
part /dev/sda 209682432 32768 primary boot /dev/sda1 |
| 41 |
part /dev/sda 128639303680 209719296 primary lvm /dev/sda2 |
| 42 |
part /dev/sda 31192862720 128849022976 primary none /dev/sda3 |
| 43 |
#part /dev/sdb 162144912384 32256 primary none /dev/sdb1 |
| 44 |
#part /dev/sdb 152556666880 162144944640 primary none /dev/sdb2 |
| 45 |
#part /dev/sdb 5371321856 314701611520 primary boot /dev/sdb3 |
| 46 |
#part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1 |
| 47 |
#part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2 |
| 48 |
#lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784 |
| 49 |
lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544 |
| 50 |
#lvmgrp /dev/backup 4096 220764 904249344 |
| 51 |
lvmgrp /dev/system 4096 30669 125620224 |
| 52 |
#lvmvol /dev/backup backup 12800 104857600 |
| 53 |
#lvmvol /dev/backup externaltemp 38400 314572800 |
| 54 |
lvmvol /dev/system root 2560 20971520 |
| 55 |
lvmvol /dev/system home 5120 41943040 |
| 56 |
lvmvol /dev/system var 2560 20971520 |
| 57 |
lvmvol /dev/system swap 512 4194304 |
| 58 |
lvmvol /dev/system vmxfs 7680 62914560 |
| 59 |
lvmvol /dev/system kvm 5000 40960000 |
| 60 |
fs /dev/mapper/system-root / ext4 uuid=dbb0c0d4-7b9a-40e2-be83-daafa14eff6b label= blocksize=4096 reserved_blocks=131072 max_mounts=21 check_interval=180d options=rw,commit=0 |
| 61 |
fs /dev/mapper/system-home /home ext4 uuid=e9310015-6043-48cd-a37d-78dbfdba1e3b label= blocksize=4096 reserved_blocks=262144 max_mounts=38 check_interval=180d options=rw,commit=0 |
| 62 |
fs /dev/mapper/system-var /var ext4 uuid=a12bb95f-99f2-42c6-854f-1cb3f144d662 label= blocksize=4096 reserved_blocks=131072 max_mounts=23 check_interval=180d options=rw,commit=0 |
| 63 |
fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label= options=rw,noatime |
| 64 |
fs /dev/mapper/system-kvm /kvm ext4 uuid=173ab1f7-8450-4176-8cf7-c09b47f5e3cc label= blocksize=4096 reserved_blocks=256000 max_mounts=21 check_interval=180d options=rw,noatime,commit=0 |
| 65 |
fs /dev/sda1 /boot ext3 uuid=f6b08566-ea5e-46f9-8f73-5e8ffdaa7be6 label= blocksize=1024 reserved_blocks=10238 max_mounts=35 check_interval=180d options=rw,commit=0 |
| 66 |
swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label= |
| 67 |
crypt /dev/mapper/disk /dev/sda2 cipher=aes-xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb |
| 68 |
---------------------------------- |
| 69 |
This document will continue to use this example to explore the various options |
| 70 |
available in Relax-and-Recover. The exact syntax of the layout file is |
| 71 |
described in a later section. It is already clear that this file is human |
| 72 |
readable and thus human editable. It is also machine readable and all |
| 73 |
information necessary to restore a system is listed. |
| 74 |
|
| 75 |
It's easy to see that there are 3 disks attached to the system. +/dev/sda+ is the internal disk of the system. Its filesystems are normally mounted. The other devices are external disks. One of them has just normal partitions. The other one has a physical volume on one of the partitions. |
| 76 |
|
| 77 |
== Excluding components |
| 78 |
|
| 79 |
=== Autoexcludes |
| 80 |
|
| 81 |
Relax-and-Recover has reasonable defaults when creating the recovery |
| 82 |
information. It has commented out the two external disks and any |
| 83 |
component that's part of it. The reason is that no mounted filesystem |
| 84 |
uses these two disks. |
| 85 |
|
| 86 |
This behavior is controlled by the +AUTOEXCLUDE_DISKS=y+ parameter in |
| 87 |
+default.conf+. If we unset it in the local configuration, Relax-and-Recover |
| 88 |
will no longer exclude it automatically. |
| 89 |
|
| 90 |
A similar mechanism exists for multipath disks. The +AUTOEXCLUDE_MULTIPATH=y+ |
| 91 |
variable in +default.conf+ prevents Relax-and-Recover from overwriting |
| 92 |
multipath disks. Typically, they are part of the SAN disaster recovery |
| 93 |
strategy. However, there can be cases where you want to recover them. The |
| 94 |
information is retained in +disklayout.conf+. |
| 95 |
|
| 96 |
Some filesystems are excluded from the layout file by default if their |
| 97 |
mountpoints are located under certain directories. This behavior is |
| 98 |
controlled by the +AUTOEXCLUDE_PATH+ variable. It is an array of |
| 99 |
paths. If a mountpoint of a filesystem is under one of the paths, the |
| 100 |
filesystem is excluded. The default value includes +/media+, +/mnt+ |
| 101 |
and +/tmp+. See +default.conf+ for the full list. Note that if one of |
| 102 |
the paths is itself a mountpoint, the filesystem is not excluded. So, |
| 103 |
if +/media+ is a mounted filesystem, it will not be excluded, but if |
| 104 |
we mount the +/dev/mapper/backup-backup+ filesystem on |
| 105 |
+/media/backup+, it will get excluded, as the mountpoint is under |
| 106 |
+/media+. |
| 107 |
|
| 108 |
If we mount the filesystem on +/dev/mapper/backup-backup+ on +/backup+, |
| 109 |
Relax-and-Recover will think that it's necessary to recreate the filesystem: |
| 110 |
---------------------------------- |
| 111 |
disk /dev/sdc 1999696297984 msdos |
| 112 |
... |
| 113 |
part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1 |
| 114 |
part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2 |
| 115 |
lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784 |
| 116 |
... |
| 117 |
lvmgrp /dev/backup 4096 220764 904249344 |
| 118 |
... |
| 119 |
lvmvol /dev/backup backup 12800 104857600 |
| 120 |
lvmvol /dev/backup externaltemp 38400 314572800 |
| 121 |
... |
| 122 |
fs /dev/mapper/backup-backup /backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw |
| 123 |
---------------------------------- |
| 124 |
|
| 125 |
=== Manual excludes |
| 126 |
In this example, the external drive +/dev/sdc+ contains a volume group |
| 127 |
used for backups outside Relax-and-Recover. It is assumed that one |
| 128 |
does not want to overwrite and recreate the content of the backup disk |
| 129 |
when recovering the system, but one expects the backup disk to survive |
| 130 |
the recovery unchanged, and that one also does not want |
| 131 |
Relax-and-Recover to make a backup of its content. (Note that |
| 132 |
excluding a filesystem from the layout file also excludes the files in |
| 133 |
the filesystem from the backup when using a supported backup method, |
| 134 |
which is what we want in this case.) One thus needs to |
| 135 |
exclude the components on the disk from the layout file. |
| 136 |
A generic mechanism for doing this is the +EXCLUDE_RECREATE+ |
| 137 |
variable. It can contain a list of storage components that will be |
| 138 |
excluded from the layout (will be present in the layout file, but |
| 139 |
commented out) recursively together with their descendants (components |
| 140 |
that depend on the excluded component, like a filesystem on the |
| 141 |
underlying logical volume). Each component in the list corresponds to |
| 142 |
a component in the layout file, but the syntax is different. To |
| 143 |
specify a mounted filesystem, use the +fs:+ prefix: |
| 144 |
+fs:+<mountpoint>. To specify swap, use the +swap:+ prefix. The syntax |
| 145 |
to specify a volume group to exclude (together with all its logical |
| 146 |
volumes and filesystems on them) is +/dev/+<volume group name>. Consult |
| 147 |
the +/var/lib/rear/layout/disktodo.conf+ file created together with |
| 148 |
the layout file for the full list of components in a compatible |
| 149 |
syntax. |
| 150 |
|
| 151 |
To prevent the mounted backup filesystem from being added to |
| 152 |
the layout file and recreated, one may add the filesystem to the +EXCLUDE_RECREATE+ array. |
| 153 |
---------------------------------- |
| 154 |
EXCLUDE_RECREATE+=( "fs:/backup" ) |
| 155 |
---------------------------------- |
| 156 |
|
| 157 |
The layout file is as expected: |
| 158 |
---------------------------------- |
| 159 |
#disk /dev/sdc 1999696297984 msdos |
| 160 |
... |
| 161 |
#part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1 |
| 162 |
#part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2 |
| 163 |
#lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784 |
| 164 |
... |
| 165 |
#lvmgrp /dev/backup 4096 220764 904249344 |
| 166 |
... |
| 167 |
#lvmvol /dev/backup backup 12800 104857600 |
| 168 |
#lvmvol /dev/backup externaltemp 38400 314572800 |
| 169 |
... |
| 170 |
#fs /dev/mapper/backup-backup /backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw |
| 171 |
---------------------------------- |
| 172 |
|
| 173 |
Another approach would be to exclude the backup volume group. This is achieved by adding this line to the local configuration: |
| 174 |
---------------------------------- |
| 175 |
EXCLUDE_RECREATE+=( "/dev/backup" ) |
| 176 |
---------------------------------- |
| 177 |
|
| 178 |
== Restore to the same hardware |
| 179 |
Restoring the system to the same hardware is simple. Type +rear recover+ in |
| 180 |
the rescue system prompt. Relax-and-Recover will detect that it's restoring to |
| 181 |
the same system and will make sure things like UUIDs match. It also asks for |
| 182 |
your LUKS encryption password. |
| 183 |
|
| 184 |
Once the restore of the backup has completed, Relax-and-Recover will install |
| 185 |
the bootloader and the system is back in working order. |
| 186 |
---------------------------------- |
| 187 |
RESCUE firefly:~ # rear recover |
| 188 |
Relax-and-Recover 0.0.0 / $Date$ |
| 189 |
NOTICE: Will do driver migration |
| 190 |
Comparing disks. |
| 191 |
Disk configuration is identical, proceeding with restore. |
| 192 |
Start system layout restoration. |
| 193 |
Creating partitions for disk /dev/sda (msdos) |
| 194 |
Please enter the password for disk(/dev/sda2): |
| 195 |
Enter LUKS passphrase: |
| 196 |
Please re-enter the password for disk(/dev/sda2): |
| 197 |
Enter passphrase for /dev/sda2: |
| 198 |
Creating LVM PV /dev/mapper/disk |
| 199 |
Restoring LVM VG system |
| 200 |
Creating ext4-filesystem / on /dev/mapper/system-root |
| 201 |
Mounting filesystem / |
| 202 |
Creating ext4-filesystem /home on /dev/mapper/system-home |
| 203 |
Mounting filesystem /home |
| 204 |
Creating ext4-filesystem /var on /dev/mapper/system-var |
| 205 |
Mounting filesystem /var |
| 206 |
Creating xfs-filesystem /vmware on /dev/mapper/system-vmxfs |
| 207 |
meta-data=/dev/mapper/system-vmxfs isize=256 agcount=4, agsize=1966080 blks |
| 208 |
= sectsz=512 attr=2, projid32bit=0 |
| 209 |
data = bsize=4096 blocks=7864320, imaxpct=25 |
| 210 |
= sunit=0 swidth=0 blks |
| 211 |
naming =version 2 bsize=4096 ascii-ci=0 |
| 212 |
log =internal log bsize=4096 blocks=3840, version=2 |
| 213 |
= sectsz=512 sunit=0 blks, lazy-count=1 |
| 214 |
realtime =none extsz=4096 blocks=0, rtextents=0 |
| 215 |
Mounting filesystem /vmware |
| 216 |
Creating ext4-filesystem /kvm on /dev/mapper/system-kvm |
| 217 |
Mounting filesystem /kvm |
| 218 |
Creating ext3-filesystem /boot on /dev/sda1 |
| 219 |
Mounting filesystem /boot |
| 220 |
Creating swap on /dev/mapper/system-swap |
| 221 |
Disk layout created. |
| 222 |
Please start the restore process on your backup host. |
| 223 |
|
| 224 |
Make sure that you restore the data into '/mnt/local' instead of '/' because the |
| 225 |
hard disks of the recovered system are mounted there. |
| 226 |
|
| 227 |
Please restore your backup in the provided shell and, when finished, type exit |
| 228 |
in the shell to continue recovery. |
| 229 |
|
| 230 |
Welcome to Relax-and-Recover. Run "rear recover" to restore your system ! |
| 231 |
|
| 232 |
rear> |
| 233 |
---------------------------------- |
| 234 |
== Restore to different hardware |
| 235 |
There are two ways to deal with different hardware. One is being lazy and dealing with problems when you encounter them. The second option is to plan in advance. Both are valid approaches. The lazy approach works fine when you are in control of the restore and you have good knowledge of the components in your system. The second approach is preferable in disaster recovery situations or migrations where you know the target hardware in advance and the actual restore can be carried out by less knowledgeable people. |
| 236 |
|
| 237 |
=== The Ad-Hoc Way |
| 238 |
Relax-and-Recover will assist you somewhat in case it notices different disk |
| 239 |
sizes. It will ask you to map each differently sized disk to a disk in the |
| 240 |
target system. Partitions will be resized. Relax-and-Recover is careful not to |
| 241 |
resize your boot partition, since this is often the one with the most |
| 242 |
stringent sizing constraints. In fact, it only resizes LVM and RAID |
| 243 |
partitions. |
| 244 |
|
| 245 |
Let's try to restore our system to a different system. Instead of one 160G |
| 246 |
disk, there is now one 5G and one 10G disk. That's not enough space to restore |
| 247 |
the complete system, but for purposes of this demonstration, we do not care |
| 248 |
about that. We're also not going to use the first disk, but we just want to |
| 249 |
show that Relax-and-Recover handles the renaming automatically. |
| 250 |
|
| 251 |
---------------------------------- |
| 252 |
RESCUE firefly:~ # rear recover |
| 253 |
Relax-and-Recover 0.0.0 / $Date$ |
| 254 |
NOTICE: Will do driver migration |
| 255 |
Comparing disks. |
| 256 |
Device sda has size 5242880000, 160041885696 expected |
| 257 |
Switching to manual disk layout configuration. |
| 258 |
Disk sda does not exist in the target system. Please choose the appropriate replacement. |
| 259 |
1) sda |
| 260 |
2) sdb |
| 261 |
3) Do not map disk. |
| 262 |
#? 2 |
| 263 |
2011-09-10 16:17:10 Disk sdb chosen as replacement for sda. |
| 264 |
Disk sdb chosen as replacement for sda. |
| 265 |
This is the disk mapping table: |
| 266 |
/dev/sda /dev/sdb |
| 267 |
Please confirm that '/var/lib/rear/layout/disklayout.conf' is as you expect. |
| 268 |
|
| 269 |
1) View disk layout (disklayout.conf) 4) Go to Relax-and-Recover shell |
| 270 |
2) Edit disk layout (disklayout.conf) 5) Continue recovery |
| 271 |
3) View original disk space usage 6) Abort Relax-and-Recover |
| 272 |
---------------------------------- |
| 273 |
|
| 274 |
Ok, mapping the disks was not that hard. If Relax-and-Recover insists on us |
| 275 |
checking the disklayout file, we'd better do that. |
| 276 |
|
| 277 |
---------------------------------- |
| 278 |
#? 1 |
| 279 |
disk /dev/sdb 160041885696 msdos |
| 280 |
#disk _REAR1_ 320072933376 msdos |
| 281 |
#disk /dev/sdc 1999696297984 msdos |
| 282 |
part /dev/sdb 209682432 32768 primary boot /dev/sdb1 |
| 283 |
part /dev/sdb -20916822016 209719296 primary lvm /dev/sdb2 |
| 284 |
part /dev/sdb 31192862720 128849022976 primary none /dev/sdb3 |
| 285 |
#part _REAR1_ 162144912384 32256 primary none _REAR1_1 |
| 286 |
#part _REAR1_ 152556666880 162144944640 primary none _REAR1_2 |
| 287 |
#part _REAR1_ 5371321856 314701611520 primary boot _REAR1_3 |
| 288 |
#part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1 |
| 289 |
#part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2 |
| 290 |
#lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784 |
| 291 |
lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544 |
| 292 |
#lvmgrp /dev/backup 4096 220764 904249344 |
| 293 |
lvmgrp /dev/system 4096 30669 125620224 |
| 294 |
#lvmvol /dev/backup backup 12800 104857600 |
| 295 |
#lvmvol /dev/backup externaltemp 38400 314572800 |
| 296 |
lvmvol /dev/system root 2560 20971520 |
| 297 |
lvmvol /dev/system home 5120 41943040 |
| 298 |
lvmvol /dev/system var 2560 20971520 |
| 299 |
lvmvol /dev/system swap 512 4194304 |
| 300 |
lvmvol /dev/system vmxfs 7680 62914560 |
| 301 |
lvmvol /dev/system kvm 5000 40960000 |
| 302 |
fs /dev/mapper/system-root / ext4 uuid=dbb0c0d4-7b9a-40e2-be83-daafa14eff6b label= blocksize=4096 reserved_blocks=131072 max_mounts=21 check_interval=180d options=rw,commit=0 |
| 303 |
fs /dev/mapper/system-home /home ext4 uuid=e9310015-6043-48cd-a37d-78dbfdba1e3b label= blocksize=4096 reserved_blocks=262144 max_mounts=38 check_interval=180d options=rw,commit=0 |
| 304 |
fs /dev/mapper/system-var /var ext4 uuid=a12bb95f-99f2-42c6-854f-1cb3f144d662 label= blocksize=4096 reserved_blocks=131072 max_mounts=23 check_interval=180d options=rw,commit=0 |
| 305 |
fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label= options=rw,noatime |
| 306 |
fs /dev/mapper/system-kvm /kvm ext4 uuid=173ab1f7-8450-4176-8cf7-c09b47f5e3cc label= blocksize=4096 reserved_blocks=256000 max_mounts=21 check_interval=180d options=rw,noatime,commit=0 |
| 307 |
fs /dev/sdb1 /boot ext3 uuid=f6b08566-ea5e-46f9-8f73-5e8ffdaa7be6 label= blocksize=1024 reserved_blocks=10238 max_mounts=35 check_interval=180d options=rw,commit=0 |
| 308 |
#fs /dev/mapper/backup-backup /backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw |
| 309 |
swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label= |
| 310 |
crypt /dev/mapper/disk /dev/sdb2 cipher=aes-xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb |
| 311 |
|
| 312 |
1) View disk layout (disklayout.conf) |
| 313 |
2) Edit disk layout (disklayout.conf) |
| 314 |
3) View original disk space usage |
| 315 |
4) Go to Relax-and-Recover shell |
| 316 |
5) Continue recovery |
| 317 |
6) Abort Relax-and-Recover |
| 318 |
#? |
| 319 |
---------------------------------- |
| 320 |
The renaming operation was successful. |
| 321 |
|
| 322 |
On the other hand, we can already see quite a few problems. A partition with negative sizes. I do not think any tool would like to create that. Still, we don't care at this moment. Do you like entering partition sizes in bytes? Neither do I. There has to be a better way to handle it. We will show it during the next step. |
| 323 |
|
| 324 |
The /kvm and /vmware filesystems are quite big. We don't care about them, so just put some nice comments on them and their logical volumes. |
| 325 |
|
| 326 |
The resulting layout file looks like this: |
| 327 |
---------------------------------- |
| 328 |
disk /dev/sdb 160041885696 msdos |
| 329 |
#disk _REAR1_ 320072933376 msdos |
| 330 |
#disk /dev/sdc 1999696297984 msdos |
| 331 |
part /dev/sdb 209682432 32768 primary boot /dev/sdb1 |
| 332 |
part /dev/sdb -20916822016 209719296 primary lvm /dev/sdb2 |
| 333 |
part /dev/sdb 31192862720 128849022976 primary none /dev/sdb3 |
| 334 |
#part _REAR1_ 162144912384 32256 primary none _REAR1_1 |
| 335 |
#part _REAR1_ 152556666880 162144944640 primary none _REAR1_2 |
| 336 |
#part _REAR1_ 5371321856 314701611520 primary boot _REAR1_3 |
| 337 |
#part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1 |
| 338 |
#part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2 |
| 339 |
#lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784 |
| 340 |
lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544 |
| 341 |
#lvmgrp /dev/backup 4096 220764 904249344 |
| 342 |
lvmgrp /dev/system 4096 30669 125620224 |
| 343 |
#lvmvol /dev/backup backup 12800 104857600 |
| 344 |
#lvmvol /dev/backup externaltemp 38400 314572800 |
| 345 |
lvmvol /dev/system root 2560 20971520 |
| 346 |
lvmvol /dev/system home 5120 41943040 |
| 347 |
lvmvol /dev/system var 2560 20971520 |
| 348 |
lvmvol /dev/system swap 512 4194304 |
| 349 |
#lvmvol /dev/system vmxfs 7680 62914560 |
| 350 |
#lvmvol /dev/system kvm 5000 40960000 |
| 351 |
fs /dev/mapper/system-root / ext4 uuid=dbb0c0d4-7b9a-40e2-be83-daafa14eff6b label= blocksize=4096 reserved_blocks=131072 max_mounts=21 check_interval=180d options=rw,commit=0 |
| 352 |
fs /dev/mapper/system-home /home ext4 uuid=e9310015-6043-48cd-a37d-78dbfdba1e3b label= blocksize=4096 reserved_blocks=262144 max_mounts=38 check_interval=180d options=rw,commit=0 |
| 353 |
fs /dev/mapper/system-var /var ext4 uuid=a12bb95f-99f2-42c6-854f-1cb3f144d662 label= blocksize=4096 reserved_blocks=131072 max_mounts=23 check_interval=180d options=rw,commit=0 |
| 354 |
#fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label= options=rw,noatime |
| 355 |
#fs /dev/mapper/system-kvm /kvm ext4 uuid=173ab1f7-8450-4176-8cf7-c09b47f5e3cc label= blocksize=4096 reserved_blocks=256000 max_mounts=21 check_interval=180d options=rw,noatime,commit=0 |
| 356 |
fs /dev/sdb1 /boot ext3 uuid=f6b08566-ea5e-46f9-8f73-5e8ffdaa7be6 label= blocksize=1024 reserved_blocks=10238 max_mounts=35 check_interval=180d options=rw,commit=0 |
| 357 |
#fs /dev/mapper/backup-backup /backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw |
| 358 |
swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label= |
| 359 |
crypt /dev/mapper/disk /dev/sdb2 cipher=aes-xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb |
| 360 |
---------------------------------- |
| 361 |
|
| 362 |
Let's continue recovery. |
| 363 |
|
| 364 |
---------------------------------- |
| 365 |
1) View disk layout (disklayout.conf) |
| 366 |
2) Edit disk layout (disklayout.conf) |
| 367 |
3) View original disk space usage |
| 368 |
4) Go to Relax-and-Recover shell |
| 369 |
5) Continue recovery |
| 370 |
6) Abort Relax-and-Recover |
| 371 |
#? 5 |
| 372 |
Partition /dev/sdb3 size reduced to fit on disk. |
| 373 |
Please confirm that '/var/lib/rear/layout/diskrestore.sh' is as you expect. |
| 374 |
|
| 375 |
1) View restore script (diskrestore.sh) |
| 376 |
2) Edit restore script (diskrestore.sh) |
| 377 |
3) View original disk space usage |
| 378 |
4) Go to Relax-and-Recover shell |
| 379 |
5) Continue recovery |
| 380 |
6) Abort Relax-and-Recover |
| 381 |
#? |
| 382 |
---------------------------------- |
| 383 |
|
| 384 |
Now, this is where human friendly resizes are possible. Edit the file. Find the partition creation code. |
| 385 |
|
| 386 |
---------------------------------- |
| 387 |
if create_component "/dev/sdb" "disk" ; then |
| 388 |
# Create /dev/sdb (disk) |
| 389 |
LogPrint "Creating partitions for disk /dev/sdb (msdos)" |
| 390 |
parted -s /dev/sdb mklabel msdos >&2 |
| 391 |
parted -s /dev/sdb mkpart primary 32768B 209715199B >&2 |
| 392 |
parted -s /dev/sdb set 1 boot on >&2 |
| 393 |
parted -s /dev/sdb mkpart primary 209719296B -20707102721B >&2 |
| 394 |
parted -s /dev/sdb set 2 lvm on >&2 |
| 395 |
parted -s /dev/sdb mkpart primary 18446744053002452992B 10485759999B >&2 |
| 396 |
# Wait some time before advancing |
| 397 |
sleep 10 |
| 398 |
---------------------------------- |
| 399 |
It's simple bash code. Change it to use better values. Parted is happy to accept partitions in Megabytes. |
| 400 |
---------------------------------- |
| 401 |
if create_component "/dev/sdb" "disk" ; then |
| 402 |
# Create /dev/sdb (disk) |
| 403 |
LogPrint "Creating partitions for disk /dev/sdb (msdos)" |
| 404 |
parted -s /dev/sdb mklabel msdos >&2 |
| 405 |
parted -s /dev/sdb mkpart primary 1M 200M >&2 |
| 406 |
parted -s /dev/sdb set 1 boot on >&2 |
| 407 |
parted -s /dev/sdb mkpart primary 200M 10485759999B >&2 |
| 408 |
parted -s /dev/sdb set 2 lvm on >&2 |
| 409 |
# Wait some time before advancing |
| 410 |
sleep 10 |
| 411 |
---------------------------------- |
| 412 |
The same action should be done for the remaining logical volumes. We would like them to fit on the disk. |
| 413 |
---------------------------------- |
| 414 |
if create_component "/dev/mapper/system-root" "lvmvol" ; then |
| 415 |
# Create /dev/mapper/system-root (lvmvol) |
| 416 |
LogPrint "Creating LVM volume system/root" |
| 417 |
lvm lvcreate -l 2560 -n root system >&2 |
| 418 |
component_created "/dev/mapper/system-root" "lvmvol" |
| 419 |
else |
| 420 |
LogPrint "Skipping /dev/mapper/system-root (lvmvol) as it has already been created." |
| 421 |
fi |
| 422 |
---------------------------------- |
| 423 |
No-one but a computer likes to think in extents, so we size it a comfortable 5G. |
| 424 |
---------------------------------- |
| 425 |
if create_component "/dev/mapper/system-root" "lvmvol" ; then |
| 426 |
# Create /dev/mapper/system-root (lvmvol) |
| 427 |
LogPrint "Creating LVM volume system/root" |
| 428 |
lvm lvcreate -L 5G -n root system >&2 |
| 429 |
component_created "/dev/mapper/system-root" "lvmvol" |
| 430 |
else |
| 431 |
LogPrint "Skipping /dev/mapper/system-root (lvmvol) as it has already been created." |
| 432 |
fi |
| 433 |
---------------------------------- |
| 434 |
Do the same thing for the other logical volumes and choose number 5, continue. |
| 435 |
---------------------------------- |
| 436 |
1) View restore script (diskrestore.sh) |
| 437 |
2) Edit restore script (diskrestore.sh) |
| 438 |
3) View original disk space usage |
| 439 |
4) Go to Relax-and-Recover shell |
| 440 |
5) Continue recovery |
| 441 |
6) Abort Relax-and-Recover |
| 442 |
#? 5 |
| 443 |
Start system layout restoration. |
| 444 |
Creating partitions for disk /dev/sdb (msdos) |
| 445 |
Please enter the password for disk(/dev/sdb2): |
| 446 |
Enter LUKS passphrase: |
| 447 |
Please re-enter the password for disk(/dev/sdb2): |
| 448 |
Enter passphrase for /dev/sdb2: |
| 449 |
Creating LVM PV /dev/mapper/disk |
| 450 |
Creating LVM VG system |
| 451 |
Creating LVM volume system/root |
| 452 |
Creating LVM volume system/home |
| 453 |
Creating LVM volume system/var |
| 454 |
Creating LVM volume system/swap |
| 455 |
Creating ext4-filesystem / on /dev/mapper/system-root |
| 456 |
Mounting filesystem / |
| 457 |
Creating ext4-filesystem /home on /dev/mapper/system-home |
| 458 |
An error occurred during layout recreation. |
| 459 |
|
| 460 |
1) View Relax-and-Recover log |
| 461 |
2) View original disk space usage |
| 462 |
3) Go to Relax-and-Recover shell |
| 463 |
4) Edit restore script (diskrestore.sh) |
| 464 |
5) Continue restore script |
| 465 |
6) Abort Relax-and-Recover |
| 466 |
#? |
| 467 |
---------------------------------- |
| 468 |
An error... Did you expect it? I didn't. |
| 469 |
|
| 470 |
Relax-and-Recover produces exceptionally good logs. Let's check them. |
| 471 |
---------------------------------- |
| 472 |
+++ tune2fs -r 262144 -c 38 -i 180d /dev/mapper/system-home |
| 473 |
tune2fs: reserved blocks count is too big (262144) |
| 474 |
tune2fs 1.41.14 (22-Dec-2010) |
| 475 |
Setting maximal mount count to 38 |
| 476 |
Setting interval between checks to 15552000 seconds |
| 477 |
2011-09-10 16:27:35 An error occurred during layout recreation. |
| 478 |
---------------------------------- |
| 479 |
Yes, we resized the home partition from 20GB to 2G in the previous step. The root user wants more reserved blocks than the total number of available blocks. |
| 480 |
|
| 481 |
Fixing it is simple. Edit the restore script, option 4. Find the code responsible for filesystem creation. |
| 482 |
|
| 483 |
---------------------------------- |
| 484 |
if create_component "fs:/home" "fs" ; then |
| 485 |
# Create fs:/home (fs) |
| 486 |
LogPrint "Creating ext4-filesystem /home on /dev/mapper/system-home" |
| 487 |
mkfs -t ext4 -b 4096 /dev/mapper/system-home >&2 |
| 488 |
tune2fs -U e9310015-6043-48cd-a37d-78dbfdba1e3b /dev/mapper/system-home >&2 |
| 489 |
tune2fs -r 262144 -c 38 -i 180d /dev/mapper/system-home >&2 |
| 490 |
LogPrint "Mounting filesystem /home" |
| 491 |
mkdir -p /mnt/local/home |
| 492 |
mount /dev/mapper/system-home /mnt/local/home |
| 493 |
component_created "fs:/home" "fs" |
| 494 |
else |
| 495 |
LogPrint "Skipping fs:/home (fs) as it has already been created." |
| 496 |
fi |
| 497 |
---------------------------------- |
| 498 |
The +-r+ parameter is causing the error. We just remove it and do the same for the other filesystems. |
| 499 |
---------------------------------- |
| 500 |
if create_component "fs:/home" "fs" ; then |
| 501 |
# Create fs:/home (fs) |
| 502 |
LogPrint "Creating ext4-filesystem /home on /dev/mapper/system-home" |
| 503 |
mkfs -t ext4 -b 4096 /dev/mapper/system-home >&2 |
| 504 |
tune2fs -U e9310015-6043-48cd-a37d-78dbfdba1e3b /dev/mapper/system-home >&2 |
| 505 |
tune2fs -c 38 -i 180d /dev/mapper/system-home >&2 |
| 506 |
LogPrint "Mounting filesystem /home" |
| 507 |
mkdir -p /mnt/local/home |
| 508 |
mount /dev/mapper/system-home /mnt/local/home |
| 509 |
component_created "fs:/home" "fs" |
| 510 |
else |
| 511 |
LogPrint "Skipping fs:/home (fs) as it has already been created." |
| 512 |
fi |
| 513 |
---------------------------------- |
| 514 |
Continue the restore script. |
| 515 |
---------------------------------- |
| 516 |
1) View Relax-and-Recover log |
| 517 |
2) View original disk space usage |
| 518 |
3) Go to Relax-and-Recover shell |
| 519 |
4) Edit restore script (diskrestore.sh) |
| 520 |
5) Continue restore script |
| 521 |
6) Abort Relax-and-Recover |
| 522 |
#? 5 |
| 523 |
Start system layout restoration. |
| 524 |
Skipping /dev/sdb (disk) as it has already been created. |
| 525 |
Skipping /dev/sdb1 (part) as it has already been created. |
| 526 |
Skipping /dev/sdb2 (part) as it has already been created. |
| 527 |
Skipping /dev/sdb3 (part) as it has already been created. |
| 528 |
Skipping /dev/mapper/disk (crypt) as it has already been created. |
| 529 |
Skipping pv:/dev/mapper/disk (lvmdev) as it has already been created. |
| 530 |
Skipping /dev/system (lvmgrp) as it has already been created. |
| 531 |
Skipping /dev/mapper/system-root (lvmvol) as it has already been created. |
| 532 |
Skipping /dev/mapper/system-home (lvmvol) as it has already been created. |
| 533 |
Skipping /dev/mapper/system-var (lvmvol) as it has already been created. |
| 534 |
Skipping /dev/mapper/system-swap (lvmvol) as it has already been created. |
| 535 |
Skipping fs:/ (fs) as it has already been created. |
| 536 |
Creating ext4-filesystem /home on /dev/mapper/system-home |
| 537 |
Mounting filesystem /home |
| 538 |
Creating ext4-filesystem /var on /dev/mapper/system-var |
| 539 |
Mounting filesystem /var |
| 540 |
Creating ext3-filesystem /boot on /dev/sdb1 |
| 541 |
Mounting filesystem /boot |
| 542 |
Creating swap on /dev/mapper/system-swap |
| 543 |
Disk layout created. |
| 544 |
---------------------------------- |
| 545 |
That looks the way we want it. Notice how Relax-and-Recover detected that it |
| 546 |
had already created quite a few components and did not try to recreate them |
| 547 |
anymore. |
| 548 |
|
| 549 |
=== Planning In Advance === |
| 550 |
Relax-and-Recover makes it possible to define the layout on the target system |
| 551 |
even before the backup is taken. All one has to do is to move the |
| 552 |
+/var/lib/rear/layout/disklayout.conf+ file to +/etc/rear/disklayout.conf+ and |
| 553 |
edit it. This won't be overwritten on future backup runs. During recovery, |
| 554 |
Relax-and-Recover will use that file instead of the snapshot of the original |
| 555 |
system. |
| 556 |
|
| 557 |
== Disk layout file syntax == |
| 558 |
|
| 559 |
This section describes the syntax of all components in the Relax-and-Recover |
| 560 |
layout file /var/lib/rear/layout/disklayout.conf |
| 561 |
|
| 562 |
One cannot rely on backward compatibility between ReaR versions. |
| 563 |
Normally the layout file /var/lib/rear/layout/disklayout.conf is created from scratch |
| 564 |
for each run of "rear mkrescue/mkbackup" so a newer ReaR version creates it anew |
| 565 |
with the right syntax for this ReaR version which is the exact same ReaR |
| 566 |
that gets included in the ReaR recovery system together with this layout file |
| 567 |
to recreate the disk layout during "rear recover". |
| 568 |
Only when a selfmade /etc/rear/disklayout.conf is used then it must be adapted |
| 569 |
by the user when he upgrades to a newer ReaR version. |
| 570 |
|
| 571 |
The syntax is of the form |
| 572 |
---------------------------------- |
| 573 |
keyword value1 value2 value3 ... |
| 574 |
---------------------------------- |
| 575 |
where keyword denotes one kind of component (disk, partition, filesystem, ...) |
| 576 |
and keyword and all the values are separated by single space characters |
| 577 |
(which means spaces in values are forbidden - there is neither quoting nor escaping) |
| 578 |
so that one can get the lines that belong to a particular component |
| 579 |
with particular value1 and value2 via simple commands like |
| 580 |
---------------------------------- |
| 581 |
grep "^keyword value1 value2 " /var/lib/rear/layout/disklayout.conf |
| 582 |
---------------------------------- |
| 583 |
(provided there is a value3 after value2 so there is a space after value2). |
| 584 |
|
| 585 |
No whitespace is allowed at the beginning of lines in the disklayout.conf file. |
| 586 |
Lines that start with a # (number sign, hash, or pound sign) are comments. |
| 587 |
All other lines start with a component keyword. |
| 588 |
|
| 589 |
None of the component keywords is a leading substring of another component keyword |
| 590 |
(e.g. disk is not a leading substring of raiddisk) so that one could even get |
| 591 |
only those lines that belong to a particular component via sloppy commands like |
| 592 |
---------------------------------- |
| 593 |
grep ^keyword /var/lib/rear/layout/disklayout.conf |
| 594 |
---------------------------------- |
| 595 |
regardless that the proper command (in particular for scripts) is |
| 596 |
---------------------------------- |
| 597 |
grep "^keyword " /var/lib/rear/layout/disklayout.conf |
| 598 |
---------------------------------- |
| 599 |
with a single space after the keyword as delimiter. |
| 600 |
|
| 601 |
For most component keywords the values are positional parameters |
| 602 |
(if there is no value a dummy value like 'none' must be used) |
| 603 |
so empty values in between are invalid syntax |
| 604 |
which can result arbitrarily bad failures during "rear recover". |
| 605 |
|
| 606 |
For some component keywords the parameters have a form like |
| 607 |
---------------------------------- |
| 608 |
keyword value1 value2 optionA=valueA optionB=valueB ... |
| 609 |
---------------------------------- |
| 610 |
where the first ones are positional parameters but not the option=value parameters |
| 611 |
so empty option=value parameters are allowed, for example see the 'raidarray' keyword. |
| 612 |
|
| 613 |
For details the matching scripts need to be inspected how things actually work |
| 614 |
for a particular component keyword (i.e. what is implemented in the code). |
| 615 |
|
| 616 |
Syntax of the individual component keyword descriptions below: |
| 617 |
|
| 618 |
Normal text has to be present verbatim. |
| 619 |
Angle brackets "<" and ">" delimit a value that can be edited. |
| 620 |
Quotes " inside the angle brackets indicate a verbatim option, |
| 621 |
often used together with a / to indicate multiple options. |
| 622 |
Parenthesis "(" ")" inside explain the expected unit. |
| 623 |
No unit suffix should be present, unless specifically indicated. |
| 624 |
Square brackets "[" and "]" indicate an optional parameter. |
| 625 |
They can be excluded when hand-crafting a layout file line. |
| 626 |
|
| 627 |
=== Disks === |
| 628 |
---------------------------------- |
| 629 |
disk <name> <size(B)> <partition label> |
| 630 |
---------------------------------- |
| 631 |
|
| 632 |
=== Partitions === |
| 633 |
---------------------------------- |
| 634 |
part <disk name> <size(B)> <start(B)> <partition name/type> <flags/"none"> <partition name> |
| 635 |
---------------------------------- |
| 636 |
|
| 637 |
=== Software RAID arrays === |
| 638 |
---------------------------------- |
| 639 |
raidarray /dev/<kernel RAID device> level=<RAID level> raid-devices=<nr of active devices> devices=<component device1,component device2,...> [name=<array name>] [metadata=<metadata style>] [uuid=<UUID>] [layout=<data layout>] [chunk=<chunk size>] [spare-devices=<nr of spare devices>] [size=<container size>] |
| 640 |
---------------------------------- |
| 641 |
|
| 642 |
=== Software RAID disks === |
| 643 |
---------------------------------- |
| 644 |
raiddisk <devname> <size(bytes)> <partition label type> |
| 645 |
---------------------------------- |
| 646 |
|
| 647 |
=== Multipath === |
| 648 |
---------------------------------- |
| 649 |
multipath /dev/<name> <size(B)> <partition label> <slave1,slave2,...> |
| 650 |
---------------------------------- |
| 651 |
|
| 652 |
=== Physical Volumes === |
| 653 |
---------------------------------- |
| 654 |
lvmdev /dev/<volume_group> <device> [<uuid>] [<size(bytes)>] |
| 655 |
---------------------------------- |
| 656 |
|
| 657 |
=== Volume Groups === |
| 658 |
---------------------------------- |
| 659 |
lvmgrp <volume_group> <extentsize> [<size(extents)>] [<size(bytes)>] |
| 660 |
---------------------------------- |
| 661 |
|
| 662 |
=== Logical Volumes === |
| 663 |
---------------------------------- |
| 664 |
lvmvol <volume_group> <name> <size(bytes)> <layout> [key:value ...] |
| 665 |
---------------------------------- |
| 666 |
|
| 667 |
=== LUKS Devices === |
| 668 |
---------------------------------- |
| 669 |
crypt /dev/mapper/<name> <device> [type=<type>] [cipher=<cipher>] [key_size=<key size>] [hash=<hash function>] [uuid=<uuid>] [keyfile=<keyfile>] [password=<password>] |
| 670 |
---------------------------------- |
| 671 |
|
| 672 |
=== DRBD === |
| 673 |
---------------------------------- |
| 674 |
drbd /dev/drbd<nr> <drbd resource name> <device> |
| 675 |
---------------------------------- |
| 676 |
|
| 677 |
=== Filesystems === |
| 678 |
---------------------------------- |
| 679 |
fs <device> <mountpoint> <filesystem type> [uuid=<uuid>] [label=<label>] [blocksize=<block size(B)>] [<reserved_blocks=<nr of reserved blocks>] [max_mounts=<nr>] [check_interval=<number of days>d] [options=<filesystem options>] |
| 680 |
---------------------------------- |
| 681 |
|
| 682 |
=== Btrfs Default SubVolumes === |
| 683 |
---------------------------------- |
| 684 |
btrfsdefaultsubvol <device> <mountpoint> <btrfs_subvolume_ID> <btrfs_subvolume_path> |
| 685 |
---------------------------------- |
| 686 |
|
| 687 |
=== Btrfs Normal SubVolumes === |
| 688 |
---------------------------------- |
| 689 |
btrfsnormalsubvol <device> <mountpoint> <btrfs_subvolume_ID> <btrfs_subvolume_path> |
| 690 |
---------------------------------- |
| 691 |
|
| 692 |
=== Btrfs Mounted SubVolumes === |
| 693 |
---------------------------------- |
| 694 |
btrfsmountedsubvol <device> <subvolume_mountpoint> <mount_options> <btrfs_subvolume_path> |
| 695 |
---------------------------------- |
| 696 |
|
| 697 |
=== Swap === |
| 698 |
---------------------------------- |
| 699 |
swap <device> [uuid=<uuid>] [label=<label>] |
| 700 |
---------------------------------- |
| 701 |
|
| 702 |
=== HP SmartArray Controllers === |
| 703 |
---------------------------------- |
| 704 |
smartarray <slot number> |
| 705 |
---------------------------------- |
| 706 |
|
| 707 |
=== HP SmartArray Logical Drives === |
| 708 |
---------------------------------- |
| 709 |
logicaldrive <device> <slot nr>|<array name>|<logical drive name> raid=<raid level> drives=<drive1,drive2> [spares=<spare1,spare2>] [sectors=<sectors>] [stripesize=<stripe size>] |
| 710 |
---------------------------------- |
| 711 |
|
| 712 |
=== TCG Opal 2-compliant Self-Encrypting Disks === |
| 713 |
---------------------------------- |
| 714 |
opaldisk <device> [boot=<[yn]>] [password=<password>] |
| 715 |
---------------------------------- |
| 716 |
|
| 717 |
|
| 718 |
== Disk Restore Script (recover mode) == |
| 719 |
|
| 720 |
The +/var/lib/rear/layout/disklayout.conf+ file is being used as input |
| 721 |
during +rear recover+ to create on-the-fly a script called +/var/lib/rear/layout/diskrestore.sh+. |
| 722 |
|
| 723 |
When something goes wrong during the recreation of partitions, volume groups, ... |
| 724 |
you will be thrown in edit mode and you can make the modification needed. |
| 725 |
However, it is desirable to have a preview mode before doing the recovery |
| 726 |
so you can review the +diskrestore.sh+ script before doing any recovery. |
| 727 |
It is better to find mistakes, obsolete arguments and so on before then later, right? |
| 728 |
|
| 729 |
Gratien wrote a script to accomplish this (script is not part of ReaR) |
| 730 |
and is meant for debugging reasons only. |
| 731 |
For more details see http://www.it3.be/2016/06/08/rear-diskrestore/ |
| 732 |
|