Data recovery from a Linux harddisk using LVM

wpid-IMG_20140103_141334.jpgReceiving a request from somebody who owns a home server I have installed in the past, I have updated myself about methods to retrieve data from Linux  hard drives with LVM volume management . The server is actually gone up in smoke . Backup hard drive, that was connected through USB have had its lifetime shortened also, it should have been the normal way to recover data without difficulties. Bad luck, electrical problem ? It doesn’t matter, server’s hard drive itself seems to be functional.

The server has been organized using same OS than my own one : Sme Serveur 7, based on Linux Centos 4 which is an open source RedHat distribution.

I already had the opportunity to manage this kind of data retrieval few years ago, with some difficulties due to lack of simple tools.
Let speak directly about the best solution for those who have a similar problem : free software Linux reader from Diskinternals company. This Windows software is able to read hard disks with ext3 / ext4 / …. filesystems. More than that it is able now to manage LVM volumes. With this software it is then possible to read back files and save them in a safer place, this process being really simple, no need to follow some complex tutorials.
More complete, but not free, tools from Diskinternals are also able to grab data from corrupted or scratched hard disks, being linux formats or others.

For people that have no such issue to solve quickly, let’s have a look to LVM volume management, and the oldest solution to recover data.

LVM (Logical Volume Management )

Logical volume management is a hardware or software overlay that sits between the physical hard disk ( splitted by sectors) and the different filesystems that are created on it . OS allocates for each filesystem a letter for Windows ( C: D:, … ), or a mount point for linux systems.

LVM organization (from

The best known logical volume management system is software RAID that you already have heard about  :

  • RAID hard disk management has been originally created as a hardware function to handle redundancy and extensions on multiple hard disks.
  • LVM system is a native software function that have been created to dynamically manage filesystems using one or more disks.

Nevertheless, evolution of these two standards over the years is so that they have very similar features today ( look at this post for a one-to-one comparison ). For instance RAID is now commonly managed by software and LVM is now able to handle all cases of redundancies like RAID.

Let’s see some concrete cases for which logical volume management is very useful on a linux server:

  • extend the size of a file system dynamically
    Several volumes are created on hard disks on which we want to have multiple filesystems. A set of non-allocated blocks are kept free on hard disks. These blocks can then be reallocated later on to volumes that require additional storage space. LVM functions also allow to increase the size of file systems ( EXT3 / EXT4 / …) without data loss.  Reduction in size of a logical volume is not so easy and may require to re-format the volume.
  • Perform a ” snapshot ” of the file system
    This is to make a snapshot at a precise time of one or more volumes. These copies can be temporary, for example to perform a backup of a linux filesystem while maintaining data integrity . The creation of a temporary snapshot requires no physical copy of the data on the disk, the creation takes less than a second.
    The copy can also be reused in a long term as a duplicate of the original data.
  • extend a file system on multiple disks
    A logical volume can span multiple disks and hence the filesystem installed on it. These discs can be of different nature and capacity.

tumblr_m94h15BXIr1rpp9doo1_400LVM is organized using 3 layers :

  • “Physical Volumes ” (LVM commands beginning with pv* ) that correspond to physical partitions on different discs.
    This is the connection point between the hardware layer and LVM management.
  • “Volume Groups” ( LVM commands starting with vg* ) that bring together several physical volumes being on one or multiple hard drives into a single entity .
  • “Logical Volumes” ( LVM commands starting with lv* ) are virtual volumes that are created onto those volume groups. Then, these logical volumes can be spread over several partitions / discs in a natural way.
    This is the point of connection with OS filesystems : each of these logical volumes will be formatted according to your needs (ext 3 , ext 4 , fat32, … )

Accessing data without Linux Reader tool

A few years ago no such windows tools was available that permits to read data from LVM volumes. We had to use other solutions, those being necessarily based on Linux. The easiest solution is to use a bootable CD / DVD offering a linux environment compatible with LVM volume management.
The best one is SystemRescueCD which offers the whole linux environment and tools for troubleshooting your computer using Linux. SystemRescueCD is integrating also LVM tools and there are some tutorials for LVM management on the website.

No GUI is however available to manage those tools, everything has to be done using command line. There are three ways to access lvm management tools :

  • calling  “lvm” executable .
    A lvm prompt appears then that enables to enter specific LVM commands. Ctrl + C is used to exit lvm.
    Example of useful command “help” 🙂
  • calling a particular function as an argument
    Example: ” lvm help”
  • specific system commands doing same function than lvm call
    “pvdisplay” command for example, should be known directly at bash level, it is equivalent to the command “lvm pvdisplay”

A list of useful commands is available here for instance. The more useful commands when starting using LVM should be undoubtedly “help”, “pvdisplay” , “vgdisplay” and “lvdisplay” to have an overview of the LVM organization  available on your hard discs.
You can find many internet tutorials to achieve the desired tasks. These tutorials should be easier to find on website related to RedHat or CentOS Linux distributions, because those are using natively LVM for a long time.

Vincent Recipon

Propriétaire de ce blog. Owner of this blog.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.