How to clon a system with logic volumes LVM: 1. - Introduction 1.1.- What is LVM? 1.2.- Why exist this how-to? 2.- Steps to follow 2.1.- Create an image or an emission being 2.2.- Restore an image or an emission being 3.- Author Copyright (C) 2006 Joan Lledó. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being list their titles, with the Front-Cover Texts being list, and with the Back-Cover Texts being list. A copy of the license is included in the file "fdl-1.2.txt". 1. - Introduction 1.1.- What is LVM? LVM (Logical Volume Manager) is an administration system of logical volumes in Linux. This system can create and manage "virtual" partitions instead of partition the HDD. These partitions are called “Logical Volumes". The primary advantages of using logical volumes are the following: - They can be easily resized to save space. - Allow using the space in one or several partitions; however they are in different hard disks; and create volumes as big as the addition of all partitions used. Project web page: http://sourceware.org/lvm2/ Article in Wikipedia with more information: http://es.wikipedia.org/wiki/Logical_Volume_Manager 1.2 Why exists this how-to? Due to with lvm you can save data in several partitions and those partitions can be in different hard disks, and gnetic only can work with a single HDD at the time, is necessary to do many operations to be able of cloning a system which is configured with lvm. The steps to follow are detailed next. 2.- Steps to follow To illustrate the process will take like an example a typical installation of Fedora in the HDD /dva/hda. In this system, /dev/hda1 is a traditional partition mounted in /boot and containing the necessary files for the system to start up. This partition is out of the lvm group because GRUB cannot read lvm partitions. The device /dev/hda2 is a partition without a file system and in this partition will be created logical volumes. The system has two logical volumes (lvm). One which is used to for the system root and the other that is used like a SWAP partition. 2.1.- Create an image or an emission being These steps must be followed when you have a system with lvm and you want to do a security copy or you want to send it over the net. 1.- Create an image with a structure of the partitions (without data) of all the hard disks that uses the system, using no-data option. In Fedora case it will be /dev/hda. gnetic -cd /dev/hda -f /mnt/hdb1/fedora-nodata.dna -n 2.- Create an image of the partitions that are out of LVM. In this case only /dev/hda1. gnetic -cd /dev/hda1 -f /mnt/hdb1/fedora-hda1.dna 3.- Activate the logic volumes. vgchange -a y 4.- Create an image of logical volumes with data. gnetic -cd /dev/VolGroup00/LogVol00 -f /mnt/hdb1/fedora-LogVol00.dna 2.2.- Restore an image or an emission being These steps must be followed when you have images of a system that was using LVM and you want to restore it. 1.- Restore no-data images from hard disks that the system was using. In Fedoras example, only /dev/hda gnetic -rd /dev/hda -f /mnt/hdb1/fedora-nodata.dna 2.- The previous command restores the LVM configuration that the hard disks had; now you can activate LVM. vgchange -a y 3.- Restore images from logical volumes with data that the system had. gnetic -rd /dev/VolGroup00/LogVol00 -f /mnt/hdb1/fedora-LogVol00.dna 4.- Fedora uses LogVol01 for SWAP partition, for that reason this partition must be formatted like SWAP. mkswap /dev/VolGroup00/LogVol01 5.- Restore images from partitions that are outside of LVM. In Fedora case, only /dev/hda1 gnetic -rd /dev/hda1 -f /mnt/hdb1/fedora-hda1.dna 6.- In case that the boot loader was GRUB, gnetic allow us restore it; for that we must specify the partition where the GRUB files are and the device where we want to install GRUB. gnetic -g /dev/hda1 -d /dev/hda 3.- Author Joan Lledó