DON'T PANIC

Logical Volume Manager (LVM)

Posted on: November 16, 2010


LVM is a logical volume manager for Linux kernel. It’s based on Veritas’s logical volume manager.
LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting existing ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncating extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to RAID 0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID 1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split). This can be useful when migrating whole logical volumes to or from offline storage.
  • (Last pharagraph was taken from Wikipedia)

    1. You can create a Physical Volume on whole disk or on a patition.

    # pvcreate /dev/sda

    2. Create a Volume Group too.

    # vgcreate vg0 /dev/sda

    3. Create a Logical Volume inside Volume Group created recently.

    # lvcreate -n lv_home --size 40g vg0

    4. Format the lv_home partition.

    # mkfs.ext3 -L home /dev/mapper/lv_home

    5. You have to add entries in ”/etc/fstab” file.

    # vi /etc/fstab


    /dev/mapper/home /home ext3 defaults,noatime 0 2 0

    5. Add necessaries data to ramdisk

    # update-initramfs -u -k all

    6. Extend a LVM partition
    6.1 Boot the system using a live cd
    6.2 Umount the partition to be extended.

    #umount/mnt/lvm/localvg-usrlv

    6.3 Extend the Logical partition to 2G (giga)

    #lvextend --size +2G -n /dev/localvg/usrlv

    6.4 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    6.5 Extend the filesystem

    #resize2fs /dev/localvg/usrlv

    6.6 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    7. Reduce a LVM partition
    7.1 Umount the partition

    #umount /home

    7.2 Reduce the filesystem

    #resize2fs /dev/myvg/homevol 524288

    7.3 Reduce the LVM partition

    #lvreduce -L-1G /dev/myvg/homevol

    7.4 Run fsck

    #e2fsck -f /dev/myvg/homevol

    7.5 Mount the partition

    # mount /home

    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    Advertisements

    • None
    • analialorenzatto: Buzz is just a host name for this example, it doesn't have any relation to the topic. Instead of being "Buzz", could be whatever name.
    • fridelain: >buzz What's the story behind this host name? Actully running buzz, once running buzz and upgraded many times since, or unrelated to debian naming
    • Pratik: Nice, but I would change it to include more directories. Like my .mozilla and .kde4 by using .{config,mozilla,kde4} instead of just .config .

    Categories

    %d bloggers like this: