Red Hat Linux LVM


There are Four steps needed to create a usable Logical Volume.
1. Prepare the physical device.
2. Create a physical volume.
3. Create a volume group.
4. Create a logical volume.

Create Logical Volume of 400 MiB.
1. Create the physical resource.
  1.1 Use fdisk to create partition.
            # fdisk /dev/vdb
  1.2 Create the Primary partition.
            # n
            # p
            # 1
            # Enter
            # +500M
   1.3. Change partition type to Linux LVM 8e.
            # t
            # 1
            # 8e
   1.4. Write changes to the partition table.
            # w
   1.5. Use partprobe to register new partition.
            # partprobe
2. Create physical volumes.
            # pvcreate /dev/vdb1
3. Create Volume Group.
            # vgcreate shazam /dev/vdb1
             shazam is the name of Volume Group
4. Create the Logical Volume.
            # lvcreate –n storage –L 400M shazam
             Storage is the name of Logical Volume, -L is used to gives size of Logical Volume.
5. Add a Persistent File System.
  5.1 Use mkfs to place file system on storage LV.
            # mkfs –t xfs /dev/shazam/storage
            -t is used to set file system type,xfs is file system type,/dev/shazam/storage is path of Logical Volume.
  5.2 Use mkdir to create a mount point at /storage.
            # mkdir /storage
  5.3 Configure /etc/fstab
            # vim /etc/fstab
            /dev/shazam/storage    /storage            xfs       defaults           0          0
  5.4 Use mount to verify the /etc/fstab entry and mount the new storage LV device.
            # mount –a
6. Verify the Logical Volume is successfully mounted at specified point.
            # df –h /storage

Most Reading