[Rear-users] SF.net SVN: rear:[710] trunk/usr/share/rear/doc/layoutman.txt

jhoekx at users.sourceforge.net jhoekx at users.sourceforge.net
Sat Sep 10 17:23:31 CEST 2011


Revision: 710
          http://rear.svn.sourceforge.net/rear/?rev=710&view=rev
Author:   jhoekx
Date:     2011-09-10 15:23:30 +0000 (Sat, 10 Sep 2011)
Log Message:
-----------
Add a first draft of a layout engine usage guide.

Added Paths:
-----------
    trunk/usr/share/rear/doc/layoutman.txt

Added: trunk/usr/share/rear/doc/layoutman.txt
===================================================================
--- trunk/usr/share/rear/doc/layoutman.txt	                        (rev 0)
+++ trunk/usr/share/rear/doc/layoutman.txt	2011-09-10 15:23:30 UTC (rev 710)
@@ -0,0 +1,532 @@
+Relax and Recover Layout Manual
+===============================
+Jeroen Hoekx <jeroen.hoekx at hamok.be>
+2011-09-10
+
+This document describes all aspects of the system disk layout generation in Relax and Recover.
+
+== General overview ==
+The disk layout generation code in Relax and Recover is responsible for the faithful recreation of the disk layout of the original system. It gathers information about any component in the system layout. Components supported in Rear include:
+- Partitions
+- Logical volume management (LVM)
+- Software RAID (MD)
+- Encrypted volumes (LUKS)
+- Multipath disks
+- Swap
+- Filesystems
+- DRBD
+- HP SmartArray controllers
+
+Rear detects dependencies between these components.
+
+During the rescue media creation phase, Rear centralizes all information in one file. During recovery, that file is used to generate the actual commands to recreate the components. Rear allows customizations and manual editing in all these phases.
+
+== Layout information gathered during rescue image creation ==
+Layout information is stored in +/var/lib/rear/layout/disklayout.conf+. The term 'layout file' in this document refers to this particular file.
+
+Consider the information from the following system as an example:
+----------------------------------
+disk /dev/sda 160041885696 msdos
+# disk /dev/sdb 320072933376 msdos
+# disk /dev/sdc 1999696297984 msdos
+part /dev/sda 209682432 32768 primary boot /dev/sda1
+part /dev/sda 128639303680 209719296 primary lvm /dev/sda2
+part /dev/sda 31192862720 128849022976 primary none /dev/sda3
+# part /dev/sdb 162144912384 32256 primary none /dev/sdb1
+# part /dev/sdb 152556666880 162144944640 primary none /dev/sdb2
+# part /dev/sdb 5371321856 314701611520 primary boot /dev/sdb3
+# part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1
+# part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2
+# lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784
+lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544
+# lvmgrp /dev/backup 4096 220764 904249344
+lvmgrp /dev/system 4096 30669 125620224
+# lvmvol /dev/backup backup 12800 104857600 
+# lvmvol /dev/backup externaltemp 38400 314572800 
+lvmvol /dev/system root 2560 20971520 
+lvmvol /dev/system home 5120 41943040 
+lvmvol /dev/system var 2560 20971520 
+lvmvol /dev/system swap 512 4194304 
+lvmvol /dev/system vmxfs 7680 62914560 
+lvmvol /dev/system kvm 5000 40960000 
+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
+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
+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
+fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label=  options=rw,noatime
+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
+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
+swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label=
+crypt /dev/mapper/disk /dev/sda2 cipher=aes mode=xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb
+----------------------------------
+This document will continue to use this example to explore the various options available in Rear. The exact syntax of the layout file is described in a later section. It is already clear that this file is human readable and thus human editable. It is also machine readable and all information necessary to restore is a system is listed.
+
+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.
+
+== Including/Excluding components ==
+
+=== Autoexcludes ===
+
+Rear has reasonable defaults when creating the recovery information. It has commented out the two external disks and any component that's part of it. The reason is that no mounted filesystem uses these two disks. After all, you don't wan't to recreate your backup disk when you're recovering your system.
+
+If we mount the filesystem on +/dev/mapper/backup-backup+ on +/media/backup+, Rear will think that it's necessary to recreate the filesystem:
+----------------------------------
+disk /dev/sda 160041885696 msdos
+# disk /dev/sdb 320072933376 msdos
+disk /dev/sdc 1999696297984 msdos
+part /dev/sda 209682432 32768 primary boot /dev/sda1
+part /dev/sda 128639303680 209719296 primary lvm /dev/sda2
+part /dev/sda 31192862720 128849022976 primary none /dev/sda3
+# part /dev/sdb 162144912384 32256 primary none /dev/sdb1
+# part /dev/sdb 152556666880 162144944640 primary none /dev/sdb2
+# part /dev/sdb 5371321856 314701611520 primary boot /dev/sdb3
+part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1
+part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2
+lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784
+lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544
+lvmgrp /dev/backup 4096 220764 904249344
+lvmgrp /dev/system 4096 30669 125620224
+lvmvol /dev/backup backup 12800 104857600 
+lvmvol /dev/backup externaltemp 38400 314572800 
+lvmvol /dev/system root 2560 20971520 
+lvmvol /dev/system home 5120 41943040 
+lvmvol /dev/system var 2560 20971520 
+lvmvol /dev/system swap 512 4194304 
+lvmvol /dev/system vmxfs 7680 62914560 
+lvmvol /dev/system kvm 5000 40960000 
+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
+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
+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
+fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label=  options=rw,noatime
+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
+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
+fs /dev/mapper/backup-backup /media/backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw
+swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label=
+crypt /dev/mapper/disk /dev/sda2 cipher=aes mode=xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb
+----------------------------------
+
+This behavior is controlled by the +AUTOEXCLUDE_DISKS=y+ parameter in +default.conf+. If we unset it in the local configuration, Rear will nog longer exclude it automatically.
+
+A similar mechanism exists for multipath disks. The +AUTOEXCLUDE_MULTIPATH=y+ variable in +default.conf+ prevents Rear from overwriting multipath disks. Typically, they are part of the SAN disaster recovery strategy. However, there can be cases where you want to recover them. The information is retained in +disklayout.conf+.
+
+=== Manual excludes ===
+It seems prudent to prevent the external drives from ever being backed-up or overwritten. The default configuration contains these lines:
+----------------------------------
+# Exclude components from being backed up, recreation information is active
+EXCLUDE_BACKUP=()
+
+# Exclude components during component recreation
+# will be added to EXCLUDE_BACKUP (it is not backed up)
+# recreation information gathered, but commented out
+EXCLUDE_RECREATE=()
+
+# Exclude components during the backup restore phase
+# Only used to exclude files from the restore.
+EXCLUDE_RESTORE=()
+----------------------------------
+
+To prevent an inadvertently mounted backup filesystem being added to the restore list, the easiest way is to add the filesystem to the +EXCLUDE_RECREATE+ array.
+----------------------------------
+EXCLUDE_RECREATE=( "${EXCLUDE_RECREATE[@]}" "fs:/media/backup" )
+----------------------------------
+
+The layout file is as expected:
+----------------------------------
+disk /dev/sda 160041885696 msdos
+# disk /dev/sdb 320072933376 msdos
+# disk /dev/sdc 1999696297984 msdos
+part /dev/sda 209682432 32768 primary boot /dev/sda1
+part /dev/sda 128639303680 209719296 primary lvm /dev/sda2
+part /dev/sda 31192862720 128849022976 primary none /dev/sda3
+# part /dev/sdb 162144912384 32256 primary none /dev/sdb1
+# part /dev/sdb 152556666880 162144944640 primary none /dev/sdb2
+# part /dev/sdb 5371321856 314701611520 primary boot /dev/sdb3
+# part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1
+# part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2
+# lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784
+lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544
+# lvmgrp /dev/backup 4096 220764 904249344
+lvmgrp /dev/system 4096 30669 125620224
+# lvmvol /dev/backup backup 12800 104857600 
+# lvmvol /dev/backup externaltemp 38400 314572800 
+lvmvol /dev/system root 2560 20971520 
+lvmvol /dev/system home 5120 41943040 
+lvmvol /dev/system var 2560 20971520 
+lvmvol /dev/system swap 512 4194304 
+lvmvol /dev/system vmxfs 7680 62914560 
+lvmvol /dev/system kvm 5000 40960000 
+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
+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
+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
+fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label=  options=rw,noatime
+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
+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
+# fs /dev/mapper/backup-backup /media/backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw
+swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label=
+crypt /dev/mapper/disk /dev/sda2 cipher=aes mode=xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb
+----------------------------------
+
+Another approach would be to exclude the backup volume group. This is achieved by adding this line to the local configuration:
+----------------------------------
+EXCLUDE_RECREATE=( "${EXCLUDE_RECREATE[@]}" "/dev/backup" )
+----------------------------------
+
+== Restore to the same hardware ==
+Restoring the system to the same hardware is simple. Type +rear recover+ in the rescue system prompt. Rear will detect that it's restoring to the same system and will make sure things like UUIDs match. It also asks my LUKS encryption password.
+
+Once the restore of the backup is completed, Rear will install the bootloader and the system is back in working order.
+----------------------------------
+RESCUE firefly:~ # rear recover
+Relax and Recover 0.0.0 / $Date$
+NOTICE: Will do driver migration
+Comparing disks.
+Disk configuration is identical, proceeding with restore.
+Start system layout restoration.
+Creating partitions for disk /dev/sda (msdos)
+Please enter the password for disk(/dev/sda2):
+Enter LUKS passphrase: 
+Please re-enter the password for disk(/dev/sda2):
+Enter passphrase for /dev/sda2: 
+Creating LVM PV /dev/mapper/disk
+Restoring LVM VG system
+Creating ext4-filesystem / on /dev/mapper/system-root
+Mounting filesystem /
+Creating ext4-filesystem /home on /dev/mapper/system-home
+Mounting filesystem /home
+Creating ext4-filesystem /var on /dev/mapper/system-var
+Mounting filesystem /var
+Creating xfs-filesystem /vmware on /dev/mapper/system-vmxfs
+meta-data=/dev/mapper/system-vmxfs isize=256    agcount=4, agsize=1966080 blks
+         =                       sectsz=512   attr=2, projid32bit=0
+data     =                       bsize=4096   blocks=7864320, imaxpct=25
+         =                       sunit=0      swidth=0 blks
+naming   =version 2              bsize=4096   ascii-ci=0
+log      =internal log           bsize=4096   blocks=3840, version=2
+         =                       sectsz=512   sunit=0 blks, lazy-count=1
+realtime =none                   extsz=4096   blocks=0, rtextents=0
+Mounting filesystem /vmware
+Creating ext4-filesystem /kvm on /dev/mapper/system-kvm
+Mounting filesystem /kvm
+Creating ext3-filesystem /boot on /dev/sda1
+Mounting filesystem /boot
+Creating swap on /dev/mapper/system-swap
+Disk layout created.
+Please start the restore process on your backup host.
+
+Make sure that you restore the data into '/mnt/local' instead of '/' because the
+hard disks of the recovered system are mounted there.
+
+Please restore your backup in the provided shell and, when finished, type exit
+in the shell to continue recovery.
+
+Welcome to Relax and Recover. Run "rear recover" to restore your system !
+
+rear>
+----------------------------------
+== Restore to different hardware ==
+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 will be carried out by less knowledgeable people.
+
+=== The Ad-Hoc Way ===
+Rear will assist you somewhat in case it notices different disk sizes. It will ask you to map each differently sized disk to a disk in the target system. Partitions will be resized. Rear is careful not to resize your boot partition, since this is often the one with the most stringent sizing constraints. In fact, it only resizes LVM and RAID partitions.
+
+Let's try to restore our system to a different system. Instead of one 160G disk, there is now one 5G and one 10G disk. That's not enough space to restore the complete system, but for purposes of this demonstration, we do not care about that. We're also not going to use the first disk, but we just want to show that Rear handles the renaming automatically.
+
+----------------------------------
+RESCUE firefly:~ # rear recover
+Relax and Recover 0.0.0 / $Date$
+NOTICE: Will do driver migration
+Comparing disks.
+Device sda has size 5242880000, 160041885696 expected
+Switching to manual disk layout configuration.
+Disk sda does not exist in the target system. Please choose the appropriate replacement.
+1) sda
+2) sdb
+3) Do not map disk.
+#? 2
+2011-09-10 16:17:10 Disk sdb chosen as replacement for sda.
+Disk sdb chosen as replacement for sda.
+This is the disk mapping table:
+    /dev/sda /dev/sdb
+Please confirm that '/var/lib/rear/layout/disklayout.conf' is as you expect.
+
+1) View disk layout (disklayout.conf)  4) Go to Rear shell
+2) Edit disk layout (disklayout.conf)  5) Continue recovery
+3) View original disk space usage      6) Abort Rear
+----------------------------------
+
+Ok, mapping the disks was not that hard. If Rear insists on us checking the disklayout file, we'd better do that.
+
+----------------------------------
+#? 1
+disk /dev/sdb 160041885696 msdos
+# disk _REAR1_ 320072933376 msdos
+# disk /dev/sdc 1999696297984 msdos
+part /dev/sdb 209682432 32768 primary boot /dev/sdb1
+part /dev/sdb -20916822016 209719296 primary lvm /dev/sdb2
+part /dev/sdb 31192862720 128849022976 primary none /dev/sdb3
+# part _REAR1_ 162144912384 32256 primary none _REAR1_1
+# part _REAR1_ 152556666880 162144944640 primary none _REAR1_2
+# part _REAR1_ 5371321856 314701611520 primary boot _REAR1_3
+# part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1
+# part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2
+# lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784
+lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544
+# lvmgrp /dev/backup 4096 220764 904249344
+lvmgrp /dev/system 4096 30669 125620224
+# lvmvol /dev/backup backup 12800 104857600 
+# lvmvol /dev/backup externaltemp 38400 314572800 
+lvmvol /dev/system root 2560 20971520 
+lvmvol /dev/system home 5120 41943040 
+lvmvol /dev/system var 2560 20971520 
+lvmvol /dev/system swap 512 4194304 
+lvmvol /dev/system vmxfs 7680 62914560 
+lvmvol /dev/system kvm 5000 40960000 
+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
+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
+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
+fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label=  options=rw,noatime
+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
+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
+# fs /dev/mapper/backup-backup /media/backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw
+swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label=
+crypt /dev/mapper/disk /dev/sdb2 cipher=aes mode=xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb
+
+1) View disk layout (disklayout.conf)
+2) Edit disk layout (disklayout.conf)
+3) View original disk space usage
+4) Go to Rear shell
+5) Continue recovery
+6) Abort Rear
+#? 
+----------------------------------
+The renaming operation was successful.
+
+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.
+
+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.
+
+The resulting layout file looks like this:
+----------------------------------
+disk /dev/sdb 160041885696 msdos
+# disk _REAR1_ 320072933376 msdos
+# disk /dev/sdc 1999696297984 msdos
+part /dev/sdb 209682432 32768 primary boot /dev/sdb1
+part /dev/sdb -20916822016 209719296 primary lvm /dev/sdb2
+part /dev/sdb 31192862720 128849022976 primary none /dev/sdb3
+# part _REAR1_ 162144912384 32256 primary none _REAR1_1
+# part _REAR1_ 152556666880 162144944640 primary none _REAR1_2
+# part _REAR1_ 5371321856 314701611520 primary boot _REAR1_3
+# part /dev/sdc 1073741824000 1048576 primary boot /dev/sdc1
+# part /dev/sdc 925953425408 1073742872576 primary lvm /dev/sdc2
+# lvmdev /dev/backup /dev/sdc2 cJp4Mt-Vkgv-hVlr-wTMb-0qeA-FX7j-3C60p5 1808502784
+lvmdev /dev/system /dev/mapper/disk N4Hpdc-DkBP-Hdm6-Z6FH-VixZ-7tTb-LiRt0w 251244544
+# lvmgrp /dev/backup 4096 220764 904249344
+lvmgrp /dev/system 4096 30669 125620224
+# lvmvol /dev/backup backup 12800 104857600 
+# lvmvol /dev/backup externaltemp 38400 314572800 
+lvmvol /dev/system root 2560 20971520 
+lvmvol /dev/system home 5120 41943040 
+lvmvol /dev/system var 2560 20971520 
+lvmvol /dev/system swap 512 4194304 
+#lvmvol /dev/system vmxfs 7680 62914560 
+#lvmvol /dev/system kvm 5000 40960000 
+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
+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
+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
+#fs /dev/mapper/system-vmxfs /vmware xfs uuid=7457d2ab-8252-4f41-bab6-607316259975 label=  options=rw,noatime
+#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
+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
+# fs /dev/mapper/backup-backup /media/backup ext4 uuid=da20354a-dc4c-4bef-817c-1c92894bb002 label= blocksize=4096 reserved_blocks=655360 max_mounts=24 check_interval=180d options=rw
+swap /dev/mapper/system-swap uuid=9f347fc7-1605-4788-98fd-fca828beedf1 label=
+crypt /dev/mapper/disk /dev/sdb2 cipher=aes mode=xts-plain hash=sha1 uuid=beafe67c-d9a4-4992-80f1-e87791a543bb
+----------------------------------
+
+Let's continue recovery.
+
+----------------------------------
+1) View disk layout (disklayout.conf)
+2) Edit disk layout (disklayout.conf)
+3) View original disk space usage
+4) Go to Rear shell
+5) Continue recovery
+6) Abort Rear
+#? 5
+Partition /dev/sdb3 size reduced to fit on disk.
+Please confirm that '/var/lib/rear/layout/diskrestore.sh' is as you expect.
+
+1) View restore script (diskrestore.sh)
+2) Edit restore script (diskrestore.sh)
+3) View original disk space usage
+4) Go to Rear shell
+5) Continue recovery
+6) Abort Rear
+#? 
+----------------------------------
+
+Now, this is where human friendly resizes are possible. Edit the file. Find the partition creation code.
+
+----------------------------------
+if create_component "/dev/sdb" "disk" ; then
+# Create /dev/sdb (disk)
+LogPrint "Creating partitions for disk /dev/sdb (msdos)"
+parted -s /dev/sdb mklabel msdos >&2
+parted -s /dev/sdb mkpart primary 32768B 209715199B >&2
+parted -s /dev/sdb set 1 boot on >&2
+parted -s /dev/sdb mkpart primary 209719296B -20707102721B >&2
+parted -s /dev/sdb set 2 lvm on >&2
+parted -s /dev/sdb mkpart primary 18446744053002452992B 10485759999B >&2
+# Wait some time before advancing
+sleep 10
+----------------------------------
+It's simple bash code. Change it to use better values. Parted is happy to accept partitions in Megabytes.
+----------------------------------
+if create_component "/dev/sdb" "disk" ; then
+# Create /dev/sdb (disk)
+LogPrint "Creating partitions for disk /dev/sdb (msdos)"
+parted -s /dev/sdb mklabel msdos >&2
+parted -s /dev/sdb mkpart primary 1M 200M >&2
+parted -s /dev/sdb set 1 boot on >&2
+parted -s /dev/sdb mkpart primary 200M 10485759999B >&2
+parted -s /dev/sdb set 2 lvm on >&2
+# Wait some time before advancing
+sleep 10
+----------------------------------
+The same action should be done for the remaining logical volumes. We would like them to fit on the disk.
+----------------------------------
+if create_component "/dev/mapper/system-root" "lvmvol" ; then
+# Create /dev/mapper/system-root (lvmvol)
+LogPrint "Creating LVM volume system/root"
+lvm lvcreate -l 2560 -n root system >&2
+component_created "/dev/mapper/system-root" "lvmvol"
+else
+    LogPrint "Skipping /dev/mapper/system-root (lvmvol) as it has already been created."
+fi
+----------------------------------
+No-one but a computer likes to think in extents, so we size it a comfortable 5G.
+----------------------------------
+if create_component "/dev/mapper/system-root" "lvmvol" ; then
+# Create /dev/mapper/system-root (lvmvol)
+LogPrint "Creating LVM volume system/root"
+lvm lvcreate -L 5G -n root system >&2
+component_created "/dev/mapper/system-root" "lvmvol"
+else
+    LogPrint "Skipping /dev/mapper/system-root (lvmvol) as it has already been created."
+fi
+----------------------------------
+Do the same thing for the other logical volumes and choose number 5, continue.
+----------------------------------
+1) View restore script (diskrestore.sh)
+2) Edit restore script (diskrestore.sh)
+3) View original disk space usage
+4) Go to Rear shell
+5) Continue recovery
+6) Abort Rear
+#? 5
+Start system layout restoration.
+Creating partitions for disk /dev/sdb (msdos)
+Please enter the password for disk(/dev/sdb2):
+Enter LUKS passphrase: 
+Please re-enter the password for disk(/dev/sdb2):
+Enter passphrase for /dev/sdb2: 
+Creating LVM PV /dev/mapper/disk
+Creating LVM VG system
+Creating LVM volume system/root
+Creating LVM volume system/home
+Creating LVM volume system/var
+Creating LVM volume system/swap
+Creating ext4-filesystem / on /dev/mapper/system-root
+Mounting filesystem /
+Creating ext4-filesystem /home on /dev/mapper/system-home
+An error occured during layout recreation.
+
+1) View Rear log
+2) View original disk space usage
+3) Go to Rear shell
+4) Edit restore script (diskrestore.sh)
+5) Continue restore script
+6) Abort Rear
+#?
+----------------------------------
+An error... Did you expect it? I didn't.
+
+Rear produces exceptionally good logs. Let's check them.
+----------------------------------
++++ tune2fs -r 262144 -c 38 -i 180d /dev/mapper/system-home
+tune2fs: reserved blocks count is too big (262144)
+tune2fs 1.41.14 (22-Dec-2010)
+Setting maximal mount count to 38
+Setting interval between checks to 15552000 seconds
+2011-09-10 16:27:35 An error occured during layout recreation.
+----------------------------------
+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.
+
+Fixing it is simple. Edit the restore script, option 4. Find the code responsible for filesystem creation.
+
+----------------------------------
+if create_component "fs:/home" "fs" ; then
+# Create fs:/home (fs)
+LogPrint "Creating ext4-filesystem /home on /dev/mapper/system-home"
+mkfs -t ext4 -b 4096 /dev/mapper/system-home >&2
+tune2fs -U e9310015-6043-48cd-a37d-78dbfdba1e3b /dev/mapper/system-home >&2
+tune2fs -r 262144 -c 38 -i 180d /dev/mapper/system-home >&2
+LogPrint "Mounting filesystem /home"
+mkdir -p /mnt/local/home
+mount /dev/mapper/system-home /mnt/local/home
+component_created "fs:/home" "fs"
+else
+    LogPrint "Skipping fs:/home (fs) as it has already been created."
+fi
+----------------------------------
+The +-r+ parameter is causing the error. We just remove it and do the same for the other filesystems.
+----------------------------------
+if create_component "fs:/home" "fs" ; then
+# Create fs:/home (fs)
+LogPrint "Creating ext4-filesystem /home on /dev/mapper/system-home"
+mkfs -t ext4 -b 4096 /dev/mapper/system-home >&2
+tune2fs -U e9310015-6043-48cd-a37d-78dbfdba1e3b /dev/mapper/system-home >&2
+tune2fs -c 38 -i 180d /dev/mapper/system-home >&2
+LogPrint "Mounting filesystem /home"
+mkdir -p /mnt/local/home
+mount /dev/mapper/system-home /mnt/local/home
+component_created "fs:/home" "fs"
+else
+    LogPrint "Skipping fs:/home (fs) as it has already been created."
+fi
+----------------------------------
+Continue the restore script.
+----------------------------------
+1) View Rear log
+2) View original disk space usage
+3) Go to Rear shell
+4) Edit restore script (diskrestore.sh)
+5) Continue restore script
+6) Abort Rear
+#? 5
+Start system layout restoration.
+Skipping /dev/sdb (disk) as it has already been created.
+Skipping /dev/sdb1 (part) as it has already been created.
+Skipping /dev/sdb2 (part) as it has already been created.
+Skipping /dev/sdb3 (part) as it has already been created.
+Skipping /dev/mapper/disk (crypt) as it has already been created.
+Skipping pv:/dev/mapper/disk (lvmdev) as it has already been created.
+Skipping /dev/system (lvmgrp) as it has already been created.
+Skipping /dev/mapper/system-root (lvmvol) as it has already been created.
+Skipping /dev/mapper/system-home (lvmvol) as it has already been created.
+Skipping /dev/mapper/system-var (lvmvol) as it has already been created.
+Skipping /dev/mapper/system-swap (lvmvol) as it has already been created.
+Skipping fs:/ (fs) as it has already been created.
+Creating ext4-filesystem /home on /dev/mapper/system-home
+Mounting filesystem /home
+Creating ext4-filesystem /var on /dev/mapper/system-var
+Mounting filesystem /var
+Creating ext3-filesystem /boot on /dev/sdb1
+Mounting filesystem /boot
+Creating swap on /dev/mapper/system-swap
+Disk layout created.
+----------------------------------
+That looks the way we want it. Notice how Rear detected that it had already created quite a few components and dit not try to recreate them anymore.
+
+=== Planning In Advance ===
+Rear makes it possible to define the layout on the target system even before the backup is taken. All one has to do is to move the +/var/lib/rear/layout/disklayout.conf+ file to +/etc/rear/disklayout.conf+ and edit it. This won't be overwritten on future backup runs. During recovery, Rear will use that file instead of the snapshot of the original system.
+
+== Disk layout file syntax ==
+TBW
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rear-users mailing list