Page tree

LVM (Logical Volume Management) is a technology that can allow you to span a filesystem over multiple disks or partitions and access the storage across them as if it was a single mounted directory.

This is a worked example that demonstrates how to reconfigure the storage on a Third Light server that may already contain content, so that it gains the flexibility benefits that LVM provides. Adding additional storage in the future becomes much easier when LVM is in use and is the recommended method for configuring storage.

Assumptions made in the worked example

  1. LVM is not already in use ('lvdisplay' at the command line should return 'command not found').

  2. You have a single /space directory and not/space2, /space3 etc.

  3. Your existing content is on /space but the partition or disk it is held on is either too small or you wish to migrate to LVM for easing future storage upgrades.

  4. The existing /space mount is on /dev/sda[X] and that a new bare disk has been added as /dev/sdb.

  5. The newly-added disk will be at least as big enough to contain the content from the existing /space directory.

  6. When following these instructions, should drive lettering assignments on your system vary from the examples in these instructions, it is assumed that you will substitute as necessary. Failure to do so could result in loss of data should the wrong disk assignments be used.

Please contact [email protected] if you are in any doubt.


Overview

  1. The new disk will be setup with LVM and temporarily mounted as /space_new.
  2. Existing content from /space will be copied onto /space_new.
  3. The mounts will be swapped around and renamed so that we eventually have /space (new disk using LVM) and /space_old (original disk, no LVM).

  4. Once tested and confirmed working, the partition or disk used for /space_old can optionally be converted to LVM itself and added to the available storage (this destroys the content originally held on /space_old).

Command Line Operations

  1. Install LVM and the XFS file system tools.

    apt-get install lvm2 xfsprogs
  2. Create the physical extends, volume group and logical volume

    pvcreate /dev/sdb
    vgcreate store /dev/sdb
    lvcreate --name space -l 100%FREE store
  3. Create an XFS filesystem on the logical volume. It make take a little while to complete:

    mkfs.xfs /dev/store/space
  4. Add a reference to the new disk to the bottom of the /etc fstab file. Use the existing entry for /space as an example:

    /dev/store/space /space_new xfs noatime,nodiratime,defaults     0 2
  5. Create a mount point for the new disk and mount it:

    mkdir /space_new
    mount /space_new
  6. Install and run the 'screen' utility

    apt-get install screen
    screen

    This utility is useful if you are going to use commands (such as 'rsync' in step7) that may take a long time to run. If the terminal times out and you loose the connection, you can restore your screen with the following

    screen -ls  # to find the pid
    screen -r <pid> # To re-attach to your previous screen session
  7. Now copy the content from the existing /space to /space_new:

    rsync -Shar --progress /space/ /space_new/

    It may take a long time so consider using 'screen' if you wish to disconnect your ssh session while you wait and to allow you to continue should the  connection be lost by accident:

    http://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/

  8. The initial sync may take many hours to complete and during that time changes may be made on /space that won't be reflected in /space_new. Run the command from 7. again to sync difference from the last time it was run. Continue to do so until there are no more changes

  9. Swap the /space and /space_new mount points around:

    umount /space
    umount /space_new

    Change /etc/fstab mount points so that /space is now on the new disk and /space_old is the mount point for the original storage. You may wish to comment out or remove /space_old when you have tested the new arrangement.

    mount /space
  10. Satisfy yourself that everything is working by using the IMS web interface and that the Reporting > Storage page shows that the new disk is in use. This page updates after five minutes so may not instantly reflect the changes.

  11. Reboot. Your Chorus server will automatically add the new disk to the existing LVM storage.
  • No labels