Example of Linux full system restore from an lvm based install to a non-lvm based system.

Published 02/17/2010 05:40 PM | Updated 02/21/2010 03:01 AM


This example will show an “In Place Restore” of a complete Linux OS that was initially installed using lvm based storage to a new disk that does not have lvm based storage. Prior to performing a restore of this nature the existing OS must be examined to capture file system sizes and disk partition layouts.


This can be done by using the following commands:


1. cat /etc/fstab

2. cat /proc/partitions

3. fdisk -l

4. df

5. lvm


a) pvdisplay ← sub command within lvm

b) vgdisplay

c) lvdisplay


The following is the captured output from these commands run on a Linux system that will be used to demonstrate this restore:


# cat /etc/fstab


# This file is edited by fstab-sync - see 'man fstab-sync' for details


/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/hda /media/cdrom auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0


# cat /proc/partitions


major minor #blocks name
8 0 8388608 sda
8 1 104391 sda1
8 2 8281507 sda2
253 0 6127616 dm-0
253 1 2097152 dm-1


# fdisk -l


Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM


# df


Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 6031296 2829488 2895428 50% /
/dev/sda1 101086 10439 85428 11% /boot
none 1027604 0 1027604 0% /dev/shm


# lvm


lvm>
lvm> pvdisplay


--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 7.90 GB / not usable 23.41 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 252
Free PE 1
Allocated PE 251
PV UUID UK5qGM-55D1-I1aH-SsfA-n4pK-XRFW-mqJQke


lvm> vgdisplay


--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.88 GB
PE Size 32.00 MB
Total PE 252
Alloc PE / Size 251 / 7.84 GB
Free PE / Size 1 / 32.00 MB
VG UUID BeC5YY-AFh9-W9Il-WwNH-38uj-Okd5-ETNkZh


lvm> lvdisplay


--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID Gx7TrH-mkIS-cJYq-kyVu-MeA6-BGrr-bMQqfL
LV Write Access read/write
LV Status available
# open 1
LV Size 5.84 GB
Current LE 187
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID FaoqID-ns1A-bW48-2ZyB-xm1L-XH2k-85IuiQ
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1


lvm> exit

Resolution:


Once this information has been gathered, and a full backup has been run of the server, the client is powered off, and the system disk is then replaced with a same sized disk. In addition to that disk, another disk is also added to install a basic Linux OS which will be used to restore the original disk. Be sure to replace the original system disk with the same type of disk using the same target ID. Add the additional new disk to a different SCSI ID from the original system disk. This will ensure that reconfiguring the restored OS goes smoothly. On this system the original 8GB “sda” disk is replaced with another “sda” disk (SCSI target 0), and a new 4GB sdb disk (SCSI target 1) is added. A bare minimum Linux OS will be installed onto the sdb disk which will then get CommVault Software FS agent installed on to it. At that point a restore will be performed, restoring the data back on to sda (as it was originally installed).


From the output above it can be noted that the root “/” partition was located on /dev/VolGroup00/LogVol00, a swap partition was located on /dev/VolGroup00/LogVol01, and the “/boot” partition was located on a regular non lvm /dev/sda1 partition. The VolGroup00 was located on disk partition /dev/sda2.