User Tools

Site Tools


handbook:handbook:filesystem:lv_vg:logical_volume_volume_group

How to create LVM

fdisk /dev/sdb

1. press n to create a new disk partition,
2. press p to create a primary disk partition,
3. press 1 to denote it as 1st disk partition
4. press ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition
5. press t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0x8e)
6. press L to list all the currently supported partition type
7. press 8e (as per the L listing) to change partition 1 to 8e for Linux LVM partition type
8. press p to display the secondary hard disk partition setup (2nd partition is denoted as /dev/sdb2 in Linux)
9. press w to write the partition table and exit fdisk upon completion.

Initializing disks/disk partitions

# pvcreate /dev/sdb3

# vgcreate vg_rh_new /dev/sdb3

# vgchange -a y vg_rh_new

# vgdisplay 

=====  --- Volume group ---
  VG Name               vg_rh_new
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.88 GiB
  PE Size               4.00 MiB
  Total PE              482
  Alloc PE / Size       0 / 0
  Free  PE / Size       482 / 1.88 GiB
  VG UUID               8P8ahx-F3Bv-WFC9-anJe-Ni5d-5uJW-wknh1X
 =====


# lvcreate -l 482 vg_rh_new                ---------------------> check the Total PE which in my case is 482

# mkfs -t ext3 -m 1 -v /dev/vg_rh_new/lvol0

# mkdir /mnt/newvg

# mount -t ext3 /dev/vg_rh_new/lvol0 /mnt/newvg

# vi /etc/fstab   and add the below line:

/dev/vg_rh_new/lvol0 /mnt/newvg     ext3    rw,noatime,user 0       2

Add Another Partition to the Logical Volume

# pvcreate /dev/sdb2
# vgextend vg_rh1 /dev/sdb2
# pvdisplay                                 <      use pvdisplay to find out the total available number of free PE (add the numbers from the physical volumes), then use lvextend to use up all this available space.
# lvextend -l +2435 /dev/vg_rh1/lv_root
# resize2fs /dev/vg_rh1/lv_root

Resize

# lvextend -L +1G /dev/vg_rh1/lv_root
# resize2fs -p /dev/vg_rh1/lv_root

Create a VG with extend Size of 8MB and the LV of 50 extends.

# vgcreate -s 8m my_volume_group
# lvcreate -l 50 -n my_logical_volume my_volume_group

Eduard Goiu 2011/08/16 07:23

handbook/handbook/filesystem/lv_vg/logical_volume_volume_group.txt · Last modified: 2011/10/26 11:34 by eduard