Results 1 to 5 of 5

Thread: Managing filesystem LVM in linux

  1. #1
    Join Date
    Feb 2010
    Posts
    136

    Managing filesystem LVM in linux

    1. Introduction
    This tutorial shows you the installation and management of a LVM (Logical Volume Manager). It is important for administrators to manage disk space with precision. Users often make the mistake of asking their space is too big or too small, or worse, they have forgotten a file system and more! Linux, the management system LVM is simple, efficient and flexible than the good old primary partitions, extended and secondary.

    1.1. Concept of LVM
    The system inserts LVM sub-layers between the disk partition and the filesystem (where are your data). These sub-layers will allow you to dynamically change the size of file systems, without compromising your data. So you can add, remove the disk space on a filesystem on the fly, add a file system without changing the partition table. These two layers are called: the "Volume Group (abbreviation: VG)" and the "Logical Volume (or LV)".
    At a "Volume Group", we will allocate disk partitions. Each disk or disk partition assigned to a VG is exclusively reserved. It is impossible to assign the same disk to several VG.
    In each LV, we will create several LV. Each LV is then formatted and installed in our tree to be used by end users. When we format a VG we actually create a file system (fs): is this layer that you use when performing operation of the installation.

    A little sketch:
    Code:
    Partition(s) of Volume Group disk |----> |----> Logicals Volumes 
    |----> filesystem
    Instead of:
    Code:
    A disk partition file system |---->
    These intermediate layers will therefore allow better mobility of our file systems.

  2. #2
    Join Date
    Feb 2010
    Posts
    136

    Re: Managing filesystem LVM in linux

    2. System Preparation

    2.1. Installation tools
    Installation requires simply a packet, the LVM tools (version 2). You will get all the commands to manipulate the LVM.
    On GNU/Linux Debian:
    Code:
    apt-get install lvm2

    2.2. Kernel Configuration
    You will need to recompile your kernel to add the following modules:
    Code:
    [*] Multiple devices driver support (RAID and LVM) <M> 
    Logical volume manager (LVM) support
    I leave this to you, to rebuild your kernel and reboot it.

  3. #3
    Join Date
    Feb 2010
    Posts
    136

    Re: Managing filesystem LVM in linux

    3. Installing LVM:

    3.1. Create a partition on the disk
    fdisk is the tool of reference for the disk partition under Linux. We will create a 80GB partition to type LVM.
    Code:
    [Root @ test root] # fdisk / dev / hda
    After issuing this command you will get a detailed information about your disk. Do not forget to make a "toggle" the partition type to "Linux LVM". Another operation is performed to initialize the disk to LVM.
    Code:
    [Root @ test root] # pvcreate / dev/hda1
    Know we have our partition ready for use.


    3.2. Create our VG
    This VG called test_vg. A VG is made up of one or more partitions. Let's create our VG, called test_vg.
    Code:
    [Root @ test root] # vgcreate test_vg / dev/hda1
    We have initialized our VG with the partition / dev/hda1. Now look what you've created:
    Code:
    [Root @ test root] # vgdisplay-v test_vg Using volume group(s) on command line 
    Finding volume group test_vg "--- Volume group --- VG Name System ID Format lvm2 
    film_vg Metadata Areas 1
    Off-course you will get more information in this, when you will see it on your terminal. The PV is the volume Physics: in our case the partition / dev/hda1. A new acronym is: PE. What is a PE? It is the smallest unit of your VG. A VL has a minimum size of 4.00Mb (the size of PE in our case).


    3.3. Create an LV
    We must now create a LV. We will create a LV of 10GB for movies in Black and White in the LV test_vg.
    Code:
    [Root @ test root] # lvcreate-L10000-n movies test_vg
    Now we can see its features via the command:
    Code:
    [Root @ test root] # lvdisplay-v / dev / test_vg / movies --- Logical volume --- LV Name / dev / test_vg / movies
    You will get more information on this in your terminal.
    Now that the number is 2500 LE in our case. The LE is the number of units assigned to your PE logical volume.
    THE Size of a LV Size = EP
    Code:
    2500 * 4M = 10000M
    We do have the desired size. We could have used the following command to give rather LE desired:
    Code:
    [Root @ test root] # lvcreate-l2500-n movies test_vg

    3.4. Create the file system.
    We often use the word format, which I do not agree with. In fact, we create a layer called the filesystem (or filesystem).
    To create an ext3 filesystem:
    Code:
    [Root @ test root] # mkfs.ext3 / dev / test_vg / movies
    We can then do the editing of our new partition.
    Code:
    [Root @ test root] # mkdir-p / eng / myfav 
    [root @ test root] # mount / dev / test_vg / movies / eng / myfav
    So we led to the creation of a file system used. Now we can pass the management of LVM, which will show us its power.

  4. #4
    Join Date
    Feb 2010
    Posts
    136

    Re: Managing filesystem LVM in linux

    4. The LVM: Management and Administration

    4.1. How to enlarge the size of a file system?
    The problem is as follows. I organized my file systems as follows:
    Code:
    test_vg 10GB: movies mounted on / eng / 20GB myfav: music on / eng / Color 30GB: freesp 20GB of free space unused.
    But I have more space in / eng / myfav. Well yes, missing 1024 MB. The solution of yesteryear would have been to safeguard the movies, destroy / recreate the partition, remake the file system and copy the files. In our case, two commands are sufficient. Mind you the pattern of layers:
    Code:
    Partition (s) of Volume Group disk |----> |----> Logicals Volumes 
    |----> Filesystem
    We have two layers to change: Logical Volume and Filesystem.

    First step: disassembly
    Code:
    [Root @ test root] # umount / eng / myfav
    The system file is removed, we can work.

    Second operation: Enlarged and the LV.
    Code:
    [Root @ test root] # lvextend-L 1024 M / dev / test_vg / movies
    Third operation: put the file system to the size of the LV.
    Code:
    [Root @ test root] # resize2fs / dev / test_vg / movies
    Fourth operation: assembly
    Code:
    [Root @ test root] # mount / dev / test_vg / movies / eng / myfav
    The second and third operation may be launched only once for formats via ext2/ext3 e2fsadm.
    Code:
    [Root @ test root] # L-1024 e2fsadm M / dev / test_vg / movies

    4.2. How to reduce the size of a file system?
    You can also reduce the LV and the filesystem. But the operation has some significant risks. The process is the same. I give you the control to reduce the LV (the file system does not change):
    Code:
    [Root @ test root] # lvreduce-L-1024m / dev / test_vg / movies
    You can also remove an LV. It must first unmount the file system. All data will be lost.
    Code:
    [Root @ test root] # lvremove / dev / test_vg / music

    4.3. Special case of LV stripping
    The stripping is to write on alternate PV, then another, the data blocks. These blocks(k) are defined to create the LV, a power of 2.
    Example:
    Code:
    lvccreate-i2-I10-L100M-lv lv_test test_vg
    For the option "-i", 2 corresponds to the number of stripes you want.
    For the option "-I", 4 is the stripe size (4KB)

  5. #5
    Join Date
    Feb 2010
    Posts
    136

    Re: Managing filesystem LVM in linux

    5. Logical Volume Transactions

    5.1. How to add a partition VG?
    The management of a VG is mainly the addition of a partition in a VG, or delete it.
    Here is am example
    Code:
    [Root @ test root] # vgextend test_vg / dev/hdb1
    Can add to the VG test_vg first partition hdb. You can then add / change / extend your LVs at will.


    5.2. How to remove a partition in VG?
    To remove a partition:
    Code:
    [Root @ test root] # vgreduce test_vg / dev/hda1

    Warning:
    You can not remove a partition if there is not enough room on other partitions of Volume Group.

Similar Threads

  1. Replies: 9
    Last Post: 10-09-2011, 11:10 PM
  2. Read only root filesystem on Linux
    By Abeni in forum Operating Systems
    Replies: 6
    Last Post: 01-06-2011, 02:41 AM
  3. Managing path under windows and linux
    By Remedy in forum Software Development
    Replies: 4
    Last Post: 03-03-2010, 11:18 AM
  4. What are the Filesystem Security in PHP?
    By super soaker in forum Software Development
    Replies: 4
    Last Post: 26-02-2010, 06:10 AM
  5. Accelerate NTFS filesystem
    By XDRoX in forum Tips & Tweaks
    Replies: 1
    Last Post: 20-03-2009, 01:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,247,013.15765 seconds with 17 queries